Hey everyone D
GDevelop is just AMAZING For the moment all i want to do, i can do it
(Sorry if my english is not perfect i’m french)
So, i have a little question about Set an animation of an object in my scene, but i want have the name of the object in a variable and execute it…
Example some object on my scene :
So i try to do this on my events :
Set animation of btn_+ToString(Variable(Num_Btn)) to "example_animation"
But i can’t write a variable on this, i can on Change scene, but not here…
Maybe i have to write it with difference syntax?
(The objectif is make a repeat for each button of level and test if the player have finish it or not, so if yes btn_x with x_animation if not btn_x with y_animation, so level_1 → btn_1 → animation, etc etc)
I can write it for each but when i have 50 levels… ouch ^^" A solution?
Hope you understand me ^^"
Cia and enjoy
On this screenshoot, i have try 2 syntax at the right, it’s not work (the code at the left work)
I’m pretty sure I tried to do this to when I first started and it doesn’t work for Object references.
I believe you can only do this for Variable references.
So what I would do is separate your logic into different parts:
1 - Some event that triggers an animation change, then you set a variable structure like “BoxWorldButtonAnimations[VariableString(Box_World_Actuel)]”. Also set some flag like “AnimationUpdated = 1”
2 - Have a second block of logic that only activates when “AnimationUpdated == 1”. The first thing it does is set “AnimationUpdated = 0” then it loops across all buttons and updates each one’s animation to be equal to the value stored in “BoxWorldButtonAnimations” structure. Optionally as an optimization, only update the animation if the value in the structure is different from the current animation.
Hope that makes sense from a design perspective.
You cannot use variables as object names, as an exact object name is required for compiling the game by the code generator. Instead, you should use one Button object and an instance variable to differentiate each button: https://twitter.com/arthuro555/status/1351199566520086528?s=19
Hey Krunkster & Arthuro555, thx for your answers
Okay i see, I will try to do that ^___^
Your video is perfect it’s help me more than i expect !