Quantcast
Channel: Wwwebber's Blog » bitmapdata
Viewing all articles
Browse latest Browse all 5

Meteor Based Blitter Engine

0
0

Following up on my last post on how to dynamically, scale and apply filters to display objects and then copy these into bitmapdatas , I wanted to implement the following

Source Code

1) A Meteor class that pre calculates and precaches its rotation, scale etc.. into arrays (thus gaining a performance boost ) Again, I feel the need to give a link out to 8bitrocket.com here regarding this entire idea of bitmapdata blitting for performance gains . Unlike the last post, this one would require also rotating the meteors (just a few extra lines) and storing all of the rotations into an array (I’m actually using the new Vector class…but same idea) Here’s the updated meteor class.
2) Create a Meteor Manager class (self descriptive) for adding new meteors etc..

It ended up working pretty well. Here’s about the only code you need in your main document class to get the meteors going

//create a bitmapdata --which our MetoerManager can blit to
var canvas:BitmapData = new BitmapData(stage.stageWidth,stage.stageHeight,false, 0x0000);
//create a bitmap to house the bitmapdata
var bmp = new Bitmap(canvas);
stage.addChild(bmp);

//create the Manager object
var mFact:MeteorSpawnFactory = MeteorSpawnFactory.getInstance();;
//pre-cache the bitmapdata
MeteorSpawn.preCache();

//let the manager know about the bitmapdata that it'll blit to
mFact.canvas = super.canvas;

//"spawn" a new at x = 100 and y = 200
mFact.addSpawn(100, 200);

Source Code



Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images