【发布时间】:2015-08-07 13:13:32
【问题描述】:
我正在尝试在 SpriteKit(Xcode 7 测试版)中制作像 Doodle Jump 这样的垂直无尽跑步者,但不知道如何不断向上移动 Node。
override func didMoveToView(view: SKView) {
makeBackground()
// Bubble
let bubbleTexture = SKTexture(imageNamed: "bubble.png")
bubble = SKSpriteNode(texture: bubbleTexture)
bubble.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame))
bubble.physicsBody = SKPhysicsBody(circleOfRadius: bubbleTexture.size().height/2)
bubble.physicsBody!.dynamic = false
bubble.physicsBody!.allowsRotation = false
let float = SKAction.moveToY(+yScale, duration: 0.2)
bubble.SKAction.repeatActionForever(runAction(float))
self.addChild(bubble)
}
【问题讨论】:
-
你能展示你的尝试吗?
-
子类
SKSpriteNode并在覆盖的update方法中修改精灵位置。
标签: ios swift sprite-kit swift2