Flash Help, Please!
Hey i was testing my game and the resolution is 300x400 and i made it on Flash MX 2004 but when Im playing the game and controlling my sprite you can make it so he just wonders off the screen. What do i do to stop him from just wodering off?
First I will say I dont know how flash works...so this is just a general answer. I hope you can apply it.
You do a thing called "collision detection." When the players x position is greater than or equal to 300-playerxsize, you dont allow him to move. Same goes for when it is less than or equal to 0.
Here is some pseudo code to explain:
There you go cheech. That should get you started. You want to make sure the position isn't outside the bounding area before you let him move.
You do a thing called "collision detection." When the players x position is greater than or equal to 300-playerxsize, you dont allow him to move. Same goes for when it is less than or equal to 0.
Here is some pseudo code to explain:
if(keydown == right){ //the guy should move right if(xpos < 300 - xsize) xpos++; }else if(keydown == left){ if(xpos > 0) xpos--;}if(keydown == up){ if(ypos > 0) ypos--;}if(keydown == down){ if(ypos < 400 - ysize) ypos++;}
There you go cheech. That should get you started. You want to make sure the position isn't outside the bounding area before you let him move.
K well anyone that knows flash can tell me what to do? That last post helped me a bit but I still dont know what code to use, i'v been trying to google it for like the past couple hours lol
COMON PEOPLE LOL ANYONEW ELSE KNOW WHAT KIND OF CODE I SHOULD USE OR HOW TO FIX THIS PROBLEM?
ok here ya go, let me know if this isnt what your looking for
then same thing for the _y to catch top and bottom, of course im assuming player is the varible name for whatever your character name is
if (Key.IsDOWN(key.RIGHT) && player._x < 300){player._x = player._x + 2;}if (Key.IsDOWN(key.LEFT) && player._x > 1){player._x = player._x - 2;}
then same thing for the _y to catch top and bottom, of course im assuming player is the varible name for whatever your character name is
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement