ZFGC
Resources => Coding => Topic started by: Scooternew on April 16, 2006, 07:35:56 pm
-
I didn't see a tutorial section anywhere, so I'm posting here. This simply allows you to click a sprite and save it as a file. This isn't perfect - it doesn't include a menu (like in Windows), and it may capture gray area aroudn the sprite (or background) depending on how the sprite is shaped. Either way, this is how you do it.
temp_id = instance_position(mouse_x,mouse_y,all);
if(temp_id != noone) {
var tx, ty, tsw, tsh;
tx = temp_id.x;
ty = temp_id.y;
tsw = sprite_get_width(temp_id.sprite_index);
tsh = sprite_get_height(temp_id.sprite_index);
screen_save_part("sprite.bmp",tx,ty,tsw,tsh);
}
That can go in global left pressed.
-
Could this work as a sprite ripping program?
-
Only to rip sprites from your own gamemaker game =P
-
Not bad, but I think I see a little error. If the sprite's origin is not (0,0), the capture will be offset. There are some variables and/or functions to find the origin, that you'll have to subtract from the object position to get the left and top edges.
-
Hehe. I'm already 10 steps ahead of you. I had to go before I could put that in, and I plan to find time this week to fix that. It shouldn't be hard with some origin finding functions.
The only real times I could see this being used "usefully" would be in some kind of Game Maker paint program.
-
Very good. This is very good indeed... I may use it as a Portait taker :D. Good work scooter.