jeudi 13 novembre 2014

SKSpriteNode : Handling Collision during SKAction


Vote count:

0




I'm making a little game, and I'm now stuck with the following problem.


I'm running an action (followPath type) on a particular node :



let followTrack: SKAction = SKAction.followPath(ballPath!.CGPath, duration: ACTION_SPEED)
movingBall.runAction(followTrack)


But during the animation, if the node collide with another one (like a wall for exemple), the animation stops and there is no collision animation.


I 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 there is no collision either (I guess that's because velocity is (0,0))


Is there anyway to handle this case ? (I don't especially need a swift answer, an objective-C or generic answer would be great too !)



asked 3 mins ago

KIDdAe

1,036






SKSpriteNode : Handling Collision during SKAction

Aucun commentaire:

Enregistrer un commentaire