I’m trying to accurately determine the point at which a node moving with velocity hits the very edge of the screen. At the moment, the node’s position registers later, beyond the screen edge (and more so when travelling faster) when checking if its position is >=
to self.frame.maxX
(using ==
doesn't register at all).
Having initially tried using bit masks applied to the sprite and a border physics body acting as a wall - and coming across well known issues with collision detection in SpriteKit - I decided to opt for the default update function where I check for the x position instead.
However, both approaches seem problematic. From what I’ve read, update
is called a maximum of 60 times per second, so in between frames, the node’s position registers later.
For the same reason I suppose, collision detection using didBegin
suffers from the same problem, and even when the physics body has its collisionBitMask
not set to zero - meaning even when the node bounces off it.
And checking for position in a custom function called by a timer with a time interval of say 0.00001 isn't accurate either.
As it stands there is no acceptable implementation - how can I precisely check for position?