-3
我需要一种将图像纹理从nsmutable数组中的一个索引切换到另一个索引的方法。如何将nsarray对象从一个索引切换到另一个索引
balloonTextures = [NSMutableArray array];
// Add each of the balloon textures into the balloon textures array
[balloonTextures addObject:[SPTexture textureWithContentsOfFile:@"greentutorial.png"]];
[balloonTextures addObject:[SPTexture textureWithContentsOfFile:@"redtutorial.png"]];
SPImage *image = [SPImage imageWithTexture:[balloonTextures objectAtIndex:0]];
image.x = 0;
image.y = 10 ;
[playFieldSprite addChild:image];
[image addEventListener:@selector(onTouchBalloon:) atObject:self forType:SP_EVENT_TYPE_TOUCH];
正如你可以看到我有一个NSMutableArray与图像,其中包含图像纹理greentutorial。现在我想用红色纹理(红色教程)将其切换为20秒内调用的方法。
-(void)changeColor{
image = [SPImage imageWithTexture:[balloonTextures objectAtIndex:1]];
}
但是,它根本不工作。我知道这个图像正在被调用,因为如果我在方法中添加下面的代码并且它可以工作。
image.x = 300;
如何将添加图像到这个方法。 – 2013-05-11 12:22:13
我在答案中添加了更多信息.. – 2013-05-11 12:28:25