I want to take a moment and share (in code) some of the way things are changing
Code:
-- On the frame, we've created a bunch of instances of a "Goomba" active object. We've also got some "Koopa Shell"s
-- An object class represents an object collectively
-- An object represents a single instance
goombaClass = mmf.NewObjectClass("Goomba")
koopaShellClass = mmf.NewObjectClass("Koopa Shell")
-- We can get objects from a class
goombaList = goombaClass.objectList()
-- And operate on them all
for i,goomba in ipairs(goombaList) do
if (goomba.overClass(koopaShellClass)) then
-- When we destroy an object, the lua table backing it will
-- disable itself, so even if we try to use it we're safe
goomba.destroy()
end
end
-- We can store our own data or methods with objects or object classes.
goombaClass.step = function(obj)
obj.x = obj.x - 1
-- Speaking of names, now you can access alt values and strings
-- by their names if you defined them in the editor
obj.y = obj.y + obj.values['gravity']
end
for i,goomba in ipairs(goombaList) do
-- Note, I still need to do some exploring but I may be able to
-- get proper inheritance working with these special objects, thus
-- avoiding needing call the class method via the class object
goombaClass.step(goomba)
end
-- What am I doing here?
goombaClass = nil
collectgarbage()
-- Oh no, I lost my class object with my custom defined method!
-- But actually...
goombaClass = mmf.newClassObject("Goomba")
goombaClass.step(goombaClass.randomObject())
-- ... the function is still there.
goombaClass2 = mmf.newClassObject("Goomba")
-- In fact goombaClass and goombaClass2 are the same table. The
-- library will keep a persistent reference of every object or
-- object class created, and always return the same table.
So that's a little preview of the new things I've accomplished with the library.
I'd like to hear anyone's suggestions on how you think the API should be designed, what should be included, issues like 1- vs 0-based indexing, etc. I never went out looking for input the first time I designed it, but now's your chance.