Nathan Laing
Member
Hello all,
With the use of sprite_create_from_surface, is an entirely new texture page created on the fly to store the newly created sprite? And if so, if sprite_create_from_surface is used multiple times, are multiple new texture pages created, or, are the newly created sprites added to the previously created texture page? The angle here is that I am concerned about having an outrageous number of texture swaps.
This entry from the manual does not discuss it:
With the use of sprite_create_from_surface, is an entirely new texture page created on the fly to store the newly created sprite? And if so, if sprite_create_from_surface is used multiple times, are multiple new texture pages created, or, are the newly created sprites added to the previously created texture page? The angle here is that I am concerned about having an outrageous number of texture swaps.
This entry from the manual does not discuss it:
The [below] code creates a surface and stores its index in the local variable "surf". It then targets that surface, clears it and draws several sprites on top of each other. Finally it creates a new sprite from the composite image drawn on the surface and assigns its index to "spr_Custom" before freeing up the memory used by the surface.
Code:
var surf;
surf = surface_create(32, 32);
surface_set_target(surf);
draw_clear_alpha(c_black, 0);
draw_sprite(spr_Body, 0, 0, 0);
draw_sprite(spr_Clothes, 0, 0, 0);
draw_sprite(spr_Hair, 0, 0, 0);
spr_custom = sprite_create_from_surface(surf, 0, 0, 32, 32, true, true, 16, 16);
surface_reset_target();
surface_free(surf);