omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. smartvipere75

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    • Profile
    • Following 1
    • Followers 0
    • Topics 4
    • Posts 11
    • Best 1
    • Controversial 0
    • Groups 0

    smartvipere75

    @smartvipere75

    1
    Reputation
    907
    Profile views
    11
    Posts
    0
    Followers
    1
    Following
    Joined Last Online

    smartvipere75 Unfollow Follow

    Best posts made by smartvipere75

    • RE: ObjC float2 to ctypes.Structure

      @dgelessus said:

      Ah, that's an auto-generated header from a class dump or something like that. I was looking at the "real" headers from the iOS SDK, which use vector types. (The iOS SDK headers aren't available online, the closest thing you can see is Apple's online documentation for GKAgent2D.position.) I'm guessing that during compilation some "magic" happens to properties/methods that use vector types, and the result is what you see in the class dump header. You could try using the methods position_ and setPosition__ (note the extra underscores), which according to the class dump header use structs instead of vector types.

      Thank you very much, using the methods with underscore solved the problem!

      posted in Pythonista
      smartvipere75
      smartvipere75

    Latest posts made by smartvipere75

    • GKPath question

      I have a float2 struct that works perfectly:

      class float2(Structure):
      	_fields_ = [('x',c_float),('y',c_float)]```
      

      How can I implement this method of GKPath:

      - (instancetype)initWithPoints:(vector_float2 *)points 
                               count:(size_t)count 
                              radius:(float)radius 
                            cyclical:(BOOL)cyclical
      

      Specifically, the problem is when I pass array of float2 to points parameters, app crashes.

      Reference:
      GKPath initWithPoints:count:radius:cyclical:

      posted in Pythonista
      smartvipere75
      smartvipere75
    • RE: ObjC float2 to ctypes.Structure

      @dgelessus said:

      Ah, that's an auto-generated header from a class dump or something like that. I was looking at the "real" headers from the iOS SDK, which use vector types. (The iOS SDK headers aren't available online, the closest thing you can see is Apple's online documentation for GKAgent2D.position.) I'm guessing that during compilation some "magic" happens to properties/methods that use vector types, and the result is what you see in the class dump header. You could try using the methods position_ and setPosition__ (note the extra underscores), which according to the class dump header use structs instead of vector types.

      Thank you very much, using the methods with underscore solved the problem!

      posted in Pythonista
      smartvipere75
      smartvipere75
    • RE: SpriteKit problem

      @JonB said:

      node.physicsBody().contactTestBitMask=1

      in two places (end of your shape creation functions) solves the issue.

      contactTestBitMask is mentioned in the description of https://developer.apple.com/documentation/spritekit/skphysicscontactdelegate , and looking at the description shows that it is a way of only responding to contacts that you care about.

      Thank you so much for your help! I highly appreciate it, and it’s that situation when code wasn’t working because of simple mistake.

      posted in Pythonista
      smartvipere75
      smartvipere75
    • RE: ObjC float2 to ctypes.Structure

      @JonB said:

      @dgelessus, are you sure?
      Looking at the headers for GKAgent2D, that looks like a normal struct.

      Exactly, since it’s a a normal struct than what can be wrong with my code?

      posted in Pythonista
      smartvipere75
      smartvipere75
    • RE: ObjC float2 to ctypes.Structure

      @dgelessus said:

      vector_float2 is a native vector type and not a normal struct. Working with vectors requires different CPU instructions than the ones for normal values. ctypes doesn't support vector types, so I don't think you can use vector types from Pythonista.

      Thanks for explanation, sounds like it's impossible but I still have a hope. Can you suggest any possible solution? And also could you please check this post regarding SpriteKit contactDelegate issue:
      https://forum.omz-software.com/topic/4267/spritekit-problem

      posted in Pythonista
      smartvipere75
      smartvipere75
    • ObjC float2 to ctypes.Structure

      Hello, for some reasons the y value of float2 ctypes.Structure doesn’t change. You can run the code from link below and check console. What’s causing this and how to fix it?
      Here is a code (line 46):
      https://gist.github.com/7f46b31bd43959f937b58a54a24e91a0

      posted in Pythonista
      smartvipere75
      smartvipere75
    • SpriteKit problem

      Hello, I am opening this topic once again since I still didn't get solution. Basically i’m trying to set contactDelegate on physicsWorld of SKScene that’s created through create_objc_class but it doesn’t work. Any ideas? Thanks in advance.

      Here is full code:
      https://gist.github.com/anonymous/2530353b2a41c19746bf9c0e0fa9a57f

      Note:
      The code is basically modified version of this:
      https://github.com/jbking/pythonista-misc/blob/master/spritekit/skview-demo.py

      posted in Pythonista
      smartvipere75
      smartvipere75
    • RE: SpriteKit contactDelegate doesn’t work

      @omz said:

      I can't test this right now, but I have a suspicion that you need to set the argtypes and restype properties of the ObjC method manually. The derivation from the protocols argument doesn't always work reliably if the protocol isn't used as part of Pythonista itself. I hope this makes sense.

      I completely forgot about argtypes and restype honestly. It makes sense, I will keep trying to find out correct argtypes. Thanks for your suggestion. Please let me know once you test.

      posted in Pythonista
      smartvipere75
      smartvipere75
    • RE: SpriteKit contactDelegate doesn’t work

      @JonB said:

      By doesn't work, is it crashing, or just does not receive callbacks?
      You might try keeping a copy (rather than alloc.init() inside the function call) -- I am not 100% sure if setting the delegate also increments the retain count, so you might be losing your object before it gets used.

      I mean it doesn’t receive callbacks, as if I didn’t set delegate. And I posted a link to full code

      posted in Pythonista
      smartvipere75
      smartvipere75
    • RE: SpriteKit contactDelegate doesn’t work

      @omz Here is full code:
      https://gist.github.com/anonymous/2530353b2a41c19746bf9c0e0fa9a57f

      Note:
      The code is basically modified version of this:
      https://github.com/jbking/pythonista-misc/blob/master/spritekit/skview-demo.py

      posted in Pythonista
      smartvipere75
      smartvipere75