我有一个通过函数生成的精灵节点:
let NBrick1 = SKSpriteNode(texture: Brick1)
NBrick1.setScale(0.04)
NBrick1.position = CGPointMake(0.0, CGFloat(y1 + bounds/2))
NBrick1.physicsBody = SKPhysicsBody(rectangleOfSize: NBrick1.size)
NBrick1.physicsBody?.dynamic = true
BrickPairs.addChild(NBrick1)
我正在使用这个SKAction移动砖块:
let moveBricks = SKAction.moveByX(-distanceToMove, y: 0.0, duration: NSTimeInterval(0.01 * distanceToMove))
let removeBricks = SKAction.removeFromParent()
BricksMoveAndRemove = SKAction.sequence([moveBricks,removeBricks])
我想知道是否有办法让砖块随着时间的推移而变得更快。
答案 0 :(得分:0)
实际上很简单,你不需要参与SKActions
。下面的代码将加速精灵或多个精灵的移动(如果你应用相同的代码。)它正在做的是每次每帧更改精灵的位置多一点。这是moveFactor
变量。要更改加速的起始速度和速率,请更改我输入的值。
var moveFactor:CGFloat = 0.5
override func update(currentTime: CFTimeInterval) {
/* Called before each frame is rendered */
sprite.position = CGPoint(x: sprite.position.x + moveFactor, y: sprite.position.y)
moveFactor *= 1.005
}