Knew which object was picked among a group

Hello !

I wonder if there is something like a “.this” or “.me” in the list of event ?
Lets says for example that I have a group of 5 buttons, I want a condition to be checked for the group but a result different, depending of which of this 5 buttons has been picked.

I hope I am clear, its not easy to explaine =p

Groups are great for simplifying events. Say you wanted to play a sound when any of the objects was clicked. You can use groupName is clicked

If you then want to do something depending on the button that was clicked, you could use any condition in a subevent like buttonName is clicked or you can use compare two strings with GroupName label text Unfortunately, you can’t just use the condition label text but you can use it as an expression within a compare 2 text condition.

These examples just rotate the clicked button.

(In my example Buttons was a group that had 2 buttons, BlackDecoratedButton1 and BlackDecoratedButton1. The label text was simply “Apple” and “Orange”)

Note: the compare two strings condition doesn’t pick the object but in the previous example the is clicked condition using the group name picks the object and the compare two strings works as the trigger without changing which object is picked.

You can use any condition to check if the clicked button is a certain button. You could also check an object variable or location.

I believe the closest you’ll get to .this with GDevelop is the following. Assuming you have Button State behaviour on each button object in the group, you can use the group is clicked condition, and compare two strings to check the name of the object clicked:

image

Thanks to both of you for your answer.

Seems I cant unfortunaly do what I was expected =p

Here is the details, maybe there is another way or I can still achieve this with what you’ve juste showed me !

In my game, I will have many scenes, with many buttons. All square or rectangle, but with different size.

I want the button to be “animated” when clicked. Usually, for every single button I have, I created a second asset, which is the same but it is lighter.

So when those buttons are pushed, player can see it (I also often add a scale resize to make it “pop”).

But this time, I dont want to double my assets and create loooooots of lighter version of all my button.

So I was wondering if, when a button is clicked, I can created a white sprite, resize it (with the same size that the button, that’is here that I would have need something like this.height and this.width =p) put it in front of my clicked button (this.x() and this.Y()) and make it for example 20 opacity.

So with a single external event of few lines, and can handle the whole game clicking animation …

You can put all of the buttons into a group and give all of them the button behavior. Then use the button group name with the clicked button condition and the clicked object gets picked. Then, any actions, conditions and expressions will use that object. You could also use “mouse released” and “cursor is on object” using the group name.

Instead of placing an object over another object , you could change the opacity or change their tint or use one of the many object effects. If you use a shade of grey with tint then it will darken the none black colors. Using white would remove the tint.

This is one method.

Thanks a lot !
By searching for the extension your were mentioning, it turn out it actually already deal with the thing I was looking for !
So I dont even have to add any conditions or events =p

Nice. I didn’t know there was that extension.

1 Like