Multiple bitmaps from a single TPage

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Multiple bitmaps from a single TPage

Jon...

Hey Jon,

that looks more or less like how I've been doing things. I's a bit
long-winded, yeah, but after I wrote a script that generated the xml file
for swfmill and a hx file with a class definition for each image, things
became a lot more workable. I then further encapsulated the creating of
BitmapData objects and the copyPixel methods into an easily usable rendering
class.


So am I correct in thinking I have to create a new class that extends BitmapData for EACH .png file I wish to include (this is why I was going down the tpage route)
 
 Hmm - I was sure there was probably an easier way, I was really looking for way to structure a webgame that uses lot's of bitmaps (ideally laid out on a single tpage) and the "easiest" way to draw a single frame or anim sequence rather than having 100's of small images all loaded seperately.
 
Are there any flash.display functions that only draw partial bitmaps, all the methods I've found in the various bitmap classes all seem to handle whole bitmaps.
 
Jon...

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Multiple bitmaps from a single TPage

Gamehaxe
Hi,
What you would normally think of as a "bitmap" is actually "BitmapData" in  
flash.
(eg, your "sprite sheet")
The "Bitmap" is actually the instance of it on the stage, eg what
you would probably call a "Sprite".

So you load you PNG image into "BitmapData".  With no direct API
to do this, you load it into a "Bitmap", get the data, and chuck
away the Bitmap (ie, don't add it to the stage).

Now say you want to instanciate a coule of sprite using various
(possibly animated) sub-rects of this BitmapData for display.

1. You could create a flash.disply.Bitmap for each of the Sprites,
     and set their "bitmapData" to the "sprite sheet".  I think you
     then set the "scrollRect" to view your given sprite. I have
     not tried this.

2. You could create a Bitmap for each sprite and "copyPixels" the
    data from your sprite sheet onto the bitmapData of the bitmap.

3. You create ONE flash.display.Bitmap for your main game area and then
    "copyPixels" from your sprite sheet onto that bitmap for EACH
    of your sprites.  This is the more traditional "game loop" and is
    actually quite fast.

Hugh

>> Hey Jon,
>>
>> that looks more or less like how I've been doing things. I's a bit
>> long-winded, yeah, but after I wrote a script that generated the xml  
>> file
>> for swfmill and a hx file with a class definition for each image, things
>> became a lot more workable. I then further encapsulated the creating of
>> BitmapData objects and the copyPixel methods into an easily usable
>> rendering
>> class.
>>
>>
>> So am I correct in thinking I have to create a new class that extends
> BitmapData for EACH .png file I wish to include (this is why I was going
> down the tpage route)
>
>   Hmm - I was sure there was probably an easier way, I was really looking
> for way to structure a webgame that uses lot's of bitmaps (ideally laid  
> out
> on a single tpage) and the "easiest" way to draw a single frame or anim
> sequence rather than having 100's of small images all loaded seperately.
>
> Are there any flash.display functions that only draw partial bitmaps, all
> the methods I've found in the various bitmap classes all seem to handle
> whole bitmaps.
>
> Jon...



--
haXe - an open source web programming language
http://haxe.org