Create Game Turn

Newbie question I guess since I’m a noob.

Would really appreciate if somebody could point me in the right direction.

I’m making a game with a ball and some objects that you shoot and they disappear.

When the collision occurs I check if all the objects are gone, then “Win”.

To Win you are supposed to do this in 20 shoots, so I’m counting the shoots.

Now I got a problem checking the loose condition.

Cannot do this in the shoot function, because the shoot may hit the last object after the shoot, then it should be a Win. The shoot functions is more or less ripped from the pool table tutorial.

So my question is - how do I determine/listen to when the shoot is over?

This would create a “Game Turn” and after this I could have my Win/Loose check.

So, when the ball stops moving or something similar.

I also need to know if it is possible to make the game unresponsive for touch from when the shoots began and ended. Guess I could remove the listner and later add it again, is this the right way?

Regards

bergapappa - The Hopeful Newbie

  1. Add an enterFrame listener, which is a function that runs every frame. Within this listener check the number of shots taken, and if it is 20, check the velocity of the ball. If it is zero you have your lose condition.

  2. Set up a variable like ‘canTouch’, set it to false when the shot begins, and true when it ends. Check whether canTouch is true before running the code within the listener.

TNX a lot, this was an easy approach. Even I could understand it  :stuck_out_tongue:

Will try this.

I thougt maybe enterFrame listners gave a heavy load and should be avoided if possible.

So they are ok to use?

Regards

bergapappa

Yeah, especially a simple check like this will be fine.

If I need to do heavier calculations that start to effect the framerate, I’ll set up a timer and only run the code say once a second.

THX, you have helped me a lot!

Regards

bergapappa

  1. Add an enterFrame listener, which is a function that runs every frame. Within this listener check the number of shots taken, and if it is 20, check the velocity of the ball. If it is zero you have your lose condition.

  2. Set up a variable like ‘canTouch’, set it to false when the shot begins, and true when it ends. Check whether canTouch is true before running the code within the listener.

TNX a lot, this was an easy approach. Even I could understand it  :stuck_out_tongue:

Will try this.

I thougt maybe enterFrame listners gave a heavy load and should be avoided if possible.

So they are ok to use?

Regards

bergapappa

Yeah, especially a simple check like this will be fine.

If I need to do heavier calculations that start to effect the framerate, I’ll set up a timer and only run the code say once a second.

THX, you have helped me a lot!

Regards

bergapappa