Advertisement
Guest User

Sprite Updates

a guest
Jun 8th, 2014
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Update Section
  2. for (i = 0; i < count; i++)
  3. {
  4.     sprite = new SpriteClass();
  5.     sprite.destX = 350 + 20*(i%4);
  6.     sprite.destY = 350; // + 10*(int(Math.random()*4));
  7.     sprite.x = int(Math.random() * 700);
  8.     sprite.y = 290 + int(Math.random() * 200);
  9.     //addChild(sprite);
  10.     addChild(sprite.bitmapCanvas);
  11.     sprites.push(sprite);
  12. }
  13.  
  14. public function SpriteClass()
  15. {
  16.     speed = 5.5;
  17.     remainingMoveRate = speed;
  18.     bitmapDataCanvas = new BitmapData(20, 20, true, 0x000000);
  19.     bitmapCanvas = new Bitmap(bitmapDataCanvas);
  20.     rectUnit = new Rectangle(0, 0, 20, 20);
  21.     //addChild(bitmapCanvas);
  22. }
  23.  
  24. public function Update():void
  25. {
  26.     MoveUnit();
  27.     //Got added to compensate for not being in the sprite class
  28.     bitmapCanvas.x = x;
  29.     bitmapCanvas.y = y;
  30.            
  31.     bitmapDataCanvas.lock();
  32.     //rectUnit.x = 0;
  33.     //rectUnit.y = 0;
  34.     bitmapDataCanvas.fillRect(Main.rectBackground, 0x00000000);
  35.     bitmapDataCanvas.copyPixels(Main.spriteData, rectUnit, Main.pointUnit);
  36.     bitmapDataCanvas.unlock();
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement