Show and hide problem

I use some pictures to show and hide one by one, I do that with buttons, But I’m forced to put some buttons in the same area that the pictures are in, The button in the same area don’t work, I tried with layers, Z order but I still fail to make it work.
Here is a picture of my events.

The button called NewSprite is in the same area with pictures, So it doesn’t work, Other two buttons work correctly.

I wish somebody helps me…

I really want to help you, but I need more information.
You say this works with one button, AND that the other two buttons work fine. But I count 6 buttons.

“But I’m forced to put some buttons in the same area that the pictures are in, The button in the same area don’t work” ? What does that mean? Your problem seems simple enough, but can you try being more specific please? Edited: Oops, @olivers I just read your post right now.

Do a test deleting that image. To confirm whether the button works or not. Or to know if the problem is the image.

The show and hide events are activating on the same frame, because the conditions are true for both. Hidden objects are still checked for collisions. So if NewSprite and NewSprite7 are in the same area, the order of the events has NewSprite7 being hidden as the last action. I’d recommend using an event that checks if NewSprite7 is visible, and then taking action from there. One way could be:

This sets it so it only checks for collision with the button or image once total, instead of once for each. It then sets a boolean to false, so we can use it later to ensure it happens once. The sub events then check what visibility NewSprite7 already has, and sets it to the opposite, as well as setting the variable to true so any following events won’t also activate.

1 Like

Thank you a lot, I will try it, I think you are right.

No, it didn’t work, I tried many!

No, it isn’t simple, Try it yourself.

I tried it just now but it canceled show event.

If I may, it looks to me like you have three buttons, and each are assigned a corresponding picture to show. I believe dijondude’s events would have worked, but I’m just on my phone at the moment and unable to test stuff. Though here’s what I might probably do:

For NewSprite,

NewSprite7 is not visible
Cursor is on NewSprite
Mouse is released
(Maybe Trigger Once here too)
Action: Show NewSprite7

NewSprite7 is visible
Cursor is on NewSprite7
Mouse is released
(Maybe Trigger Once also)
Action: Hide NewSprite7

And yeah, I’d then do the same with the other buttons and pictures.

On a side note, might I suggest you give the buttons and images names that would be a bit more recognizable? But it’s totally up to you, of course, if you’re more comfortable with the names they have now.

1 Like

Hello i know that im late but i have a theory.Maybe its because of your event in hiding the sprites.
Try this:
Cusor is on sprite
Left button released → hide sprite
Sprie is visible

X is hidden at the beginning, So how we could make the cursor on it?

I used a button to resolve this issue, Another button I mean, It’s work is to make all pics hidden “as a group”. Guys, the problem is some buttons were on the pic that were hidden.

Pics show and hide

So I tested your events and it appeared to be something to do with the order of events. You need to put the “hide” events first and then the “show” events afterwards. By the way, in my tests the pics are on the base layer and the buttons are placed on an interface layer above it.

and if you also wanted to hide the buttons it still works okay like so:

If that’s still not what you have in mind, I guess we may need help from the pros.

On a side note, there are animated buttons you can use in gdevelop. Just scroll down a bit when adding a new object. Though, I used a static image for the buttons in my example since it seemed to me it was also what you were using. Just thought you might like to know…

1 Like

Great job, It worked with me, Thank you my dear.

1 Like