• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[Solved] Getting a blank (transparent) sprite strip from surface?

W

whale_cancer

Guest
Edit2: It was just a matter of accidentally putting x,y for the surface coordinate rather than 0,0...

Edit: Narrowed it down a bit. Doesn't appear the sprite is drawing to the surface at all...

Update code:
Code:
default_string = string_replace(global.rom_fname,".nes","_p")
default_string = default_string + string(global.page) + ".png";

global.search_image_fname = get_string("Search_image_fname to load? All images must be contained in the 'strips' folder. Processed strips are saved in 'strips_processed'",default_string);
temp_sprite = sprite_add("strips/"+global.search_image_fname,0,false,false,0,0)

surf = surface_create(sprite_get_width(temp_sprite), sprite_get_height(temp_sprite));
show_debug_message("creating surface of size "+string(sprite_get_width(temp_sprite))+","+string(sprite_get_height(temp_sprite)));
surface_set_target(surf);
draw_sprite(temp_sprite,0,x,y);
sprite_save(temp_sprite,0,"strips_processed/"+"surface_"+global.search_image_fname);
sprite_save creates the sprite correctly, but..
Code:
surface_set_target(surf);
draw_sprite(temp_sprite,0,x,y);
...does NOT draw the sprite (I am now outputting the surface directly for debugging):
Code:
if(surface_exists(surf)){
   
draw_surface(surf,128,256)
draw_text(128,256,"EXISTS");}
else
{
    draw_text(128,256,"NOPE")
}
Anyone?

Original post:

Hello!

I am creating a surface and then attempting to chop it up into a sprite strip. I am pretty comfortable with surfaces and use them a lot in my main project, but this unrelated utility I am writing has got me confused. My code successfully loads an image and turns it into a sprite (I know this as I output the sprite for debugging). However, when I output the sprite strip itself I just get a big blank strip. What am I doing wrong?

Any idea? Thanks!

Code:
/// @description turn an image into sprite strip (which can later be turned into a .txt file)
global.search_image_fname = get_string("Search_image_fname to load? All images must be contained in the 'strips' folder. Processed strips are saved in 'strips_processed'","smb_3p31.png");
temp_sprite = sprite_add("strips/"+global.search_image_fname,0,false,false,0,0)

surf = surface_create(sprite_get_width(temp_sprite), sprite_get_height(temp_sprite));
show_debug_message("creating surface of size "+string(sprite_get_width(temp_sprite))+","+string(sprite_get_height(temp_sprite)));
surface_set_target(surf);
draw_sprite(temp_sprite,0,x,y);
sprite_save(temp_sprite,0,"strips_processed/"+"surface_"+global.search_image_fname);

temp_sprite_strip = sprite_create_from_surface(surf, 0, 0, 8, 8, 0, 0, 0, 0)

for (var j = 0; j < sprite_get_width(temp_sprite)/8; j += 1)
{
    for (var i = 0; i < sprite_get_height(temp_sprite)/8; i += 1)
    {
        if(i==0)&&(j==0) {};
        else { sprite_add_from_surface(temp_sprite_strip, surf, j * 8, i * 8, 8, 8, 0, 0);
        show_debug_message("attempting to add 8x8 tiles located at "+string(j)+","+string(i)); }
    }
}

sprite_save_strip(temp_sprite_strip,"strips_processed/"+global.search_image_fname);
surface_reset_target();
show_message("Done!");
 
Last edited:
Top