Sam04
Member
So I created a sequence and added it to a room in an asset layer. Now I want to change some stuff in code during runtime... but I do not know how to reference it.
Well, mostly it is a question about instance's names. According to the manual, the name can be used to access a specific instance:
I currently have the workaround in which I use "layer_get_all_elements()" and iterate through each of its elements to check with "layer_get_element_type()" if they are a sequence and, if they are, check if they have the name of the sequence I'm interested and only then I have the reference to modify the sequence I'm interested. But keep in mind this is only a workaround, not a solution; and definitely not ideal if assets names could be used as references in the same way instances names can.
Anyone has any idea about that? Is it an IDE bug?
Thanks.
Well, mostly it is a question about instance's names. According to the manual, the name can be used to access a specific instance:
I've used this before and it works as expected. The problem, however, lies in the assets layer (which is in the same link) that reads:However it's worth noting that the name given here (whether it's one you give, or the default one that the IDE gives) is considered a constant and so must be unique to the instance. This also means that it can be used in code n your game to identify the instance, but only if you are in the same room as the instance.
It doesn't say anything about using it as a constant to reference it later. Which seems to be for a reason. I tried to do some debugging with a sequence name but every time it would crash with an error about that name not existing (not that it is a valid reference to an invalid thing, but an invalid reference at all, i.e. an undeclared variable). I have tried accessing it through the room creation code and through an object within the room (inside a key press to make sure all the initialization is already completed) and in both cases it doesn't recognize the name at all.From here you can give the asset a unique name, set whether it is to inherit from the parent room, or change the sprite or sequence that you want it to display.
I currently have the workaround in which I use "layer_get_all_elements()" and iterate through each of its elements to check with "layer_get_element_type()" if they are a sequence and, if they are, check if they have the name of the sequence I'm interested and only then I have the reference to modify the sequence I'm interested. But keep in mind this is only a workaround, not a solution; and definitely not ideal if assets names could be used as references in the same way instances names can.
Anyone has any idea about that? Is it an IDE bug?
Thanks.