iphone - nsarray switching image texture randomly everyone one second -


i have array has 2 balloon textures,one green , 1 red.i have 12 green balloon object @ start of app.basically want 1 random green balloon turn red every 1 second.if can appreciated.

init method

    balloontextures = [nsmutablearray array];     [balloontextures addobject:[sptexture texturewithcontentsoffile:@"greenballoon.png"]];     [balloontextures addobject:[sptexture texturewithcontentsoffile:@"redballoon.png"]];     [balloontextures retain];     playfieldsprite = [spsprite sprite];     [self addchild:playfieldsprite];     [self addballoon]; 

add ballon method

  -(void)addballoon   {       for(int = 0; < 12; i++)       {          spimage *image = [spimage imagewithtexture:[balloontextures objectatindex:0]];          image.x = 40*i;          image.y = 10 ;          [playfieldsprite addchild:image];       }   } 

for getting random number:

#include <stdlib.h>  int r = arc4random() % 12; 

use nstimer called every second: how use nstimer?


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -