Does SpriteKit use physics if I reposition and rotate the SKSpriteNode directly without SKAction?

For example, if I want to make my own animation and move SKSpriteNode every frame programmatically using x += 10, will the Sprite Kit still apply physics correctly or should I always use SKAction?

+3
source share
2 answers

Manually moving a node with a physical body is possible no matter how and when you do it. But in any case, this is not recommended, as this can adversely affect physical modeling. A node (view) may not be synchronized with the position of the body for 1 frame, and you can move the body into a collision, which the physics engine will force to resolve, causing jumps, jitter, explosion speed or missed collisions.

When you use physics, stick to the movement of the physical body by force, momentum, or by changing the speed of the body directly.

+4
source

No, you do not need to use SKActionto move SKSpriteNode. This approach is great for me:

- (void)update:(CFTimeInterval)currentTime {
     myNode.position = CGPointMake(myNode.position.x + 0.1,myNode.position.y);
}

All physics works as expected

+2

Source: https://habr.com/ru/post/1548511/


All Articles