Testing your character movement (Part 3)

September 14, 2011
___________________________________________________________________

OK. Continue with the topic. In part 2, I talked about the action script for standing. This part, I will talk about walking action script. As you can see below,Figure 9.1, The action script is on the "command" layer at frame 10.

Figure 9.1

The script is as the following.

Line  1: ../:duck = "on";
Line  2: ../:block = "on";
Line  3: ../:kick_01 = "on";
Line  4: ../:punch_01 = "on";
Line  5: if (../:walking == "on") {
Line  6:     play();
Line  7: } else if (../:walking == "off" or ../:status == "stand") {
Line  8:     gotoAndPlay(1);
Line  9: }
Line10: if (../:status == "death") {
Line11:      gotoAndPlay("death");
Line12:  } else if (../:status == "hurt_01") {
Line13:      gotoAndPlay("hurt_01");
Line14:  } else if (../:status == "hurt_02") {
Line15:      gotoAndPlay("hurt_02");
Line16:  } else if (../:status == "punch_01") {
Line17:      gotoAndPlay("punch_01");
Line18:  } else if (../:status == "kick_01") {
Line19:      gotoAndPlay("kick_01");
Line20:  } else if (../:status == "duck") {
Line21:      gotoAndPlay("duck");
Line22:  } else if (../:status == "block") {
Line23:      gotoAndPlay("block");
Line24:  }
(See Figure 9.2)
 
Figure 9.2

Again, I will explain most of the script here.
___________________________________________________________________

../:duck = "on";
 
This value is to indicate the permission for my main character to duck from this state("walking"). "On" means he can duck from this state.
___________________________________________________________________
 
../:block = "on";
../:kick_01 = "on";
../:punch_01 = "on";
 
Well, these 3 lines are the same as the first line. The values are for the permission of each movement I set for. "on" means it is ok to make that move from this "stand" state, i.e., he can block, kick_01, and punch_01 from walking state.
___________________________________________________________________
 
if (../:walking == "on") {
    play();
} else if (../:walking == "off" or ../:status == "stand") {
    gotoAndPlay(1);
}

  This means if the value of parameter "walking" is "on", then just keep playing on the timeline. On the other hand, if the parameter "walking" is "off" or the parameter "status" is set to be "stand", just go back and play at frame 1(which is the the frame label "stand").
___________________________________________________________________

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

These lines just show that fi the value of "status" equals what it indicates, go to the frame label correspondingly.
____________________________________________________________________

Now, I want to show you that this action script will be used in frame 11 - 13 as well(see Figure 9.3).

Figure 9.3

You can right click at the action script frame you want to copy and then choose "Copy Frames" or you can press Ctrl+Alt+C. Then you paste them by right clicking the frame you want to paste and choose "Paste Frames" or you can press Ctrl+Alt+v.

The last frame on this state(walk) that has an action script on frame 14 will have a little bit different action script as seen below.

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

Figure 9.4

The only different is at line 5.

if (../:walking == "on") {
    gotoAndPlay("walk");

This means that if the parameter "walking" is "on", then go back and play at frame label "walk". This is how we loop the walk movement.

That's it for this part. I think you get the idea for the rest of the movement. On the next part, I will explain how to make your main character controllable ;)

No comments:

Post a Comment