I have about 20 tiles inside a group. The tiles are at random positions. I want to save the position of each clicked tile into different variables. I tried:
Condition:
For each instance of Tiles
The cursor/touch is on Tiles
Left button of mouse was released
Action:
Change the sceneVariable posx1 set to Tiles.X()
Change the sceneVariable posy1 set to Tiles.Y()
Of course, it doesn’t work.
Any help on that please?
I think you need to change scene variable to object variable,
Change Tilewhatever.Variable(var_X) = Tilewhateve.X()
Change Tilewhatever.Variable(var_Y) = Tilewahtever.Y()
Otherwise you always get the last tile x/y because is only one variable that you’re changing.
Thanks Slash!
I’m trying to do what you said, but it’s not working, but I wont give it up.
Actually, I used 4 scene variables x1,y1 and x2,y2. In my post I didn’t write down my full code. But it didn’t work.
I tried to use Object Variable too, but no success.
It keeping saving only last click.
I want to save first and second positions to switch the tiles positions when I click the second.
Dynamic structure.
Give each of your tiles an object variable (name) to identify which tile it is.
Then
Whatever your save condition is, put as subevent of it:
Set variable (counter) to 1
Repeat for each tile
→ set variable(Save[variableString(counter)].name to tile.variable(name)
set variable(Save[variableString(counter)].x to tile.X()
set variable(Save[variableString(counter)].y to tile.Y ()
Add 1 to variable (counter)
To place your tile with the structure you do
Condition to load tiles
As subevent:
Set variable(counter) to variableChildCount(save)
Repeat variableChildCount(save) times
→ among objects tiles named variableString (save [variableString (counter)].name) at position (save [variableString (counter)].x) / (save [variableString (counter)].y)
Subtract 1 from variable( counter)
I’m confuse!
Why do I have to use this:
" → among objects tiles named variableString (save [variableString (counter)].name) at position (save [variableString (counter)].x) / (save [variableString (counter)].y)
Isn’t this used to create an object?
I don’t need to create my objects. They’re already on scene. All I need is switch their positions.
I never wrote you have to. I showed how you can use your structure to load your tiles.
why do you want to save the positions?
I was assuming to load them later.
I want to click on first tile, then when I click on the second I want they switch their positions.
I need to save positions, to make the tiles know the positions they should go after second click.
Or not?
wow! I did exactly what you did. My mistake was not setting the change actions as a sub event, so when I was adding 1 to the object variable on top, the code was reading only the second actions because the object variable had already added 1.
I need to pay more attention.
Many Thanks Slash! For your time and kindness!
Have an excellent day and a great weekend!