I’m having a problem with this. Heres the code I use to stop me from moving out of the bottom of the screen:
//if the player moves below the stage area, move it back to the bottom of the stage
if((this._y+this._height)>Stage.height){
this._y=Stage.height-this._height;
}
this (I think) makes you not able to move out the top of the screen:
//if the player moves above the stage area, move it back to the top of the stage
if(this._y<0){
this._y=0;
}
this stop the player from moving out the right side of the screen:
if((this._x+this._width)>Stage.width){
this._x=Stage.width-this._width;
}
if(this._x<0){
this.x=0;
}
this one isn’t working though it stops you from moving out of the left of the screen:
if((this._x+this._width)>Stage.width){
this._x=Stage.width-this._width;
}
if(this._x>550){
this.x=550;
}
Thanks for helping.