Unique instance names

Hi guys!
So far, in my games, I have made new objects for every sprite in Photoshop and imported them with unique names. But if I want to have loads of unique sprites, say 10-50 sprites that look exactly the same it feels like a waste of time and game resources to have so many imported objects that graphically are identical with each other.

Would it be possible to have one object and make every sprite from that object on the scene totally unique with its own name?

For example if I have an object called “button”. When I drag it to the scene I can rename that instance to “play_button” and the next time I create an instance from the object “button” on the scene I can rename that specific instance “pause_button”. In my case I want to create a general button called “rotate_object” and apply many instances of that button to many different objects that I want to rotate on the scene.

Thanks

Farid

If you put an object in the scene, click on it once.
The property window of that object appears on the left.
In this window you can give your object a unique variable.
Then you can have the event mouse is on button
With all your different buttons as subevents
variable (nameofthevariable) of button = your text/number
Do your actions.

That seems like a workaround for a missing feature, but I’ll try that from now on. Thanks Slash for your help :slight_smile:

Cheers

Farid

1 Like

It’s not a workaround, it’s the way of handling specific instances in GD.

The way you want it to work is basically the same, by giving it the variable name
If it would not, you would create new objects and that would be, what you are trying to avoid.

Hi again,
I’m sorry but I don’t really understand. I have created 18 instances of the button on the scene. They all have an object variable called “ButtonNumber”. Each of the instances have a value for “button” with numbers from 1 to 18.

Now when I want to place them on the correct coordinates on the scen I don’t know how to call them. I can’t find an action that lets med point at an instance with a specific variable number such as "Put RotateButton with ButtonNumber=3 around myObject.

How do add an action to a specific instance?

Thanks

Farid

is part3 your bottons?

to specify your objects, you just add the condition:
Variable(ButtonNumber) of button = //put your button number here to specify which button//

it feels like a waste of time and game resources to have so many imported objects that graphically are identical with each other.

Indeed, that’s not necessary.

GDevelop uses object filtering, and you’re supposed to be able to target logically the instance you want, because of its position, because it’s in collision with another object, because it has such variable, etc.

In your case, if each object should have a rotate button, use the Link instructions to associate each button to its object:
image

No, part3 is the object that the button (Rotate_button) should be attached to. When I start the scene there are no visible Rotate_button’s. They are attached and visible to their objects (part1, part2, part2 etc) when the objects are touched and only then. So there is no button to touch before the object is “activated”.
What I am trying to do is a puzzle. Every puzzle piece (partx) is draggable and has no visible rotation button. The rotation button is only visible for the currently selected puzzle piece.

But is that really possible? I have 15 unique objects (puzzle pieces) and 15 identical buttons that should be attached to each puzzle piece. If I use “for each” it will create a link between two identical ojbects. Like for each instance of “button” create a link to each instance of “puzzle”. But there are 15 totally different puzzle pieces. I still don’t understand how to do that. Sorry :frowning:

Do it with a foreach or create the objects with Repeat at the beginning of the scene

Thanks everyone for trying to help. This became too complicated, so I chose another solution. I created one single instance of the Rotate_button that I move around instead, depending on which puzzle piece that is active. It’s a pity that you can’t just rename instances of objects to make them unique. Once again, thanks for helping!

Farid