在更新方法内部的SKShapeNode上运行SKAction

时间:2015-01-06 02:44:10

标签: ios sprite-kit skaction skshapenode

我希望我没有错过任何东西。我试图在我的更新方法中运行SKShapeNode上的SKAction,我做了一个标记检查我只会输入一次到"如果"法令,它正在使用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)

SKaction:

var movedown = SKAction.moveToY(324, duration: 5)
                step.runAction(movedown)

更新: 我甚至将其从if语句中删除,并将SKAction置于更新方法m的顶部并且仍然有效。并且我把它放在了thrMoveToView它正在工作,不知道为什么 完整更新方法:

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
        }

0 个答案:

没有答案