我希望我没有遗漏任何东西。我正在尝试在我的更新方法中在我的 SKShapeNode 上运行 SKAction,我做了一个标志检查,我只会在“if”语句中输入一次,它正在使用 DidMoveToView 方法,但是没有用在更新或 DidSymulatedPhyisics 方法中,有什么想法吗?我的节点://在工作正常之前创建的路径
var step = SKShapeNode(path: pathtodraw2)
step.fillColor = SKColor.whiteColor()
step.position = CGPoint(x: 0, y: self.frame.midY)
step.physicsBody = SKPhysicsBody(edgeChainFromPath: pathtodraw2)
step.physicsBody?.affectedByGravity = false
step.physicsBody?.dynamic = true
self.addChild(step)
SK动作:
var movedown = SKAction.moveToY(324, duration: 5)
step.runAction(movedown)
更新: 我什至将它从 if 语句中删除,并将 SKAction 放在更新方法 m 的顶部,并且仍然有效。我把它放在 thr didMoveToView 它正在工作,不知道为什么 完整的更新方法:
if abs(circle.physicsBody!.velocity.dx) < 5 && abs(circle.physicsBody!.velocity.dy) < 5 && ismoved == true //check if the object stopped moving (not the one im trying to move down)
{
ismoved = false
circle.physicsBody?.velocity = CGVectorMake(0, 0)
self.userInteractionEnabled = true
if circle.position.y > 100 && falloff == false { //checking if the second object above the first object **working fine used breakpoint* and it enter inside the statment
println("asd" )
var movedown = SKAction.moveToY(324, duration: 5) //trying to move it down
step.runAction(movedown) //trying to move it down
falloff = true
}
}
if abs(circle.physicsBody!.velocity.dx) > 1.4 && ismoved == false{ //check if the object start moving (not the only im trying to move down)
ismoved = true
}