xcode - Getting makeObjectsPerformSelector to Work in Objective C -
i trying use makeobjectsperformselector instead of using loop , can't quite work. have 20 balls i'm trying add screen inside "init".
i can add single 1 making sprite this:
ccsprite *ball = [ccsprite spritewithfile:@"ball.png" rect:cgrectmake(0, 0, 20, 20)]; // set position of ball providing coordinates ball.position = ccp((player.contentsize.width/2 + 400)+ball.contentsize.width/2, winsize.height/2 - ball.contentsize.height/2); // add ball playing area [self addchild:ball]; this seems work great need add 20 of them. i've decided use array called "balls" , i've read can use makeobjectsperformselector perform action on each each object in array, can't figure out how add each ball, far have this:
- (void) makeobjectsperformselector:(sel)aselector { // add ball screen [self addchild:aselector]; } i think need use aselector object on balls array , add right? using incorrectly?
thank you!
based on example, it's rather hard tell you're trying do. if have nsarray called balls, , operation want perform on each ball called bounce, can use -makeobjectsperformselector::
[balls makeobjectsperformselector:@selector(bounce)]; was helpful @ all?
Comments
Post a Comment