Advertisement
Guest User

Untitled

a guest
Mar 11th, 2019
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //var balloons:Array = [mcBalloonPink, mcBalloonGreen, mcBalloonRed];
  2. //class names in library: Balloon1, Balloon2, Balloon3
  3.  
  4. var balloons:Array=[];
  5. var tweens:Array = [];
  6.  
  7. function spawnRandomBalloons(te:TimerEvent):void
  8. {
  9.     var i:uint = Math.floor(Math.random() * 3)
  10.     var cls:Class = getDefinitionByName( "Balloon" + i ) as Class;
  11.     var balloon = new cls();
  12.    
  13.     balloon.x = 450;
  14.     balloon.y = Math.floor(Math.random()*(1 + topBoundary - bottomBoundary)) + bottomBoundary;
  15.  
  16.     var tween:Tween = new Tween(balloon, "x", None.easeNone, 450, -450, 3, true);
  17.     tween.addEventListener(TweenEvent.MOTION_FINISH, destroyTweenedObj);
  18.  
  19.     mcGullGame.addChild(balloon);
  20.     balloons.push(balloon);
  21.     tweens.push(tween);
  22. }
  23.  
  24. function checkBalloons(event:Event):void
  25. {
  26.     for(var i:uint=0; i balloons.length; i++)
  27.     {
  28.         if(balloons[i].hitTest(bird))
  29.         {
  30.             mcGullGame.removeChild(balloons[i]);
  31.             balloons.splice(i,1);
  32.             break;
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement