Creating Simple Enemy
In order to understand this short tutorial first read Character Elastic Movement and Adding mc speed using Numeric Stepper component posts. Next step is to create simple enemy and to animate that enemy.
We have new movie clip (green rectangle) that represents enemy in our game. Instance of enemy movie clip is on stage and that instance is named mc_enemy. First we want to create very basic enemy movement in single horizontal line. When enemy reaches stage end it changes direction. Before we define function for movement we want to give our new movie clip starting direction. Let’s make a deal : if direction has value 1, enemy goes left and if direction has value 2, enemy goes right.
Starting direction is determent by variable dir like this:
var dir:Number = new Number(1);
This will force our movie clip to start moving left when we define function onEnterFrame for movie clip mc_enemy. Function is simple, has 4 if conditional statement and they define simple enemy movement. We have modified coordinates where enemy movie clip changes direction for 15 pixels, which is half of movie clip’s width. In this way border bounce is better.

Download : file.
Next time we will see how we can detect collision between our Hero and Enemy.







Recent Comments
you
link is : http://www.cellufun.com/Game
-Erika
I found s