-
side following?
hmm i've been doing a platfrom game now,
and now i've encountered a problem about
how the enemy will face the hero
like if the hero is on the right side of the enemy,
it will face right
same as the left side, if the hero at the left side
of the enemy, then the enemy looks that way
and i have no idea how thats done...
anyway, thnx a bunch!:D
-
gmm...
not sure if I understood you correctly but,
if you have a "top view", and you need to detect the position of the enemy then you can do this:
if ( enemy._x - hero._x > 0 ) { enemy is on the right }
if ( enemy._x - hero._x < 0 ) { enemy is on the left }
if ( enemy._y - hero._y > 0 ) { enemy is behind }
if ( enemy._y - hero._y < 0 ) { enemy is in front }
-
I am making a platformer and i used this.
Code:
_root.enemy.onEnterFrame = function() {
if (_root.hero._x>_root.enemy._x) {
_root.enemy._xscale = 100
}
if (_root.hero._x<_root.enemy._x) {
_root.enemy._xscale = -100
}
};
You may need to change the code a little, for example the value of 100 may distort your movie clip so you may need to experiment until you get the right size.
Hope It Helps
-
dude, thats exactly what i needed!
hey thnx for the help you guys!
OH, hey GingaNinja, I noticed you mentioned that
you used it also in your platformer game, may
I know its current progress?:)
thnx agen!:D
-
Heres a lower sized version of it as the actual file is too big.
I haven't used that code above in this one but i have in my most recent one, it will be on my website soon - www.freewebs.com/beefcake4eva In my recent one, the terrein scrolls and it has enemys and attacks. the red one attacks using distance checks and looks quite cool when he attacks at random but kills the enemy anyway.
It is a platformer game but it doesn't have any platforms yet, only one main one. You can jump and use the sonic style spring in th middle, the red character follows you and does kinda what you do but sometimes he does his own thing which is kinda kool, im quite impressed with it myself so far. Hope you like it.
Controls:
Left = Left Key
Right = Right Key
Jump = Up Key
-
haha, i played wit it for 30 minutes...:D
its kinda fun actually, wish yah luck on that game!