I need help for my platformer!

Hi,
i don’t know if this has been posted up before (Im new) So I’m posting this anyway.
I’ve got my character working fine and everything is but I don’t want my character to fall off the stage (I got a scrolling bg) But I don’t want a wall, Does anyone know the code for when my character hits 0 on the left hand side of the stage it stops? My friend gave me a code but it didnt work.

Also could you tell me where it would go?

Please reply,

Amy xxx

if(_root.character_mc._x<=0){
speed = 0;
}
if(_root.character_mc._x<=550){
speed = 0;
}
that ought to work for you there the numbers are just the stage dimensions so you can easily adjust them to make him stop farther away from the edge or accomodate a larger stage and it is made to go on the main timelin e where the rest of your code should be attempted be organized hope that works :smiley:

[quote=cooldude88;2324453]if(_root.character_mc._x<=0){
speed = 0;
}
if(_root.character_mc._x[COLOR=Red]>[/COLOR]=550){
speed = 0;
}
[/quote]

There. Fixed that for you, else the character wouldn’t ever move.

You could do it different ways. Basically, what you need to do is check if your character’s _x is greater than the width of the stage or less than zero.Depending on the case you either subtract his ‘Speed’ variable(assuming there’s one) from his _x value, or add to it.

if(char._x>=Stage.width){
char._x-=Speed;
}
if(char._x<=0){
char._x+=Speed;
}

:smirk:

or you can just draw a rectangle bar, set the alpha to 0, and put the code to push the character away. But I guess zupers way is better ^^.