removeAllActions sprite kit移动背景

时间:2014-05-03 23:07:49

标签: ios iphone objective-c sprite-kit

我创建了这个SKSpriteNode,它是后台的移动背景。我想要的是能够阻止我所做的所有行动

[self removeAllAction]

哪个有效,但不是为了移动背景为什么?我怎样才能获得这个

    SKTexture* groundTexture = [SKTexture textureWithImageNamed:@"layer-1"];
    groundTexture.filteringMode = SKTextureFilteringNearest;


    SKAction* moveGroundSprite = [SKAction moveByX:-groundTexture.size.width*2 y:0 duration:0.02 * groundTexture.size.width*2];
    SKAction* resetGroundSprite = [SKAction moveByX:groundTexture.size.width*2 y:0 duration:0];
    moveGroundSpritesForever = [SKAction repeatActionForever:[SKAction sequence:@[moveGroundSprite, resetGroundSprite]]];

    for( int i = 0; i < 2 + self.frame.size.width; ++i ) {
        // Create the sprite
        sprite = [SKSpriteNode spriteNodeWithTexture:groundTexture];
        [sprite setScale:1.0];
        sprite.position = CGPointMake(i * sprite.size.width, sprite.size.height / 2);
        [sprite runAction:moveGroundSpritesForever withKey:@"bg"];
        [self addChild:sprite];
    }

0 个答案:

没有答案