Iphone SDK: Image arrays? -


i'm making "tapping-app" have kill zombies tapping on them. can't make progress because can't use methods need properly.

my app works that:

i have timer spawns image 3 times per second:

[nstimer scheduledtimerwithtimeinterval:1.0/3                                   target:self                                 selector:@selector(spawn)                                 userinfo:nil                                  repeats:yes]; 

then have spawn command:

- (void) spawn {     cgrect myimagerect = cgrectmake(0.0f, 0.0f, 320.0f, 109.0f);     uiimageview *myimage = [[uiimageview alloc] initwithframe:myimagerect];     [myimage setimage:[uiimage imagenamed:@"myimage.png"]];     myimage.opaque = yes;     [self.view addsubview:myimage];     [myimage release] } 

i have "touchesbegan" command:

- (void)touchesbegan:(nsset *)touches withevent:(uievent *)event {     uitouch *touch = [[event alltouches] anyobject];     cgpoint touchlocation = [touch locationinview:self.view];    } 

what want do, put spawning images array; if 1 of images touched want removed superview.i want know how array works , how can remove objects added array different function "touchesbegan".

please me problem!

edit:

nevermind... searched around internet , found useful resources witch needed. figured out how works , got spawner function work collision , "touchesbegan".

if wants code, ask me.

dd

use [nsmutablearray addobject:] , [nsmutablearray removeobject:]

in interface, like:

@interface myclass {     nsmutablearray *zombies_; } 

in implementation, after initializing array, change spawn method include line

[self.zombies addobject:myimage]; 

and in touch handler, after determine view touched, like

[zombies_ removeobject:theview]; [theview removefromsuperview]; 

although, after thinking it, may better off creating uibutton instances instead of uiimageviews , writing touch handlers determine view touched.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -