尽管将SKAction显式设置为repeatActionForever,但下面的代码并没有重复。
SKAction *action = [SKAction moveToY:self.frame.size.height + bullet.size.height duration:2];
SKAction *remove = [SKAction removeFromParent];
SKAction *fireForever = [SKAction repeatActionForever:[SKAction sequence:@[action,remove]]];
[bullet runAction:fireForever];子弹只发射一次,预计每1秒发射一次。
发布于 2015-02-01 00:33:19
您正在从父对象中移除子弹,这就是它不再发射的原因,您应该做的是创建一个方法来创建一个子弹-发射它-销毁它,并创建一个使用此方法的SKAction。
-(void)FireBullet
{
//create bullet
//fire it
//remove from parent
}并在希望子弹开始发射时添加以下代码。
SKAction *myAction = [SKAction performSelector:@selector(FireBullet) onTarget:self];
SKAction *forever = [SKAction repeatActionForever:myAction];
[self runAction:forever];希望这对你有帮助,如果你需要更多帮助,请告诉我。
https://stackoverflow.com/questions/28253484
复制相似问题