var speed: CGFloat = 5
override func didMoveToView(view: SKView) {
/* Setup your scene here */
var move = SKAction.moveTo(CGPoint(x: node.position.x, y: -(self.frame.height)), duration: NSTimeInterval(speed))
var reset = SKAction.moveTo(CGPoint(x: node.position.x, y: self.frame.height ), duration: 0)
var scroll = SKAction.sequence([move, reset])
node.runAction(SKAction.repeatActionForever(scroll))
}
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
/* Called when a touch begins */
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
speed++
println(speed)
}
我有一个想要滚动的节点,我希望它的速度根据玩家的触摸而变化,我的问题是当玩家触摸时值确实增加但节点本身保持相同的初始值。我也试过更改更新方法,但也没有。 怎么解决这个问题?