Art based movement 8 directions

[FIXED] Thanks anyway guys, but I fixed it just then.

  • Hey guys, It’s been a long time since I’ve touched Flash in regards to gaming, but I’ve been wanting to get back in to the scene for a while now, and I started a little project last night and need some help.

I’m wanting to make a simple little art based engine where a character can walk in all directions, much like Double Dragon or Dad’n’Me. I’ve got the walking down fine, it’s just the collision detection between the hero and the walls I am having trouble with. Whenever the hero hits a wall, he flickers back and forth between standing and walking. Now, I know why this is happening, I’m just not sure what other methods I could use.

Ive attached the FLA to this post, and it’s set up very simply, so any help would be great. Cheers.

Code is located on _root, and on the 2 individual MC’s (“stand” and “run”) inside the HERO MC.*

Now, I know why this is happening,

Why is this happening?

It was because whenever he hit a wall, I was telling him to go back to heroStand, and on heroStand, if you are pressing a directional key, he is sent back to heroRun. So the result was a constant switching between stand and walk whenever he hit the wall.

To remedy this, I changed the code on heroStand to check for any walls BEFORE sending the hero to heroRun, that way, he just doesn’t move if he is against a wall.