Posted By

RiveraEraGames on 06/01/14


Tagged

effect as3 EARTHQUAKE


Versions (?)

Earthquake Effect (RIVERA ERA)


 / Published in: ActionScript 3
 

Produces a 'quake' effect on an instance of a MC. (It's The Rivera Era)

  1. //ITS THE RIVERA ERA
  2. //THE FIRST URBAN PUERTO RICAN DEVELOPER
  3.  
  4. //REPLACE 'instance_name_here' WITH YOUR
  5. //MC OBJECT INSTANCE NAME
  6.  
  7. import flash.events.Event;
  8. stage.addEventListener(Event.ENTER_FRAME, mMotion);
  9. function mMotion(evt:Event):void
  10. {
  11. instance_name_here.x = stage.stageWidth / 2;
  12. instance_name_here.y = stage.stageHeight / 2;
  13.  
  14. instance_name_here.x += Math.floor(Math.random() * 100);
  15. instance_name_here.y -= Math.ceil(Math.random() * 100);
  16.  
  17. if (instance_name_here.x > stage.stageWidth)
  18. {
  19. instance_name_here.x = stage.stageWidth / 2;
  20.  
  21. if (instance_name_here.y > stage.stageHeight)
  22. {
  23. instance_name_here.y = stage.stageHeight / 2;
  24. }
  25. }
  26. }

Report this snippet  

You need to login to post a comment.