actionscript para background de videojuego (juego flash)

Creado a las // comentar

/*
The Background class is linked to a background movie clip on the stage.
The background will slowly scroll left (negative on the x axis) 1 pixel per frame (30 pixels per second)
The background image is 2110 pixel long, but is duplicated so it will appear to scroll seamlessly.
When the background has scrolled all 2110 pixels, it will snap back to zero and keep scrolling.
This will create the effect of an infinitely scrolling backdrop.
*/

class Background extends MovieClip
{
//this onEnterFrame function is a built-in function of every movie clip. It will execute all code inside it at frame rate (30 times a second)
function onEnterFrame()
{
//move the background image one pixel to the left
_x -= 1;

//if it has travelled its entire length (2110 pixels)
if(_x < -2110)
{
//then snap it back to zero, it will appear to scroll seamlessly
_x = 0;
}
}
}

0 comentarios: