darkly
Member
I am trying to implement a depth system in a top down, four-directional movement game. I have a room with a player object and a few box objects placed about. Both objects are tied to a parent 'depth object' with visible = false; in the create event and draw_self(); in the draw event.
I then have a separate depth sorter object with the following:
Create Event:
Clean Up Event:
Draw Event:
When trying to run the game, I am hit with the 'trying to draw non-existing sprite' error, in the parent objects' draw event called from the above //Loop section of the depth sorter object's draw event. If I remove the //Loop chunk of code in the above draw event, things seem to be working (albeit with no actual effect) as the debugger shows the ds_grid pulling and sorting variables correctly. The error appears even I remove all instances (player + boxes) in the room editor, so while I don't believe the issue is in the code of these objects, I'm happy to share it if it could help solve the issue.
Been stuck for a minute, any thoughts? For reference, the depth system is based on the following tutorial from FriendlyCosmonautl:
I then have a separate depth sorter object with the following:
Create Event:
Code:
ds_depthgrid = ds_grid_create(2,1);
Code:
ds_grid_destroy(ds_depthgrid);
Code:
//Resize Grid
var dgrid = ds_depthgrid;
var inst_num = instance_number(par_depthobject);
ds_grid_resize(dgrid,2,inst_num);
//Add Instance Info to Grid
var yy = 0; with(par_depthobject){
dgrid[# 0, yy] = id;
dgrid[# 1, yy] = y;
yy++;
}
//Sort Grid in Ascending Order
ds_grid_sort(dgrid, 1, true);
//Loop
var inst;
yy = 0; repeat(inst_num){
//pull out id
inst = dgrid[# 0, yy];
//draw self
with(inst)
{
event_perform(ev_draw, 0);
}
yy++;
}
Been stuck for a minute, any thoughts? For reference, the depth system is based on the following tutorial from FriendlyCosmonautl: