• 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 surfaces not working

anima

Member
Hi!

so i wanted to mess around with surfaces for an UI and it dint work
it dint draw the surfaces i tried following a tutorial that worked right before but now it just doenst work

it doesnt draw the surface please help.

CODE:
GML:
if surface_exists(surf){
   surface_set_target(surf)
   draw_sprite(sprite1,0,mouse_x,mouse_y)
   surface_reset_target()
 
}else{surf=surface_create(640,360)
surface_set_target(surf)
draw_clear_alpha(c_black,0.75)
surface_reset_target()
}
 
Last edited:
What you're doing is the equivalent of opening a door, closing it, and then wondering why you're still in the same room. You may be drawing to the surface, but you're not actually drawing the surface itself.
 

Binsk

Member
Surfaces do not get rendered to the screen automatically; there are plenty of uses for surfaces where you wouldn't want that.

Just like you call draw_sprite() to draw a sprite, you need to actually call draw_surface() to draw the surface once you are done drawing on it.
 
Try this
GML:
if !surface_exists(surf){
    surf = surface_create(640,360)
    surface_set_target(surf)
    draw_clear_alpha(c_black,0.75) 
    draw_sprite(sprite1,0,mouse_x,mouse_y)
    surface_reset_target()
}

draw_surface(surf, 0, 0);
 
Top