In the specific case, I want to delete all objects that are standing over another object. To do so, i was thinking to create a specific layer and delete all those objects (the layer created obviously will stay above the object’s layer). So, can you help me to figure it out? Thanks in advance!
If there are multiple objects then you can put them in an object group, check the layer they’re on and then delete them.
This solution seems like it would work well.
And what to do if, for this solution suggested, i want to dynamically add an object to a group? In example, if i click a button a create an object on a layer, then i want to remove that object Just created of that layer… How to do so? I shoiuld add this object Just created to a group and then remove the object/group from the layer, or there Is a Better solution? Thanks in Advance!
You’ll need the object to be a member of the group at design/edit time. You can’t add objects to the group during execution time.
The solution @Keith_1357 gave you is the best one given for GDevelop. It’s a trade off between ease-of-use and flexibility.
Thanks a lot guys, i’ll go to try it
An object group is a list of objects. As you add and remove instances from a scene you can pick them either by the object’s name or the name of the group the object is in.
If you only want to delete the most recent object then you could use an object boolean like IsPlaced. The default value would be false. So, you could use the condition of boolean is false then the action of delete object. Once you no longer want to delete the object Boolean to true
This example adds an apple when the mouse/touch is released. Before you add an apple it sets all the existing apples to placed. When a new apple is added the default value is false. When the button is clicked, the last apple gets deleted.
This might not be what you need but I was intrigued a bit. This uses a counter and deletes the objects by it’s value. It’s sort of like an undo.
I guess you could actually skip the counter and use the count of instances.