Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 暂停或结束并采取行动_Ios_Iphone_Objective C_Sprite Kit - Fatal编程技术网

Ios 暂停或结束并采取行动

Ios 暂停或结束并采取行动,ios,iphone,objective-c,sprite-kit,Ios,Iphone,Objective C,Sprite Kit,我有一个SKSpriteNode正在运行一个actionForever。这个SKSpriteNode在发生碰撞时更改对象。问题是,因为另一个动作永远在运行,所以它将更改回该动作。有没有办法阻止一个动作 SKTexture* groundOverlay = [SKTexture textureWithImageNamed:@"layer-5"]; groundOverlay.filteringMode = SKTextureFilteringNearest; SKActi

我有一个SKSpriteNode正在运行一个actionForever。这个SKSpriteNode在发生碰撞时更改对象。问题是,因为另一个动作永远在运行,所以它将更改回该动作。有没有办法阻止一个动作

   SKTexture* groundOverlay = [SKTexture textureWithImageNamed:@"layer-5"];
    groundOverlay.filteringMode = SKTextureFilteringNearest;


    SKAction* moveOverlaySprite = [SKAction moveByX:-groundOverlay.size.width*2 y:0 duration:0.01 * groundOverlay.size.width*2];
    SKAction* resetOverlaySprite = [SKAction moveByX:groundOverlay.size.width*2 y:0 duration:0];
    moveOverlaySpritesForever = [SKAction repeatActionForever:[SKAction sequence:@[moveOverlaySprite, resetOverlaySprite]]];

    for( int i = 0; i < 2 + self.frame.size.width; ++i ) {
        // Create the sprite
        sprite1 = [SKSpriteNode spriteNodeWithTexture:groundOverlay];
        [sprite1 setScale:1.0];
        sprite1.position = CGPointMake(i * sprite1.size.width, sprite1.size.height / 2);
        [sprite1 runAction:moveOverlaySpritesForever withKey:@"bg2"];
        [self addChild:sprite1];
    }
SKTexture*groundOverlay=[SKTexture TextureWithimageName:@“layer-5”];
groundOverlay.filteringMode=SKTextureFilteringNearest;
SKAction*moveOverlaySprite=[SKAction-moveByX:-groundOverlay.size.width*2y:0持续时间:0.01*groundOverlay.size.width*2];
SKAction*resetOverlaySprite=[SKAction moveByX:groundOverlay.size.width*2y:0持续时间:0];
moveOverlaySpritesForever=[SKAction repeatActionForever:[SKAction sequence:@[moveOverlaySprite,resetOverlaySprite]];
对于(int i=0;i<2+self.frame.size.width;+i){
//创建精灵
sprite1=[SKSpriteNode SPRITENODEWITH纹理:地面覆盖];
[sprite1设置刻度:1.0];
sprite1.position=CGPointMake(i*sprite1.size.width,sprite1.size.height/2);
[sprite1运行操作:使用键@“bg2”移动覆盖PritesForever];
[self-addChild:sprite1];
}

请发布一些与SKAction对象相关的代码。我添加了一个代码,它是InitWithSize方法中的移动背景。我想取消这个动作。我该怎么做?您是否尝试过使用
[sprite removeActionWithKey:@“bg2”]?是否确实在添加操作的同一个精灵实例上调用
removeActionWithKey
?您是否可以编辑您的问题以显示您尝试删除操作的代码?
sprite1
是方法中的局部变量还是对象的实例变量?