When I read the tutorial on using json to make config files my first reaction was that I would end up with lot’s and lot’s of json files.
Now, i’m not an expert on json and correct me if my code is wrong but can’t I just do it like this instead?
In this first file I set it so it reads from a physics file made with physicsEditor.
enemies.json
{
"dog":{
"physicsFile":["enemyPhysics.json"] -- physicsEditor file.
"score": 25,
"hitPoints": 2,
"sounds":["bark\_1.caf", "bark\_2.caf", "bark\_3.caf"]
},
"cat":{
"physicsFile":["enemyPhysics.json"] -- physicsEditor file.
"score":15,
"hitPoints":1,
"sounds":["cat\_1.caf", "cat\_2.caf"]
}
}
Or something similar but for objects without using physicsEditor.
objects.json
{
"woodBox":{
"properties":{
"bodyType":"static",
"bounce":1.0,
"friction":0.5,
"density":1.0,
"isSensor":false
},
},
"ironBlock":{
"properties":{
"bodyType":"static",
"bounce":0.0,
"friction":1.5,
"density":10.0,
"isSensor":false
}
}
}
If I would do it something like this then I would only have a few .json files or if I wanted to add everything into one large file however that would be very painful to edit.
But anyways, it seems like having files for objects, enemies, collectibles and player would be a good solution.
What it I just trace the shape with PhysicsEditor and set all values to 0, does lime override those values if I set the properties manually in the objects.json file?
Overriding the objects properties manually;
objects.json
{
"woodBox":{
"properties":{
"physicsFile":["objectsPhysics.json"] -- physicsEditor file for tracing only
"bodyType":"static",
"bounce":1.0,
"friction":0.5,
"density":1.0,
"isSensor":false
},
},
"ironBlock":{
"properties":{
"physicsFile":["objectsPhysics.json"] -- physicsEditor file for tracing only
"bodyType":"static",
"bounce":0.0,
"friction":1.5,
"density":10.0,
"isSensor":false
}
}
}
In the config tutorial on the Lime website, when you set up the config file in the object properties panel you reference to the config file. How would I reference in tiled so it pick the right objects property like in my second example?
Will it by automatic find the right property if the object name matches?
Last question, since {} are objects and [] are arrays shouldn’t I set the object properties as an [] array? Just thinking, an object has an array of properties…
If my json structure is wrong please let me know.
Thanks guys. [import]uid: 34126 topic_id: 16543 reply_id: 316543[/import]