SOLVED Trouble overlaying an object's sprite onto another object.

I am trying to make an object's sprite overlay its self onto one of another object, the latter object should change size. However, I am having two problems:

The first object is rendering below the object it should be overlaying.
The second object does not change size at all.

My objects are set up as such:
The first object (objMaskTestObject), which is supposed to project on top of the second object:
Create Event
GML:
depth = -100;
Draw Event
GML:
if(surface_exists(objMaskTest.keySurface)){
    surface_set_target(objMaskTest.keySurface);

    gpu_set_colorwriteenable(1, 1, 1, 0);
    draw_sprite(sprite_index, image_index, x, y);
    gpu_set_colorwriteenable(1, 1, 1, 0);

    surface_reset_target();
}
The second object, which should increase in size but does not.
Create Event
GML:
keySurface = -1;
circleExpansion = 0;
depth = 10;
Step Event
GML:
circleExpansion += 0.1;
Draw Event

GML:
if (!surface_exists(keySurface)){
    keySurface = surface_create(room_width, room_height);
}

surface_set_target(keySurface);

draw_sprite_ext(sprite_index, image_index, x, y, circleExpansion, circleExpansion, 0, -1, 1);

surface_reset_target();
draw_surface(keySurface, 0, 0);
I am unsure what is wrong with my code. The first object is drawing, it is just below the second and I have no idea why (you can see it if you change the alpha value on the second object's draw_sprite_ext), and the size of the second object does not visually increase whilst in the same room as the other object. I tried to make it versatile so I could have multiple of the first object drawing over the 2nd, which is why I didn't lump all the draw code into one object.
 

TheouAegis

Member
They are drawn in the wrong order because the surface only gets drawn after the objMaskTest has gotten a chance to draw. So even if the other object draws to the surface, only what is on the surface right after objMaskTest gets shown. Draw the surface in another event or another object.
 
They are drawn in the wrong order because the surface only gets drawn after the objMaskTest has gotten a chance to draw. So even if the other object draws to the surface, only what is on the surface right after objMaskTest gets shown. Draw the surface in another event or another object.
Thank you! That has solved the issue of the draw order, but for some reason I still cannot get the circle to increase in size.
 
Thank you! That has solved the issue of the draw order, but for some reason I still cannot get the circle to increase in size.
ahaha!! I've solved what was preventing the circle from changing size! It was a small oversight on my part, I forgot to change the alpha on gpu_set_colorwriteenable back to 1. Thank you for your help! :)
 
Top