AS3 character movement from one frame to next
I am quite new to AS3 and am really enjoying learning it.
My problem is I need to move a character from one frame to another.
I know how to move him and make him go from one frame to the next scene by having him move with the arrow keys to a hit point, but I cant figure out how to do this below
If the character walks right to the end of the stage he should appear on the left of the next frame. If
he walks to the left of the stage he should appear on the right of the previous scene
Any help would be great, thanks guys.
You could handle this inside of your key pressed object, and see use Logic to see if he has moved off of the stage width. For example, if your stage is 550px wide, when the x position of your character is greater than 550, then you would go to Scene 2. When the position is less than 0 - character.width then go to past scene.
This code currently works for two scenes. If you have more than this, you will need to add logic to determine which sceen you are in:
var amtMoved:int = 5;
if (event.keyCode == 40)
guy.y = guy.y + amtMoved;
if (event.keyCode == 38)
guy.y = guy.y - amtMoved;
if (event.keyCode == 37)
guy.x = guy.x - amtMoved;
if (event.keyCode == 39)
guy.x = guy.x + amtMoved;
if (guy.x > 550)
guy.x = guyX-550;
if (guy.x < 0-guy.width)
guy.x = guyX+550;
Click Here to Expand Forum to Full Width