I have the different objects named as following:
Point0
Point1
Point2
Point3
Point4
…
Point100
and all objects have been dragged to the scene editor
Now, I want to create a variable called PositionX and PositionY and save the object name along with x position and y position.
In debugger scene variable PositionX=Point0.X() is shown.
Now, I want to pass this value in Draw as start X and start Y.
Thank in advance.
reina
March 9, 2020, 2:03am
#2
That looks fine, except it’s using unique objects than dynamically generating variables.
Oh, that’s actually your topic title! Then…
You can refer to objects name dynamically using structures:
http://wiki.compilgames.net/doku.php/gdevelop5/all-features/variables#structure_variables
I’ll explain some of it.
You can refer to Point0.X() as Point[Variable(i)]X and it will become Point.0.X in the debugger.
Another example, for 2D array, and for string.
reina:
Point[Variable(i)]X
This seems to give error. Do you mean to use this, I need to first create a structure and then use this? I’ll try though. Thank you for the reply.
reina
March 9, 2020, 8:21am
#4
Yeah, try to initialize the variable first, and then check the value in Inspector: It should contain something like dropdown menu for the variable Point. (if not, try other experiment with structure variable first)
Welcome and feel free to ask more!
1 Like