animated Images?
Monkey Forums/Monkey Programming/animated Images?
| ||
is there a way to load animated images like BlitzBasic/Max? or an alternative for monkey? |
| ||
You want to look into the frames parameter of the LoadImage command docs: index.html#/mojo.graphics/LoadImage |
| ||
Thanks a lot. I didn't realize all the information was in the documentation. |
| ||
Does Monkey support sprite sheets that spans horizontal and vertical images? Ive just loaded an image which contains 16 (32x32 pixels) sprites, 8 on the top row and 8 on the bottom row. And I used the command: enemy1Img = LoadImage("aster32.png", 16, Image.MidHandle) When I displayed the first frame it was messed up - I had to change the image to one long line of sprites. BTW The size of the image is 256x64 |
| ||
From Monkey documentation: The frames of a multiple frame image must be laid out in a horizontal strip, in which case the width of the loaded image is the width of image file divided by the number of frames, and the height of the image is the height of the image file. I believe Mar is looking into changing the something in LoadImage. From this thread: http://www.monkeycoder.co.nz/Community/posts.php?topic=188 I believe he is going to redo the LoadImage format as I don't see any other way he can solve that problem. |
| ||
Thanks Jesse... didnt read the doco there! Yeah I saw your thread about the white images... |
| ||
Hi, Actually, there may already be a solution! Try something like: Local atlas:=LoadImage( "blah.png" ) Local image:=atlas.GrabImage( 0,0,frame_w,frame_h,frame_count ) This should correctly 'wrap around' allowing you have multiple rows of frames instead of just a single row. |
| ||
Yep that works! :) Would be nice if there was one command to do it though :P |
| ||
What's wrong withLoadImage(URL,width,height,frame_count) ? edit: I discovered there's no reference in the guide, and in the source code is marked as *deprecated* - but I dont' know why eliminate it, as it seems to work (and it's used by SetFont command too) |
| ||
Thats only good for an image in a horizontal strip format. |
| ||
@Therevills no, sorry, you are referring to the first variation of LoadImage There are 2 different implementation (thanks overloading) LoadImage(URL,frame_count) LoadImage(URL,width,height,frame_count) The second one is similar to the Blitz3d/BlitzMax one: URL can be a 'rectangular/boxed' image divided in X x Y images (of the same sizes) So you can provide a 128x64 pixel images containg 32x32 pixels frames (frame_count is 4x2 = 8 frame) |
| ||
I've used LoadImage and DawImageRect (where you have to deal with calculating the rect on your own) and it worked out pretty well: mno |
| ||
Thanks degac... Its funny as the code Mark provided is very similar to the code in graphics.monkey: 'deprecated! Function LoadImage:Image( path$,frameWidth,frameHeight,frameCount,flags=Image.DefaultFlags ) Local atlas:Image=New Image( path,1,0 ) If atlas Return atlas.GrabImage( 0,0,frameWidth,frameHeight,frameCount,flags ) End |
| ||
Hi, > LoadImage(URL,width,height,frame_count) I don't like this version for 2 reasons: * It creates an extra image 'behind the back' of the user. * It could encourage people to loading atlases multiple times, wasting gfx mem. In general, GrabImage should be preferred I think as it encourages 'image sharing'. The above LoadImage is therefore currently 'deprecated' and marked for destruction! |
| ||
So you are saying that we shouldn't be so lazy :P |
| ||
>So you are saying that we shouldn't be so lazy :P Bingo! |
| ||
:) BTW Why "atlas"? |
| ||
Hi, > BTW Why "atlas"? It's a term often used in 3D to describe the practice of packing multiple anims/images/textures into one larger anim/image/texture. |
| ||
Ta! Learn something new everyday :) http://en.wikipedia.org/wiki/Texture_atlas |