0

我正在使用 Sprite Kit 制作游戏,我想知道是否可以制作一个 SKAction 来改变他的重力一段时间,是吗?这是我已经拥有的代码:

        SKSpriteNode *sprite = [SKSpriteNode spriteNodeWithImageNamed:@"bal.png"];
        sprite.position = CGPointMake(self.frame.size.width/4 + arc4random() % ((int)self.frame.size.width/2), (self.frame.size.height/2 + arc4random() % ((int)self.frame.size.height/2)));
        sprite.color = [self randomColor];
        sprite.colorBlendFactor = 1.0;
        sprite.xScale = 0.2;
        sprite.yScale = 0.2;
        [self addChild:sprite];
        sprite.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:sprite.size.width/2];
        self.physicsWorld.gravity = CGVectorMake(0.0f, -4.0f);

提前致谢!

4

1 回答 1

0

您运行自定义操作块并将其打开和关闭,让我知道这是否适合您。

[self runAction:[SKAction sequence:@[[SKAction runBlock:^{ self.physicsWorld.gravity = CGVectorMake(0.0f, -4.0f);}],[SKAction waitForDuration:4],[SKAction runBlock:^{ self.physicsWorld.gravity = CGVectorMake(0.0f, 0.0f);}]]]];
于 2013-10-22T22:12:10.720 回答