I’m working on a map editor (without the tilemap extension → mobile game). The scene consists of two layers: The “Base Layer” and a “hud” layer. On the Head up Display layer to the left of the screen there is a column (width = 32pixels) of available tiles the user can select as the brush for painting onto the map on the layer below. These tiles all belong to the object group “grpTileSet”.
Selecting a brush tile and painting it onto the scene works. I can also erase a tile by hitting the right mouse button on it.
The only thing I cannot get to work is replacing a tile in the scene with another. The culprit seams to be line 2.2.
I try to delete the old tile that is under the mouse pointer and immediately afterwards add the new tile to that location. But all that happens is that a tile flashes up for an instance at the right location and is deleted right afterwards even though I delete the tile before adding the new one.
I have tried different things but somehow it doesn’t work. Am I thinking the wrong way?
This is my Logic setup:
Thanks for your help.
Did you try this, because it works for me :
Thank you, this really works.
Didn’t think that I have to explicitly tell the engine that the cursor mustn’t be on the group object when creating a new instance. It even works and adds a new one when you remove the “create object” right under the delete object statement.
I have to admit that I don’t understand why It works this way. When the old object got deleted there shouldn’t be an object in that cell anyway.
Surely it has to do with the Trigger Once condition, it can become complex if used everywhere
In your original image, the event 2 is launched while the left click is hold (every frame), then it deletes a tile if there is one under the cursor and creates a new tile.
In the next frame (hold the click only one frame is difficult) the event 2 will be launched again.
The sub-event 2.2 will be launched too (not sure, but the condition is false for a while, and the tested object is new too), and the tile created in the previous frame will be deleted.
Finally the sub-event 2.4 will not be launched, the conditions for this trigger once (left click at X>32) has not changed.
So, to solve it, ensure the entire event is launched only one time, as Kaiagan suggests, with a trigger once in the main event. The extra trigger once’s in the sub-events are not needed, I think. The inverted condition to check that there is no tile under the cursor is not needed too, if there was a tile, it was deleted in the previous sub-event, so this condition will be always true
I see, thanks for explaining.