Hi DUTOIT
I explain with more detail what I want to accomplish.
Now I have the “hard coded” version of the map definition, I mean that I defined for each zone the posibles destinations in “touch event”. Thank you for your tips.
I want that these posibles destinations will be drive through an array. For each zone I have an array with the posibles destinations, so when the user “touch” one zone, I want repeat for each element of their array and change the frame, so maintain the zones connectors will be more easy.
Pseudocode.
Load from an URL or file the JSON of the arrays for each zone.
Zone #A touched
if active=true of Zone #A
repeat for each element X of array #A
Change frame of zone X
Set active =true
end repeat [/code:1r099xrj]
On this way I can update the zones destinations from an array and not by “hard code”
It’s posible do that? how can I refer to a sprite inside the repeat loop?
Can I pass sprite reference to a function?
I read about the UIID but don’t know how pass it?
Salut,
Josep M
Load from json using ajax works perfectly.
sprite.uid / sprite.iid gives you the unique id of the sprite. But I don't like to use this.
My preferred way is to create an instance variable and name each one, that way I can control the assigned number.
And you can retrieve it, condition it, manipulate it etc etc easy enough.
Point is. You can now check against the array.
So if instance variable = to any of the array numbers then sprite frame 2 to highlight possible moves, or whatever.
You need the instance variables to use in conditions, especially when moving pieces, highlighting active/non active etc etc.
UID/IID should never be hardcoded.
So if zones destinations (instance variables) = array possibles destinations then ...[do this, or that]
Don't hold me to this:
But instance var
City Name: London
Zone: 1
Section: 1
City Name: Paris
Zone: 1
Section: 2
Array
Zone1
:: 1
:: 2
Zone2
::1
::2
if zone.zone = 1 (this automatically selects all sections)
if you want specif section, then add another condition if zone.section = 2 (this narrows it down to paris)
So foreach zone...
Condition: zone.zone = 1
change frame bla bla bla