[SOLVED]Draw all instances in the respective room???

cowpow

Member
Hi guys!
In the process of creating a debug overlay and Im stuck. I want to draw text of all the instances that are in a room, and once the room switches itll switch to the instances in that room.
Im having trouble finding the instances?
This is what I have so far.
GML:
function test()
{
    var str = " "
    var split = "\n"
    var p = layer_get_all_elements("Instances")
    
    for(var i - 0; < array_length(p); i ++)
    {
        if(layer_get_element_type(p[i])) == layerelementtype_instance
        {
            str += string(i) + object_get_name(p[i])
            str += split
            draw_text(200, 200, str)
        }
    }
}
And then Im calling this in a draw triggering event. All its doing right now is printing random instances? Not the instances in the specific room. How would I go about doing that?
 

cowpow

Member
Nevermind! Kindaish solved it myself.

GML:
 var str = " "
 var split = "\n"
 var number = 0
 
 with (all)
 {
     str += string(number) + object_get_name(object_index);
    number ++
    str += split
    draw_text(instanceNames)
 }
 
Top