所以我想知道一些事情。我有3個功能:做一些「x」秒的時間,然後做點別的事
func makeHeroRun(){
let heroRunAction = SKAction.animateWithTextures([ heroRun2, heroRun3, heroRun4, heroRun3], timePerFrame: 0.2)
let repeatedWalkAction = SKAction.repeatActionForever(heroRunAction)
hero.runAction(repeatedWalkAction)
}
func makeHeroJump(){
let heroJumpAction = SKAction.animateWithTextures([heroJump1, heroJump2, heroJump2], timePerFrame: 0.2)
hero.runAction(heroJumpAction)
}
func makeHeroSlide(){
let heroSlideAction = SKAction.animateWithTextures([heroSlide1, heroSlide2], timePerFrame: 0.1)
hero.runAction(heroSlideAction)
}
,也是我的touchesBegan:
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
var touch = touches.first as! UITouch
var point = touch.locationInView(self.view)
if point.x < size.width/2 // Detect Left Side Screen Press
{
makeHeroSlide()
}
else
if point.x > size.width/2 // Detect Right Side Screen Press
{
makeHeroJump()
}
}
「英雄」 是在遊戲運行播放器。
我想要的是,當「makeHeroSlide」完成運行時,我想重複「makeHeroRun」,所以在英雄一直滑動之後,它應該繼續運行。當英雄跳躍時,它應該停止跑步,當英雄擊中地面時,它應該繼續跑步。我怎樣才能做到這一點?我想要在AppStore中的「Line Runner」遊戲中出現與玩家跳轉和滾動相同的功能。
什麼是'heroRunAction'? – s1ddok