S
stepup2000
Guest
so im making a top down shooter and i wanted to make a blood splatter effect for when you kill an enemy, i did this by making a controller object for the blood. Then when the enemy gets destroyed he makes 25 blood object that each go in a random 360 degree and random speed. Then when the blood object stops i let it transfer his coords to the blood controller to an array, the blood controller then draws blood sprites at the right coords. I do it this way so i can have a lot of blood sprites but it wont hurt the fps that much. But i got an error i dont understand, the error is this:
action number 1
of Draw Event
for object obj_blood_decals:
trying to index a variable which is not an array
at gml_Object_obj_blood_decals_Draw_0 (line 7) - draw_sprite(spr_blood, 0, Blood[0], Blood[1]);
the codes i used are:
obj_blood decals //blood controller
//create
Splatter = ds_list_create(); // Prepare an empty list.
Splatter_Count = 100; // Maximum allowed number of items on the list.
//clean up
ds_list_destroy(Splatter);
//end step
if(ds_list_size(Splatter) > Splatter_Count){ // If more than allowed amount of items on list
do { // Start a loop.
ds_list_delete(Splatter, 0); // Delete the oldest list item, which is at position zero. This moves the remaining entries up by one step, so second-oldest will be at position zero after this.
} until(ds_list_size(Splatter) <= Splatter_Count); // Keep looping until list only has allowed amount.
}
//draw
for(var i = 0; i < Splatter_Count; i++)
{
var Blood = Splatter[| i];
if (Blood == -1) show_debug_message("illegal entry");
if (!is_array(Blood)) show_debug_message("not even an array");
draw_sprite(spr_blood, 0, Blood[0], Blood[1]);
}
obj_blood_splatter //blood object
//create
speed = random_range(0, 15)
direction = random_range(0, 360)
alarm_set(0, 10);
//collision with wall
// When the blood splatter stops:
My_Position = []; // Create an array.
My_Position[0] = x; // Store x position to first slot.
My_Position[1] = y; // Store y position to second slot.
ds_list_add(obj_blood_decals.Splatter, My_Position); // Add the array into the control object's list.
instance_destroy(); // The blood instance is no longer needed now.
action number 1
of Draw Event
for object obj_blood_decals:
trying to index a variable which is not an array
at gml_Object_obj_blood_decals_Draw_0 (line 7) - draw_sprite(spr_blood, 0, Blood[0], Blood[1]);
the codes i used are:
obj_blood decals //blood controller
//create
Splatter = ds_list_create(); // Prepare an empty list.
Splatter_Count = 100; // Maximum allowed number of items on the list.
//clean up
ds_list_destroy(Splatter);
//end step
if(ds_list_size(Splatter) > Splatter_Count){ // If more than allowed amount of items on list
do { // Start a loop.
ds_list_delete(Splatter, 0); // Delete the oldest list item, which is at position zero. This moves the remaining entries up by one step, so second-oldest will be at position zero after this.
} until(ds_list_size(Splatter) <= Splatter_Count); // Keep looping until list only has allowed amount.
}
//draw
for(var i = 0; i < Splatter_Count; i++)
{
var Blood = Splatter[| i];
if (Blood == -1) show_debug_message("illegal entry");
if (!is_array(Blood)) show_debug_message("not even an array");
draw_sprite(spr_blood, 0, Blood[0], Blood[1]);
}
obj_blood_splatter //blood object
//create
speed = random_range(0, 15)
direction = random_range(0, 360)
alarm_set(0, 10);
//collision with wall
// When the blood splatter stops:
My_Position = []; // Create an array.
My_Position[0] = x; // Store x position to first slot.
My_Position[1] = y; // Store y position to second slot.
ds_list_add(obj_blood_decals.Splatter, My_Position); // Add the array into the control object's list.
instance_destroy(); // The blood instance is no longer needed now.