What I basically just made an add-on till Rystic's jumping engine so read all about that before reading this thread.
--------------------
Things to keep aware of:
1. Make sure that you have an enemy with the instance name "enemy"
2. The following code goes on "enemy"
3. Make your wall's instance names ground1, ground2, ground3 etc...
4. Explanations are in the code after the "//"
5. Make the attacking part on your own, it isn't that hard
6. Make sure "enemy is just touching ground# at the start
7. This took me a long time so don't flame me if it sucks or you could do better
8. Make Rystic's jumping engine before doing this
9. Have fun and leave a comment!
--------------------
Here's the god dang code for "enemy":
onClipEvent (load) {
// loads the variables
enemyjump = false;
enemyoffground = false;
enemyjumping = 0;
enemyfall = false;
enemyfalling = 0;
}
onClipEvent (enterFrame) {
// rotates to face player
Xdiff = _parent.circle._x-_x;
Ydiff = _parent.circle._y-_y;
radAngle = Math.atan2(Ydiff, Xdiff);
_rotation = int((radAngle*360/(2*Math.PI))+90);
updateAfterEvent();
if (this.hitTest(_parent.circle)) {
} else {
// Do attack... add this in yourself
// this is saying attack or otherwise move
// telling flash if "enemy" is touching the ground and is lower than "circle" to make "enemy" jump and then otherwise not to jump
if (_root.circle._y<=_root.enemy._y) {
for (i=0; i<=100; i++) {
if (this.hitTest(_root["ground"+i])) {
enemyjump = true;
} else {
enemyjump = false;
}
}
}
// telling flash that if "enemy" is touching the "ground" and that it is not jumping and otherwise is
if (this.hitTest(_root["ground"+i])) {
enemyoffground = false;
} else {
enemyoffground = true;
}
// all this before my next comment to this one is telling flash what to do when jumping
if (enemyjump == true) {
enemyjumping = 4;
}
if (enemyjumping>0) {
enemyjumping -= 1;
updateAfterEvent();
}
_root.enemy._y -= enemyjumping;
}
// saying that if "enemy" is not going upwards and is not touching the "ground" then it should start falling
if (enemyjumping = 0) {
if (enemyoffground == true) {
enemyfall = true;
} else {
enemyfall = false;
}
if (enemyfall == false) {
enemyfalling = 0;
}
if (enemyfall == true) {
enemyfalling = 1;
}
if (enemyfalling>0) {
enemyfalling += 1;
updateAfterEvent();
}
// makes "enemy" stop falling if it hits ground
if (this.hitTest(_root["ground"+i])) {
enemyfalling = 0;
}
}
_root.enemy._y += enemyfalling;
}
// tells "enemy" to move left when "circle" is left of "enemy" and the same with right
if (_root.circle._x>=_root.enemy._x) {
_root.enemy._x += 3;
}
if (_root.circle._x<=_root.enemy._x) {
_root.enemy._x -= 3;
}
}