Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

PizzaTray

macrumors newbie
Original poster
Oct 31, 2009
25
0
I'm working on a game to the iphone with opengl es, and every time i have some other problem caused by the situation- that i can't run just one-time code in the game loop.

what should i do :( ?

EDIT:

I'll try to explain my problem here more deeply -

Example:
//
-init...
-game loop {

delta,
update,
render,

/* in the game loop ,as example, i want to run some method just one time, when, let's say, has a collision of explosion, Run the explosion-animation just once. */

}
 
Use an "if" statement to check for your condition, then inside the "if" so something that will prevent the "if" from being triggered the next time around. Something like this (pseudocode):

Code:
if ((ship touching laser) && !ship.dead{
     //trigger animation here
     [myAnimation trigger];

     //prevent this if from being triggered next time
     ship.dead=true; 
}

Alternately, you could remove the laser inside the if, so that the laser doesn't exist to trigger the collision next time.

Makes sense?
 
Use an "if" statement to check for your condition, then inside the "if" so something that will prevent the "if" from being triggered the next time around. Something like this (pseudocode):

Code:
if ((ship touching laser) && !ship.dead{
     //trigger animation here
     [myAnimation trigger];

     //prevent this if from being triggered next time
     ship.dead=true; 
}

Alternately, you could remove the laser inside the if, so that the laser doesn't exist to trigger the collision next time.

Makes sense?

Thank u, it works great :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.