ios - How to cancel one specific SKAction.movebyX in SpriteKit? -


i have skaction want cancel in touchesended. of right now, have code: self.player.removeallactions() , code works. problem i'm experiencing code cancelling actions including animation of player. did research , found code: player.removeactionforkey(), action code not include key. please see code below help. thank you.

import spritekit  var player = skspritenode()  //i skipped code in view did load.  // in touches began:  let rightmoveaction = skaction.movebyx(50, y: 0, duration: 0.1) player.runaction(skaction.repeatactionforever(rightmoveaction))  let leftmoveaction = skaction.movebyx(-50, y: 0, duration: 0.1) player.runaction(skaction.repeatactionforever(leftmoveaction))  // in touches ended  self.player.removeallactions()  // mentioned earlier, works need cancel 1 action not have animated player. 

you can assign action key, , cancel referring key:

add key action:

player.runaction(skaction.repeatactionforever(rightmoveaction), withkey: "rightmove") 

and remove doing this:

player.removeactionforkey("rightmove") 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -