DrawImageRect and MidHandle
Monkey Forums/Monkey Programming/DrawImageRect and MidHandle
| ||
Hi guys, as I'd like to use a texture packer I'll have to use DrawImageRect of course instead of DrawImage, BUT in that case I can't use the image flag MidHandle which is quite handy when you want to rotate images around its center. Any ideas? I can't imagine I'm the first one with that "problem"? Cheers! |
| ||
you don't use diddy do you ?PowerUPImage[0] = ImageSpriteSheet.GrabImage(918,216,54,54,1,Image.MidHandle)'bomb |
| ||
Oh and obv that would mean you wont be using DrawImageRect you will just DrawImage normally. |
| ||
Oh well, thanks for pointing me to that one! |
| ||
Did that help ? |
| ||
I haven't tried yet. ;) But I think it will! |
| ||
I use a texture pack and can set a midhandle, though I wrote the texture packer code that extracts the images, I am sure I just grabimage(you can set handle here). |
| ||
Yes, GrabImage is the key! Thanks so much! GrabImage does not create a copy, does it? |
| ||
Do you mean a copy of the whole sprite sheet, or a copy of the small section that you grab ? I think it grabs a small section and makes a fresh copy of that small part but I have not looked into it, didn't feel the need, it worked and did what I wanted of it .. |
| ||
Well if it creates a copy this doesn't make sense at all to pack the textures into one file. |
| ||
Yeah I see your point, then its still taking up extra space in memory, it must reference it then surely ? food for thought. |
| ||
AFAIK grabimage just references the parent image and does not make a copy of the grab portion. I remember posting a thread a while back about some grab image weird-ness and we can to the conclusion it references. |
| ||
taking a quick look at the docs... "GrabImage creates a new image by 'grabbing' a rectangular region of the current image." that would suggest that it does create a little copy of that portion of the over all sprite sheet. Mark ? |
| ||
As far as we could work out it does reference http://www.monkeycoder.co.nz/Community/posts.php?topic=2301#22522 changes made to the referenced image effect the grabbed images. |
| ||
Aye it references the image, so it's using the one surface, if you delete or change the image you 'grabbed' from the images you grabbed are changed/deleted. So just grab them, center and away you go :P |
| ||
I use DrawImageRect and you can set the handle the same as you would a normal DrawImage. Even if your sprite sheet is 2048x2048 and you want to draw a 16x16 sprite off your sprite sheet, you just set the handle on your sprite sheet to 8,8 and then draw your sprite with DrawImageRect. The texture packer has to give you the width and height of the each sprite so you should just be able to do something like: IMGspritesheet.SetHandle(sprite1_w/2,sprite1_h/2) DrawImageRect(IMGspritesheet, sprite_x, sprite_y, spritesheet_x, spritesheet_y, sprite1_w, sprite1_h) |