让我的应用在两个动作之间随机选择,然后每半秒钟重复一次动作,我会遇到很多麻烦。
这是我的代码:
//Setting the sprite to a position on the screen (it happens to be right where the screen cuts off)
SKSpriteNode *lightnut = [SKSpriteNode spriteNodeWithImageNamed:@"lightnut.png"];
lightnut.position = CGPointMake(257,510);
[self addChild: lightnut];
//The action that makes the sprite move to the new part of the screen
SKAction *moveNodeUp = [SKAction moveByX:0.0 y:-600.0 duration:2.0];
[lightnut runAction: moveNodeUp];
我希望我的应用程序选择将精灵设置为(257,510)或(150,510)。
例如:
SKSpriteNode *lightnut = [SKSpriteNode spriteNodeWithImageNamed:@"lightnut.png"];
lightnut.position = CGPointMake(257,510);
OR
lightnut.position2 = CGPointMake (150,510);
[self addChild: lightnut];
SKAction *moveNodeUp = [SKAction moveByX:0.0 y:-600.0 duration:2.0];
[lightnut runAction: moveNodeUp];
如果有人可以提供帮助,那就太好了!
另外,我不太了解这一点,但我仍在设法弄清楚。是否有一种方法可以刷新动作(以便我的应用程序可以在两点之间随机选择并让它们移动到新位置),甚至在动作尚未完成之前,也可以使其在另一个动作之前发送新的精灵甚至还没有离开屏幕?谢谢!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句