Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var MiPelota = new pelota();
- addChild(MiPelota);
- MiPelota.width /= 2;
- MiPelota.height /= 2;
- MiPelota.x = MiPelota.width / 2;
- MiPelota.y = MiPelota.height / 2;
- MiPelota.addEventListener(Event.ENTER_FRAME, mover);
- var desplazamientoY = 2;
- var desplazamientoX = 2;
- var cambioDireccion = false;
- var yMax = stage.height;
- var xMax = stage.width;
- function mover(e:Event)
- {
- if(MiPelota.y >= (yMax - MiPelota.height / 2) || cambioDireccion)
- {
- cambioDireccion = true;
- MiPelota.x += desplazamientoX;
- MiPelota.y -= desplazamientoY;
- }else{
- MiPelota.x += desplazamientoX;
- MiPelota.y += desplazamientoY;
- }
- trace(MiPelota.y + " ----- " + (stage.height - MiPelota.height / 2));
- }
Add Comment
Please, Sign In to add comment