LibGDX - A good flag or command

Hi there,

Just for future purposes, I have a question. Say you had a method that you wanted to run when something occurred. Lets call it action(). Action() is called in the update method. Now, lets set this up in the Action method as simply returning a print statement “Ready? Action!”;

How could you make it so that, perhaps by using parameters, it runs the amount of times specified in the (), for example: Action(3); would return the string 3 times, rather than just continuously like the update method would output normally.

Example:

//Stuff
//Perhaps a loop that calculates something… idk…
action(3);
} // Close Update method

Output:
Ready? Action
Ready? Action
Ready? Action

(Rather than)
{
action(3);
}

Ready? Action! (every millisecond repeatedly outputted.)

Hopefully this makes sense…

I may miss something, bus isn’t a for-next look what you are looking for?

void moreAction(int count) {
	for (int i = 0; i < count; i++) {
		action();
	}
}

Then call moreAction(3) from your update method.

Do you mean only running it 3 times, as opposed to running it three times per frame? If you want this behavior why would you put it in a loop in the first place?

Its just for testing purposes. Like, if you press a key in the update method it would run its return more than once, but once per frame generally…

I can’t believe I didn’t think of using a for loop. Thanks!

:wink: