draw_sprite_ext -> stop overlapping

G

GM_Newbie123

Guest
Hello everyone :)

I am new to GM Studio 2 and I have a problem with the draw_sprite_ext command

I am drawing two sprites with this command:

draw_sprite_ext(shadow_block,image_index,x+32,y+1,image_xscale,image_yscale,0,c_black,.4);

but when these meet each other they overlap and it looks like this:



I want it to be like this:



What do I need to change? Do I need to change sprite settings or the code itself?

Thanks in advance :)
 

TheouAegis

Member
In the Create Event of a control object:
Code:
shadow_surface = surface_create(camera_get_view_width(view_camera[0]), camera_get_view_height(view_camera[0]));
In that object's PreDraw event:
Code:
if !surface_exists(shadow_surface) shadow_surface = surface_create(camera_get_view_width(view_camera[0]), camera_get_view_height(view_camera[0]));
In that object's Draw Event:
Code:
draw_surface_ext(shadow_surface,camera_view_x(view_camera[0],camera_get_view_y(view_camera[0]),1,1,0,-1,0.5) //0.5 is your transparency);
Make sure this object has a high enough depth so that is drawn over the ground layer but under the instances layer.

In the control object's Begin Draw Event:
Code:
with shadowy_objects draw_sprite(shadow_block,image_index,x+32,y+1);
Replace "shadowy_objects" with the object or parent of the objects that will draw block shadows.
 
G

GM_Newbie123

Guest
In the Create Event of a control object:
Code:
shadow_surface = surface_create(camera_get_view_width(view_camera[0]), camera_get_view_height(view_camera[0]));
In that object's PreDraw event:
Code:
if !surface_exists(shadow_surface) shadow_surface = surface_create(camera_get_view_width(view_camera[0]), camera_get_view_height(view_camera[0]));
In that object's Draw Event:
Code:
draw_surface_ext(shadow_surface,camera_view_x(view_camera[0],camera_get_view_y(view_camera[0]),1,1,0,-1,0.5) //0.5 is your transparency);
Make sure this object has a high enough depth so that is drawn over the ground layer but under the instances layer.

In the control object's Begin Draw Event:
Code:
with shadowy_objects draw_sprite(shadow_block,image_index,x+32,y+1);
Replace "shadowy_objects" with the object or parent of the objects that will draw block shadows.
Thanks! :)

but Im getting an error in the draw event:
unknown function or script camera_view_x
 
Top