What to include in my "level" code

Started by
10 comments, last by theOcelot 13 years, 11 months ago
Load returns an ID number... not a function.... if you look at the code i included for cube.lua you'll see EngineManager:LoadAsset(Properties) where it takes the table and loads the assets out of it.

EDIT.. you are correct in that the engine's Create() creates an object based on the assets.. those assets are provided via Load and loaded into the assetmanager.

the object stores that id number in its table... then when it is created it uses that id number to tell the engine "hey, i gave you an asset with this type earlier, create one at x,y,z"

------------------------------

redwoodpixel.com

Advertisement
Ok, so in your terminology an Asset is the full, complete type of the entity, all its initial properties, stored in the engine and referenced by the integer id. But in that case, this line:
Player1 = Level.Assets.cube["create"](x,y,z) --Would return a cube game object at x,y,z.
makes no sense, because an integer is not a table. Wouldn't it be something more like this?
Player1 = EngineManager:CreateObject(Level.Assets.cube, x, y, z)

To get the simple mycube = Cube.Create(x, y, z) to work, here's what I would do. I would have Cube.Properties be a simple static table. Cube.Create would see if the value of Cube.Type was 0 (or just nil). If it was, it would call EngineManager:LoadAsset(Cube.Properties). Otherwise, it would go straight to return EngineManager:CreateObject(Cube.Type, x, y, z), with the event registration mixed in there somewhere.

This topic is closed to new replies.

Advertisement