我如何为一个SKTexture设置一个大小,我已经浏览了文档类引用,我没有看到任何关于能够设置这个大小的东西。我知道size方法是一种返回方法,但只是为了说明我在下面的代码中试图做什么。
_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];另一个解决方案?:也许我可以按顺序添加动作,在倒计时5秒后,当spriteNode到达最后一个动画图像时,我可以改变它的大小。但是,如果我这样做,我如何改变图像的大小,从中心来源的炸弹在哪里?
发布于 2014-02-17 06:47:59
您是对的:您不能更改纹理的大小,因为纹理本质上就是图像:“SKTexture对象是可以应用于SKSpriteNode对象或由SKEmitterNode对象创建的粒子的图像。”(来自文档)。
你考虑过为这次爆炸单独吃一杯雪碧吗?然后,当倒计时达到零时,你可以简单地用这个替换倒计时-精灵。如果你把一个工厂类来创建你的精灵,如果你想在游戏的其他地方使用同样的爆炸,这也会给你省下很多麻烦.
https://stackoverflow.com/questions/21787969
复制相似问题