LINKS YOU WILL NEED:
AS: Movement on Slopes - pyro 111
GOOD LINKS:
AS: Main XD
THE TUTORIAL
First, create your character and platforms using this tutorial: AS: Movement on Slopes - pyro 111
Give your character the instance name "circle" without the quotes
Now, make your enemy movie clip. It must not be instance named.
Put two frames in your enemy movie clip. MAKE SURE THE ENEMY IS FACING LEFT!!!!!!
Frame 1 will be walking, and you should be able to work out how to make it attack (if you want that) I will only be teaching you how to script the walking, and here it is:
// original script by pyro111
// AI edited by Hoeloe
onClipEvent (load) {
grav = 0;
// sets the gravity
speed = 4;
// sets movement speed
scale = _xscale;
// sets the size of the enemy
}
onClipEvent (enterFrame) {
// happens every frame
grav++;
// makes you fall faster
_y += grav;
// makes your _y go up by the varaible grav
while (_root.ground.hitTest(_x, _y, true)) {
// when this is touching the ground
_y--;
// makes the y keep going up, this means you can walk on slopes XD
grav = 0;
// and you wont fall, another XD
}
if(_xscale == scale){
// if your _xscale is the same as the variable scale (facing the start direction)
this._x -= speed;// moves the enemy left by speed
}
if(_xscale == -scale){// if your _xscale is facing the opposite way from the start
this._x += speed;// moves right by speed
}
if (!_root.ground.hitTest(_x, _y+5, true)) {
// if you are touching a big enough drop
if (_xscale == scale){
// if you are facing left
this._x += speed;
// you move back by speed
this._xscale = -scale;
// and change direction
}else if (_xscale == -scale){
// if you are facing right
this._x -= speed;
// you move back by speed
this._xscale = scale;
// and turn around
}
}
if (_root.ground.hitTest(_x, _y-5, true)) {
// if you hit a wall
if (_xscale == scale){
// if you are facing left
this._x += speed;
// you move back by speed
this._xscale = -scale;
// and change direction
}else if (_xscale == -scale){
// if you are facing right
this._x -= speed;
// you move back by speed
this._xscale = scale;
// and turn around
}
}
}
Please notify me of any problems
This script will work for flash 7, im not sure about any of the others
What this should look like:
I hope this helped, please leave feedback