The best way to understand how to use ImageMaster is to play with the examples. Most of the commands are covered by an example.
What follows is a step by step guide to get you up and running.
The first thing you should to do is include the ImageMaster include file. The name of this file is ImageMaster.bb
| Include "ImageMaster.bb" |
Now, you initialse the display with:
| Graphics
width,height SetBuffer BackBuffer() |
Once the display is set up you can go ahead and load a pack.
| pack=LoadPack("mypack.png") |
Your next step is to extract whatever image(s) you like from the pack:
| ball=GetPackedImage("bigball",pack) |
Now it's just a matter of drawing the image using DrawImage and flipping the display buffers, waiting for a key press, or whatever you wish to do. Here is a basic example:
| ; ImageMaster -
Basic example Include "ImageMaster.bb" Graphics 230,240,0,2 ; set up sprite display SetBuffer BackBuffer() pack1=LoadPack("testpack.png") ; load pack image=GetPackedImage("sun",pack1) ; extract image DrawImage image,50,60 ; draw image to buffer Flip : WaitKey FreePack pack1 ; free up the pack EndGraphics ; close down display End |
A thing to note about
animated images ...
In SpriteMasterPro animated sprites use 1 as the first frame.
In ImageMaster the first frame in an animated image is 0.
You can find the last
frame by using PackedImageFrames()
This function will return the total number of frames in an
animated image. So, the range of frames starts from 0 and ends at
PackedImageFrames()-1
You might want to follow SpriteMasterPro by using 1 as the first frame and PackedImageFrames() as the last frame. Then it's just a matter of using frame-1 for the DrawImage frame parameter.
Example of using an animated image:
| ; ImageMaster -
Animation example Include "ImageMaster.bb" Graphics 640,480,0,2 ; set up display SetBuffer BackBuffer() pack1=LoadPack("testpack.png") frame=1 Repeat count=count+1 DrawImage runner,50,50,frame-1 Flip Until KeyHit(1) |
It's worth pointing out that once you have extracted all the images you want from a pack you can free up the pack with a call to:
| FreePack pack1 |