我正在使用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);
提前致谢!
答案 0 :(得分: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);}]]]];