Hi all. I'm making a game with lots of objects moving down the screen at all times. The objects are different kind of bricks, so initially I had a brick class which decides which brick animation to play and an event listener that moves the brick down the screen by changing the y position. I create many instances of this brick class from my main class.
The problem I have now is that the game is lagging. I have a feeling it is due to the amount of animated bricks I have moving from top to bottom of the screen. I am now trying to make these bricks as sprite sheets but I seem to be having problems with it.
This is an example of my brick class
Code:
import flash.display.MovieClip;
import flash.display.Bitmap;
import flash.events.Event;
public class Brick extends MovieClip {
public var _column:int;
public var _type:int;
var _root:MovieClip;
public function Brick(columnNum:int, typeNum:int) {
_column = columnNum;
_type = typeNum;
this.x = ....
this.y = ....
this.addEventListener(Event.ADDED, beginClass);
}
private function beginClass(event:Event):void{
_root = MovieClip(root);
var brick :Bitmap = new Bitmap( _root.bitmaps[0] );
addChild(brick);
addMove();
}
public function move(evt:Event):void {
this.y+=speed;
}
_root.bitmaps[0] is the name of my bitmapData from the main class. I copied information from a sprite sheet to it. When I run this code, I see my brick with a white background on my stage and it's not moving. I'm not sure why there is a white background and why it's not moving? I have a feeling I'm getting the concept wrong. Thanks if anyone could help.