GameMaker draw surface over sprite

Z

zendraw

Guest
i want to draw a surface over a sprite in a way that the sprite`s alphas are applied to the surface so the surface is like cut based on the sprite. i have some code from before that doesnt work now for some reason.
GML:
draw_self();

if (surface_exists(surf))
{
    draw_surface_ext(surf,
    x,//+lengthdir_x(coordx, coorddir+image_angle),
    y,//+lengthdir_y(coordx, coorddir+image_angle),
    1, 1, image_angle, -1, 1);
} else
{
    gpu_set_colorwriteenable(true, true, true, false);

    surf=surface_create(320, 320);
    surface_set_target(surf);
    draw_clear_alpha(c_black, 0);
    
    draw_sprite(surface, 0, coordx, coordy);
    
    surface_reset_target();
    
    gpu_set_colorwriteenable(true, true, true, true);
}
 
Try setting the gpu_set_blendmode to subtract and then draw the player sprite at the player's location.
Haven't worked with surfaces in a while, so I'm not sure if this will work.
 

rytan451

Member
Here's an idea:

GML:
gpu_color_write_enable(false, false, false, true);
gpu_set_blendmode_ext_sepalpha(bm_zero, bm_one, bm_one, bm_zero);
draw_sprite(spr_something, 0, coordx, coordy);
gpu_set_blendmode(bm_normal)
gpu_color_write_enable(true, true, true, true);
 
Z

zendraw

Guest
have you tested it? i will test it when i get to it but am busy atm.
 
Top