How to inherit from Corona's Display Object ??

Objected Oriented Lua is possible using the following approach
http://lua-users.org/wiki/SimpleLuaClasses
https://github.com/kikito/middleclass/wiki/Quick-Example

How to inherit from Corona's Display Object , so that the new instance of the class can be insert into Display Group ?

1
2
3
4
5
6
7
8
9
10
11
12
13
require("middleclass")
 
Ball = class( DisplayObject )
 
function Ball:initialize(x,y)
  self.sprite = display.newCircle( x, y, 10 )
end
 
local b1 = Ball:new(100,100)
 
local group = display.newGroup()
 
group:insert(b1)

Here's my approach to inheritance with Corona display objects:

http://www.ludicroussoftware.com/blog/2011/07/06/simple-oop-with-inheritance-in-corona/

Is that the sort of thing you're looking for?

Darren

views:2031 update:2011/10/5 8:48:05
corona forums © 2003-2011