Hello,
I think that I still don't understand Lua and Classes completely.
In the main.lua I specify a world globally like:
world = b2.World.new(0, 9.8, true) |
I have a class called Block (block.lua). In this class I will handle
touches and mouse events. Also in this class I need to handle
physics. When I release the mouse button for example, the block
needs to drop to the floor due the gravity. When I define at the
beginning of block.lua:
Block = Core.class(Sprite)
local dummyBody = world:createBody({}) |
in the Block class I will get the error:
attempt to index global 'world'I wan't to use one world so I thought that this was the right
approach. Any idea's?
Thanks,
Marc
Comments
from the main file in your class file(s) and vice versa? Do you
always need to pass these values via function parameters?
Regards,
Marc
Usually this is not a problem, because you can define class, but use it only later.
So for example if you'd defined world usage inside call constructor, like:
will give errors in other classes I'll use.
What I don't get is that:
I know that it's Lua and not C, but....
Marc
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive
Yes I tried that. It gave me errors in other classes. These classes are not
directly dependent of main.lua.
Marc