3
有没有办法在同一精灵上运行其他动作时暂停SKSpriteNode中的某个动作?在SKSpriteNode中暂停一个动作,同时运行另一个
有没有办法在同一精灵上运行其他动作时暂停SKSpriteNode中的某个动作?在SKSpriteNode中暂停一个动作,同时运行另一个
您可以run action with key,像这样:
Objective-C的
[yourNode runAction:yourAction withKey:@"aKey"];
然后你就可以像这样访问特定的动作:
SKAction *action = [yourNode actionForKey:@"aKey"];
if(action){
action.speed = 0; //pause action
}
斯威夫特
与主要执行的操作:
yourNode.runAction(yourAction , withKey: "aKey")
要暂停行动:
if let action = ball.actionForKey("aKey"){
action.speed = 0
}
感谢您的回复,这解决了这一问题。 –