I would like a pacman like effect when the character goes outside of the left side of the game window then they come from the right side of the window. My character can only move left and right so they would be using the same left and right parts of the window. I need help on the actionscript for this i am using 2.0 on flash 5
Do you have your character moving off to the left? If so, right after each step of movement you should be checking its _x property to see if it is at a value that puts it off the playing area... just as an example...
character._x -= 3; // move to the left
if(character._x < leftboundaryX){ // check if it stepped over the boundary
character._x = rightboundaryX; // if so, move it across to the other side
}
Thanks a lot for your continued support, it means a lot.
After a bit of error work-arounds I'll show you my code, because while there are no errors it doesn't seem to work. My character just goes endlessly off the left of the screen.
onClipEvent (load)
{
speed = 4;
}
onClipEvent (enterFrame)
{
if (Key.isDown(39))
{
this._x = this._x + speed;
} // end if
if (Key.isDown(37))
{
this._x = this._x - speed;
} // end if
character._x -= 3
if(character._x < leftboundaryX) { // check if it stepped over the boundary
character._x = rightboundaryX; } // if so, move it across to the other side
}
You cannot blindly copy code and expect it to work - as stated it was just an example. You need to define the left boundary and the right boundary values. You already have the movement code so you don't need my character._x -= 3 line. You don't want to use "character" at all... you are using "this" instead.
North America
Europe, Middle East and Africa
Asia Pacific