Posted By

RiveraEraGames on 07/03/14


Tagged

as3 bounce


Versions (?)

BOUNCE Your MovieClip


 / Published in: ActionScript 3
 

This causes a movie clip on the stage to bounce down and up.

  1. //CAUSE MC TO BOUNCE DOWN AND UP
  2. //IN THIS CASE THE MC IS 'spiderOne'
  3. var count:Number = 0;
  4. var bounceHeight:Number = 300;
  5. var floorHeight:Number = 350;
  6. var speed:Number = .03;
  7. stage.addEventListener (Event.ENTER_FRAME, runSpiderOne);
  8. function runSpiderOne (evt:Event):void
  9. {
  10. spiderOne.y = floorHeight - Math.abs(Math.cos(count)) * bounceHeight;
  11. count += Math.random() * speed;
  12. }
  13. //SO MAKE A MOVIECLIP
  14. //DROP IT ON THE STAGE
  15. //NAME THE INSTANCE 'spiderOne'
  16. //WATCH IT BOUNCE

Report this snippet  

You need to login to post a comment.