Isometric Game: Going to the Next Frame

March 10th, 2010 by Brian Leave a reply »

We’ve got the countdown showing on the hero for our game. If you weren’t at Future Professionals when we did that, here’s the link.

Let’s check when the variable scarytimer gets to zero. When it does, we’ll have the Flash movie go to frame two.

Find the line of code in the onEnterFrame function where you decrease scarytimer.
scarytimer--;

Underneath it, check to see if it’s less than 0.
scarytimer--;
if(scarytimer<0){ gotoAndStop(2); scarytimer=0; }

The gotoAndStop means that we don't have to put a stop(); code in frame 2. It reduces the amount of typing you have to do.

Notice that I added a line to set scarytimer to 0. Instead of going into the negatives, it's now an ominous emptiness.

Now draw/type a message on the stage in frame 2 that lets the player know that time has run out.

That's if they lose. But what if they win?

Find the line that says
if(canvas.map[hero.y][hero.x] == 101){
trace("Exit");
}

Change:
trace("Exit");

to
gotoAndStop(3);
scarytimer=1000;

On frame 3 create a message that lets them know they win. Make sure that frame 3 has a new keyframe so frame 2's message doesn't show up.

Advertisement

Leave a Reply