Thursday, February 12, 2009

Achievements

well, since we are talking about games, id like to teach you something i saw on a flash game out there.
It's an achievements window. Like, whenever the player do something cool, you show him a message. It's very easy, since we are gonna use a function for it. I will teach you one day how to make a function, in the mean time, copy and paste !

ok, so on frame 1's actions, type this:


function Achievement(achName, achDescript, achVariable) {
if (achVariable == false) {
achBox.gotoAndPlay(2);
achBox.boxName.text = achName;
achBox.boxDescript.text = achDescript;
achVariable = true;
}
}

this is the magical function that will let us make achievements easily.
but we still need a achievements box. Make a big rectangle, and 2 dynamic text boxes inside it. On one of them give it the INSTANCE name ( not var ) of boxName, and the other should be called boxDescript.

Now, select the rectangle, and the 2 boxes and press F8, and select movieclip. Press ok and double click it, so we can edit it. Drag the first frame to the second slot, so that the first frame becomes blank. Type

stop ();

on this emty keyframe. Now go to frame 20 and press F5. Now all we gotta do is create an achievement. you will see how simple it is.
First, create a variable, meaning that the achievement hasn't been completed yet.
So type this on first frame's actions:

butach = false;

Create a button, and give it these actions:

on (release) {
_root.Achievement("wow", "you did it", _root.butach);
}

now, you see the first quote ? that's the title. The second one is the description, and the third is the variable.
cool right ?
here is a simple example:





0 comments:

Post a Comment