Drawing game, backspace button

Hello community :sunglasses:

I want to put a backspace (or delete) button on this drawing game but I don’t know how to do it… The drawing functions are quite dark for me :smiling_imp:

Thank you for your help again

This is the link of the game :
https://games.gdevelop-app.com/game-9d9210ad-953c-4b1b-9a7f-872061d18f22/index.html

To download the game :
https://we.tl/t-YmZE1oIM1B

The easiest effect you can hope to achieve is to have an ‘Undo’ type action. The lines themselves don’t have a hitbox, and aren’t subject to a collision detection (someone correct me if I’m wrong on this one). So deleting lines or line segments isn’t a simple option to implement at that.

Highlighted below are the extra conditions and actions to your current events needed to achieve this. you’ll also need to add a scene variable ‘CurrentId’.

2 Likes

Thank you very much for this answer,

It works very well when I move the cursor over the return button but when I replay the event: “Touch or Left mouse button is down” it doesn’t work anymore…

Here is the link of the game :
https://games.gdevelop-app.com/game-bf8683cf-1a82-4dfe-92cf-9a3247bd4474/index.html

1 Like

The problem is that when you click on the undo button, the very first event also fires on the next frame as you’ve just started a new touch or mouse button down event. So the variable CurrentId is getting decreased and then immediately increased.

The solution is to add another condition to your first event, checking that the mouse/cursor isn’t over the NewObject3 (and as an aside, I suggest you give the objects decent/descriptive names. It took me a while to realise what NewObject3 is and what it’s supposed to be)

Also, the check of “The variable Id of NewObject = Variable(CurrentId)” in the second to last event can be removed. Just checking “NewObject is clearing its rendered image between each frame” is enough (and again, give NewObject a descriptive name).

Thank you again for this more than quick answer! :pray:

I have entered the extra conditions and it works perfectly.:heart_eyes: Thank you very much for your help. I will stop asking you :sweat_smile:
I changed the names of my variables, it’s true that they were not explicit.


It’s the game link :
https://games.gdevelop-app.com/game-b03ee7ba-837b-410e-9180-8242983b47f1/index.html?fbclid=IwAR0y85rUjwsVRDM1ni6-0AzvmgLKOu3F6VJ6eZpOxIeZjQH0mmUo_76MYCQ

Don’t stop asking - research it first, and if you still don’t understand, then ask. Sometimes the answer is right under your nose and you can’t see it, in which case asking for help gets other sets of eyes that may spot something you overlooked.

2 Likes

Hi!

I was trying to implement a back button in the drawing template following this thread but I see that in the template the lines become a single sprite.

Will it be possible to implement a back button with these conditions?

Instead of resurrecting an old thread, please start a new one.

3 Likes