Forum Archive

SpriteKit problem

smartvipere75

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

JonB

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.

smartvipere75

@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.