Acceleration, Friction, and Wrapping

Screen Wrapping

OK, it's time to wrap this up. We've done screen wrapping before, so this should be a review for you.

First, we'll use an If Statement to set ship._y=0 whenever the Y position is greater than the stage height. Since we already set a variable called sH, we can use that in our statement:

ySpeed Actions

Now we'll add an else if statement to make the ship wrap in the other direction. So, we'll set ship._y=sH whenever the Y position is less than zero. Here are both conditional statements:

if(ship._y>sH){
ship._y=0;
}else if (ship._y<0){
ship._y=sH;
}

That's it! Check it out:

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player