我真的不知道从哪里开始。我有一个存储在 anSKSpriteNode
和 aphysicsBody
中的圆圈的图像,它在创建时反映了它的大小。
不过,我正在使用SKAction
缩小图像的大小,而物理体的大小保持不变。我怎样才能缩小physicsBody?
我的代码:
SKSpriteNode *sprite = [SKSpriteNode spriteNodeWithImageNamed:@"whiteball"];
sprite.size = CGSizeMake(20, 20);
sprite.position = CGPointMake(dx, CGRectGetHeight(self.frame)-dy);
sprite.name = @"ball";
sprite.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:sprite.size.width/2];
[self addChild:sprite];
SKNode *ballNode = [self childNodeWithName:@"ball"];
if (ballNode != Nil){
ballNode.name = nil;
SKAction *delay = [SKAction waitForDuration:3];
SKAction *scale = [SKAction scaleTo:0 duration:1]; // I want this to scale the physicsBody as well as the spriteNode...
SKAction *remove = [SKAction removeFromParent];
//put actions in sequence
SKAction *moveSequence = [SKAction sequence:@[delay, scale, remove]];
//run action from node (child of SKLabelNode)
[ballNode runAction:moveSequence];
}