SKSpriteNode : Handling Collision during SKAction

本小妞迷上赌 提交于 2019-12-07 17:00:42

问题


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 !)

来源:https://stackoverflow.com/questions/26909774/skspritenode-handling-collision-during-skaction

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!