Home Tutorials Forums Articles Blogs Movies Library Employment Press
Prev Previous Post   Next Post Next
Old 07-19-2011, 08:24 AM   #1
Mojo86
Registered User
 
Join Date: Jul 2011
Posts: 6
Default [AS3] Sprite sheet help

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.
Mojo86 is offline   Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:13 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.