我是新來的斯威夫特和SKSPRITE迅速SKSprite從一個GameScene移動到另一個
我說對我的第一類GameScene一個按鈕:SKScene。當按鈕被鎖住時,我想移動到我的新GameScene。我怎樣才能做到這一點?
我有方法重寫FUNC touchesBegin(觸摸:NSSet中,withEvent事件:的UIEvent){ ... }
我是新來的斯威夫特和SKSPRITE迅速SKSprite從一個GameScene移動到另一個
我說對我的第一類GameScene一個按鈕:SKScene。當按鈕被鎖住時,我想移動到我的新GameScene。我怎樣才能做到這一點?
我有方法重寫FUNC touchesBegin(觸摸:NSSet中,withEvent事件:的UIEvent){ ... }
http://www.raywenderlich.com/42699/spritekit-tutorial-for-beginners
我的回答是從這個雷Wenderlich教程剝離:
SKTransition *reveal = [SKTransition flipHorizontalWithDuration:0.5];
SKScene * myScene = [[YourSceneName alloc] initWithSize:self.size];
[self.view presentScene:myScene transition: reveal];
這不是快捷,但仍應該與您的代碼一起工作。
YourSceneName應該是您想要轉換到的場景的名稱。記得在你想從中調用它的類中導入標題。
要創建按鈕,只需創建一個SKSpriteNode,然後在touchesBegan或Ended中檢查觸摸位置是否在spriteNode中。如果是,請執行上面的代碼。
meisenman對雨燕2.0
let reveal = SKTransition.flipHorizontalWithDuration(0.5)
let gameOverScene = GameOverScene(size: self.size)
self.view?.presentScene(gameOverScene, transition: reveal)
代碼:
override func touchesBegin(touches:NSSet, withEvent event: UIEvent) {
let reveal = SKTransition.flipHorizontalWithDuration(1.0)
// the number is the duration time. After you type . right behind SKTransition, you can choose other scene transition effect.
self.view?presentScene(NewGameScene,transition:reveal)
}