0

How do I set a size for a SKTexture Ive gone through the documentation Class Reference I don't see anything about being able to set the size. I know the size method is a return method but just to make it clear what I'm trying to do its in my code below.

    _bomb = [SKSpriteNode spriteNodeWithImageNamed:@"Bomb5.gif"];

    SKTexture *Bomb5 = [SKTexture textureWithImageNamed:@"Bomb5.gif"];
    Bomb5.size = CGSizeMake(40, 40);

    SKTexture *Bomb4 = [SKTexture textureWithImageNamed:@"Bomb4.gif"];
    Bomb4.size = CGSizeMake(40, 40);

    SKTexture *Bomb3 = [SKTexture textureWithImageNamed:@"Bomb3.gif"];
    Bomb3.size = CGSizeMake(40, 40);

    SKTexture *Bomb2 = [SKTexture textureWithImageNamed:@"Bomb2.gif"];
    Bomb2.size = CGSizeMake(40, 40);

    SKTexture *Bomb1 = [SKTexture textureWithImageNamed:@"Bomb1.gif"];
    Bomb1.size = CGSizeMake(40, 40);

    SKTexture *explostion = [SKTexture textureWithImageNamed:@"explosionnn.gif"];
    explostion.size = CGSizeMake(90, 90);
    //5 second countdown and the bomb explodes
    countdown = [SKAction animateWithTextures:@[Bomb5,Bomb4, Bomb3, Bomb2, Bomb1, explostion] timePerFrame:1];

Another solution?: Maybe I could add actions in sequence where after the 5 second countdown I can change the size of the spriteNode instead when it reaches the last animation image. But if I were to do it this way how do I change the size of the image from the centre origin of where the bomb is?

4

1 回答 1

0

你是对的:你不能改变纹理的大小,因为纹理本质上图像:“SKTexture 对象是可以应用于 SKSpriteNode 对象或由 SKEmitterNode 对象创建的粒子的图像。” (来自文档)。

您是否考虑过为爆炸制作单独的精灵?然后,当倒计时达到零时,您可以简单地用它替换倒计时精灵。如果您使用工厂类来创建精灵,如果您想在游戏的其他地方使用相同的爆炸,这也将为您节省很多麻烦......

于 2014-02-17T06:47:59.060 回答