E
E.M.I
Guest
Hey GameMaker Community! I've been working on a top-down game and have run into an issue with the depth system. I have two scripts that seem to be causing this error: scr_create_draworder, which creates the draw_order and draworder_size variables I'm using to store the grid size, as well as the i variable, used to adjust the size of the depth grid according to the values of the draworder_size and draworder_size variables. Here's the code:
Then you have the scr_draw_draworder script, which actually draws the objects. Here's that code:
The problem is, all the uses of the i variable in scr_draw_draworder return the "Trying to draw non-existing sprite" error (specifically the uses in line 21). Anyone have any idea of what's going on? Thanks in advance!
Code:
/// scr_draw_draworder();
// draw everything in the draworder
for(var index = 0; index < global.draworder_size; index++){
// search list for appropiate Y!
var l = global.draworder[# 0, index];
var count = ds_list_size(l)-1;
//check, if instances in list
if (count >= 0){
while(count >= 0){
// target instance
var i = ds_list_find_value(l, count--);
if (i.subtype = "z-axis"){
draw_sprite_ext(i.sprite_index, i.image_index, i.x, i.y-i.z, i.image_xscale, i.image_yscale, i.image_angle, i.image_blend, i.image_alpha);
} else {
draw_sprite_ext(i.sprite_index, i.image_index, i.x, i.y, i.image_xscale, i.image_yscale, i.image_angle, i.image_blend, i.image_alpha);
}
}
}
}
Code:
/// scr_add_draworder
var cam = view_get_camera(0);
if (argument0.y > camera_get_view_y(cam)+600) return false;
if (argument0.y < camera_get_view_y(cam)-250) return false;
if (argument0.x > camera_get_view_x(cam)+600) return false;
if (argument0.x < camera_get_view_x(cam)-250) return false;
// add offset to instance.y
var yy = round(argument0.y)+DO_OFFSET;
// if out of bounds, don't add
if (yy < 0 or yy >= global.draworder_size) return false;
// search list, which is needed
var list = global.draworder[# 0, yy];
// add to this list
ds_list_add(list, argument0);
return true;
Last edited by a moderator: