simulate a game

Topics: Actions and Control Logic, Android, Animation
Jun 18, 2014 at 2:13 PM
Edited Jun 18, 2014 at 2:18 PM
Hi all,

I am having trouble simulating a game I have developed. I have created a simple game and would like to simulate the game.

I have a method called simulate game which uses the ontouchEnd method to simulate a game

public void simulateGame()
{
for(int x =0; x<10 ; x++ )
{
onTouchEnd(new CCTouch(0,0));
Thread.sleep(1000);
}


For some reason, the game does not show the iteration (for each untouchedend call, it should create a new sprite). What happens is that, after the simulateGame end it while show the 10 sprites rather than the loop iteration.
}


is there a way for force the draw of the sprite in the simulate game. The sprite to be drawn is on CCLayerColor class.
Coordinator
Jun 18, 2014 at 8:00 PM
Hello

Game engines are time based. Each time iteration gets to do some work. Touches are processed at each time iteration. If you run a method that publishes a bunch of touches, then you will only see the end result of the touches.

To properly simulate a sequence of user touches you need to schedule the update() call in your scene. Then in that update, publish some touches.

You could just as easily schedule a handler with the CCDirector and have that handler publish touches. That would be a smarter design pattern since it would exist outside of any scene.