SKSpriteNode: Handling collisions during SKAction
I am making a small game and now I am having the following problem.
I am triggering an action (type followPath) for a specific node:
let followTrack: SKAction = SKAction.followPath(ballPath!.CGPath, duration: ACTION_SPEED)
movingBall.runAction(followTrack)
But during animation, if a node collides with another (like a wall for example), the animation stops and there is no collision animation.
I've tried some things like:
func didBeginContact(contact: SKPhysicsContact) {
var firstBody: SKPhysicsBody = contact.bodyA
var secondBody: SKPhysicsBody = contact.bodyB
firstBody.node?.removeAllActions()
secondBody.node?.removeAllActions()
}
But also there is no collision (I am assuming since the speed is (0,0))
Is there anyway to handle this case? (I don't particularly need a quick answer, objective-C or a generic answer would be great too!)
+3
source to share
No one has answered this question yet
See similar questions:
or similar: