-1
我正在爲我的大學工作,我陷入了一件事。快速拍攝移動位置
當我試圖用我的英雄射擊子彈只能去的向上或側面,我需要我的子彈去的地方永遠是我的英雄輪播PLZ幫助我,這是我的代碼
func spownBullet() {
let bullet = SKSpriteNode(imageNamed: "Bullet")
let hero = self.childNodeWithName("hero") as! SKSpriteNode
bullet.zPosition = 1
bullet.position = CGPointMake(hero.position.x, hero.position.y)
bullet.size = CGSize(width: 20, height: 30)
let bulletact = SKAction.moveToY(self.size.height + 300, duration: 1)
bullet.runAction(SKAction.repeatActionForever(bulletact))
self.addChild(bullet)
}
的功能可以是全球性的。使用它的兩行應該簡單地替換您在示例代碼中創建的那一行(創建Bulletact的地方)。 –
ty但我有我應該在哪裏但第二個代碼(讓bulletDestination = endPointMovingSpriteFrom(hero.position,atAngle:hero.rotation,forDistance:300) let bulletact = SKAction.moveTo(bulletDestination,duration:1))在touchesMoved中。 。? –
當我更換它時,s給我一個錯誤 –