Is it posible to read the number of the animation from a sprite, transform it to a string and add it to the expresion Change to "Level "+ StringAnimationNumber?
SOLVED Quick Answer: (Thanks to @UlisesFreitas)
"Level " + ToString(Level_button.Animation())
My case explained:
I’ve been using gdevelop for only a few weeks and I don’t have previous programming experience. Until now, I’ve been able to move forward with the wiki, your posts and youtube videos but I feel stuck with this.
I’ve done a scene to choose levels that works well:
- There are sprites (text) for every number and when you click on a number it goes to the indicated level.
This way, if I had 100 levels, I should include 100 lines, so I’m trying to think a more eficient way to automatise and create only one condition that changes for whatever be the number of the level.
Mi first idea has been:
I’ve create a sprite called “Level_button” with different animations where the animation #1 is an image of a number1, #2 is a number2, etc
In the events I want to replace: Change to scene “Level 2” for something like
Change to scene "Level " + AnimationNumber.Level_button
I don’t know if this is even posible or how to write it properly.
My second idea has been:
Create an object variable and assign it a value for every instance that is the number of the image
In the events: Change to scene "Level " + Level_button.VariableString(Nivel)
This way it works, but I still feel that it could be more automatic than change manually every value of the instance variable if is the same that the animation number.
Additionally, with theses changes I lose the versatilty of the text objects because I can’t give them different “animations” (as an image sprite).
Any idea of how could implement this idea with a text sprite?
Thank you for your time!