• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker [Solved] Question: One Layer, Multiple Instances with different depth?

K

Konstamonsta

Guest
Edit 1:
As far as i can tell layers work in a way that they have a fixed depth and only can contain instances with that depth. As a result creating instances on a layer has little effect when you change the depth of them afterwards.
To work around this i created a global variable which i made an array and upon creation of my instances i feed the id into the array.

Example code:
Code:
objID = instance_create_layer(mouse_x,mouse_y,Instances,obj_Fabrik);                
my_array[array_length_1d(my_array)] = objID;


for (var i = 0; i < array_length_1d(arr_kraftwerke); i++)
    {        
        var inst = arr_kraftwerke[i];
        if instance_exists(inst)
        {
            var stat = inst.status;
            var val = inst.value;
            if stat != "new"
            {
            earnings += val;
            }    
        }   
    }

My question is as the title says. I want to have many instances of an object all collected on the same layer for iteration purposes using "layer_get_all_elements()"
However when i place these objects during runtime the sprites overlap each other in a way that doesn't look natural.
I want the Sprites to be displayed with a depth to them that would be expressed like:
depth = -y/64;
However using this rips the objects from their collective instance-layer.
Is there a way to handle this?

Alternatively is there a smart way to get all instances of a specific object no matter the layer?
 
Last edited by a moderator:
Top