Guest User

Untitled

a guest
Jan 5th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. var MiPelota = new pelota();
  2. addChild(MiPelota);
  3.  
  4. MiPelota.width /= 2;
  5. MiPelota.height /= 2;
  6.  
  7. MiPelota.x = MiPelota.width / 2;
  8. MiPelota.y = MiPelota.height / 2;
  9.  
  10. MiPelota.addEventListener(Event.ENTER_FRAME, mover);
  11.  
  12. var desplazamientoY = 2;
  13. var desplazamientoX = 2;
  14.  
  15. var cambioDireccion = false;
  16.  
  17. var yMax = stage.height;
  18. var xMax = stage.width;
  19.  
  20. function mover(e:Event)
  21. {
  22. if(MiPelota.y >= (yMax - MiPelota.height / 2) || cambioDireccion)
  23. {
  24. cambioDireccion = true;
  25.  
  26. MiPelota.x += desplazamientoX;
  27. MiPelota.y -= desplazamientoY;
  28. }else{
  29. MiPelota.x += desplazamientoX;
  30. MiPelota.y += desplazamientoY;
  31. }
  32.  
  33. trace(MiPelota.y + " ----- " + (stage.height - MiPelota.height / 2));
  34. }
Add Comment
Please, Sign In to add comment