Hey
So to make a further explanation.
In a level file generated by LevelHelper - the objects are saved in a way that LH understands. (you to if you look inside - as the file is very descriptive).
The code file - LevelHelperLoader.lua - is actually LUA/CORONA code. Whats going on there is that its reading the level file and translates everything in CORONA objects. So here you have functions that reads throw the level file and does this
– object is circle
physics.addBody( sprite, physicType, { density = lhSprite[“Density”], friction = lhSprite[“Friction”], bounce = lhSprite[“Restitution”], radius = size.width/2*scale.width, filter = collisionFilter } )
for example.
So this way - I only have a couple of functions that creates objects with some parameters that are read from a file.
If i were to create the objects writing code for every sprite you add in a level - this will be ok for 10 sprites - but when you add 100 - then… - good luck understanding something from that file.
So, basically, you can still learn from looking in the LevelHelperLoader.lua - how to create physic objects in CORONA, joints, and how to read files. Its a complex file, so i agree, its now easy to digest.
So, instead of doing this
physics.addBody(…
physics.addBody(…
physics.addBody(…
…
it does this
for i = 1 in #objectReadFromFile do
physics.addBody(…
end
Don’t you agree this is better ?
A better understanding will be to take the example project and look in the LevelHelperLoader.lua - right at the bottom - is the function that read the level file - and at the top - the function that iterates through what it was read and creates all the CORONA specific things.
Hope i made it a little clearer.
Kind regards,
Bogdan Vladu [import]uid: 38119 topic_id: 9668 reply_id: 35549[/import]