Testing your character movement (Part 2)

September 13, 2011
___________________________________________________________________

Let's take a look at Figure 8.1. The action script from "command" layer at frame 15 is as the following;

if (/:breath == "off") {                  // This means that if the value of breath = off
    gotoAndPlay("over");                // Then go to and play at frame label "over"
} else if (/:breath == "on") {         // On the other hand, if the value breath = on
    gotoAndPlay("gameon");           // Go to and play at frame label "gameon"
}


Figure 8.1

That is how we loop the game. The game will be playing from frame 5, 6, 7,... to frame 15 and then back to frame 5, 6, 7, 8,... again and again until something happens(that means when the value of breath = off).

At frame 20, in "command" layer, there is an action script that says...

gotoAndPlay("over");       // Go to and play at frame label "over"

Figure 8.2

As we can see in Figure 8.2, this is how you loop when game is over.

OK, now that we have set up the game system for testing the movement of this character, let see how we are going to do next.
If I double click this character(this character is a movie clip), I will be inside as in figure 8.3. Look at the top layer that says "label". On the time line there are frame names such as "stand", "walk", "block", "duck", "punch_01",...ect. Those are the movement the character will perform when we tell it to.


Figure 8.3
 
At the bottom is a layer called "animation". This layer contains all graphics for the movement of the red pants dude. Above this "animation" layer, there is a layer called "command". This layer is very important. For each movement, the action script in this layer will be different. For example, let's take a look at "stand" frame label. The action script at frame 1 of layer "command" is as the following;

Line  1 ../:man_invincible = "off";
Line  2 ../:man_noturningback = "off";
Line  3../:man_hurt = "off";
Line  4../:warp = "off";
Line  5../:walking = "on";
Line  6../:duck = "on";
Line  7../:block = "on";
Line  8../:kick_01 = "on";
Line  9../:kick_02 = "on";
Line10../:kick_03 = "off";
Line11 ../:kick_04 = "off";
Line12 ../:punch_01 = "on";
Line13 ../:punch_02 = "on";
Line14 ../:punch_03 = "off";
Line15 ../:punch_04 = "off";
Line16 ../:movement = "on";
Line17 ../:punch_link_03 = "off";
Line18 ../:kick_link_03 = "off";
Line19 ../:kick_link_04 = "off";
Line20 if (../:status == "death") {
Line21     gotoAndPlay("death");
Line22 } else if (../:status == "walk") {
Line23     gotoAndPlay("walk");
Line24 } else if (../:status == "hurt_01") {
Line25     gotoAndPlay("hurt_01");
Line26 } else if (../:status == "hurt_02") {
Line27     gotoAndPlay("hurt_02");
Line28 } else if (../:status == "punch_01") {
Line29     gotoAndPlay("punch_01");
Line30 } else if (../:status == "kick_01") {
Line31     gotoAndPlay("kick_01");
Line32 } else if (../:status == "duck") {
Line33     gotoAndPlay("duck");
Line34 } else if (../:status == "block") {
Line35     gotoAndPlay("block");
Line36 } else if (../:status == "stand") {
Line37     play();
Line38 }
(See Figure 8.4)

Figure 8.4

I will explain it line by line just to let you see the idea of each parameter used.

Line 1: ../:man_invincible = "off"; 

There is going to be a time that your character is untouchable, during special move, during rolling on the floor, during lying down on the floor, during death(?),... etc. So I use this value to declare invincibility of the main character. When setting it off, the main character can be hit and hurt. When setting it on, he is untouchable.

Line 2: ../:man_noturningback = "off";
This value is very cool! I used it to make my character face to the direction he's supposed to face. Basically, the main character facing the way he is moving. When the main character executes combos(chain of attack movements), he will keep going the way he is facing which doesn't make sense. Then I have the "../:man_noturningback" value set, the main character can turn back and face at the enemy to attack automatically. This value is set to make the main character smarter. :)

Line 3: ../:man_hurt = "off";
This value is to show that the main character is being hurt or not. Basically, if he is hurt(../:man_hurt = "on"), I will set the condition to prohibit him to move.

Line 4: ../:warp = "off";
There is a frame label I call "warp" somewhere on the timeline. This "warp" movement is the rolling movement of my main character. I set this value to be "off" just to prevent him to do the rolling move at this state. Meaning, I don't allow him to roll when he is standing. (He can roll when he is ducking.)

Line 5: ../:walking = "on";
This value is to indicate the permission for my main character to walk from this state("stand"). "On" means he can walk from this state.

Line 6 - 19: 
The same as line 5. Those values are for the permission of each movement I set for. You can see that some of them are "on" but some are "off". The ones that say "on" mean it is ok to make that move from this "stand" state. On the other hand, "off" means not allow.

Line 20: if (../:status == "death") {
Line 21:    gotoAndPlay("death");
There is a value called status that I set just to show what status of main character is. These two lines show that if the status = "death", go to and play "death" frame label.

Line 22 - 37:
They are the same as line 20 and 21. If the value of "status" equals what it indicates, go to the frame label correspondingly.

Easy isn't it? Let's take a look at frame 2 at the "command" layer as seen in Figure 8.5.

Figure 8.5
 
The action script you see in the figure is as the following;

../:walking = "on";
../:duck = "on";
../:block = "on";
../:kick_01 = "on";
../:punch_01 = "on";
if (../:status == "death") {
    gotoAndPlay("death");
} else if (../:status == "walk") {
    gotoAndPlay("walk");
} else if (../:status == "hurt_01") {
    gotoAndPlay("hurt_01");
} else if (../:status == "hurt_02") {
    gotoAndPlay("hurt_02");
} else if (../:status == "stand") {
    gotoAndPlay(1);
}

Basically they look the same as in frame 1. I think you get the hang of it on how to set the parameters for the beginning of how to test your character.



No comments:

Post a Comment