PDA

View Full Version : Jump from frame 2 to frame 1 in my pingpong game


henrik25
03-14-2003, 11:20 AM
Hi.
My first (of many i guess) mail here :-)
I have made a small pingpong game. It have 2 frames. The intro game on frame 1, and the game itself on frame 2.
When the player or the computer scores 3 points, i want the game to go back to the intro screen at frame 1.

Here is the code i wanna use for that
onClipEvent ( enterFrame ){
if (_root.player1Score > 1)
{
gotoAndPlay(1);
stop();
}

But the games just keeps playing. It dosent go back to frame 1. I have tryed setting in a trace("test") to see if i captured the event. And i do.
In frame i have all my parameter inits, and a stop() command. Anyone know what im doing wrong ?

Say if you wanna see my code...

tost
03-14-2003, 11:28 AM
hi, henrik, welcome aBoard :)

you don't want it t go to and PLAY, you want it to:

onClipEvent ( enterFrame ){
if (_root.player1Score > 1)
{
gotoAndStop(1);
}

keep in mind that this is rather unfriendly towards the users' cpu, as this code is repeated every frame over and over again. it would be better to check for the score just once, right after you add a new point, e.g.


if (block._x > player1Bar._x) {
// this is the same as _root.player1Score = _root.player1Score + 1;
_root.player1Score++;
// now check the score
if (_root.player1Score > 1)
{
gotoAndStop(1);
}
}


greetz
tost

henrik25
03-14-2003, 11:37 AM
That was fast. Thanks :-)

But sadly i didnt work. It might be easyer if i uploaded my source. So here it is.
Hope you, or someone else, have tame to take a look at it.

I also have a problem with the ball sometimes getting cought in the top or bottom wall when it is hitting very flat. But im gonna look more into that later.

Thanks again

henrik25
03-15-2003, 11:53 AM
Can noone help please ?
I dont understand what is happening, and my game is allmost done, except for this little bug :(