D
Deleted member 16767
Guest
When I make a polygon, I want to save it to sprite_index so that I can use it for drawing with my paint app. Is there any way to make it possible to save the polygon mask to sprite_index?
// Create a surface big enough to contain your polygon
var w = 200, h = 200;
var surf = surface_create(w,h);
// Target the surface and draw the polygon on a cleared background
surface_set_target(surf);
draw_clear_alpha(c_black, 0);
// Draw your polygon here
surface_reset_target();
// Create a sprite from the surface -- you should look up the function to see what argument values you want
spr_polygon = sprite_create_from_surface(surf, 0, 0, w, h, false, false, 0, 0);
// Now we don't need the surface anymore, so delete it
surface_free(surf);
// Assign the sprite to sprite_index
sprite_index = spr_polygon;
// Or draw the sprite
draw_sprite(spr_polygon, 0, x, y);
// ...
// Then when you don't need the sprite anymore, to avoid memory leak:
sprite_delete(spr_polygon)