OOP and display objects

So I want to create an Enemy class and then inherit from it and create enemy objects later, but there was a problem when trying to create an object of that class and at the same time making it a display object. 

Here is my enemy class:

local enemy = {} function enemy.new( t ) local newEnemy = { speed = t.speed or 0, health = t.health or 0, damage = t.damage or 0, body = {} \<-- will use it later to add a "displayObject" } return setmetatable( newEnemy, {\_\_index=enemy} ) end function enemy:test( &nbsp;) print(self.body.x) print( self.speed ) end

Here is how I instantiate it:

local e1 = enemy.new({ &nbsp; speed = 100, &nbsp; health &nbsp;=200, &nbsp; damage = 300 })

Here is how I give an actual rendered displayObject to appear on the screen:

e1.body = display.newImageRect( sceneGroup, "enemypng", 50, 50 ) &nbsp; &nbsp; e1.body.x = 50 &nbsp; &nbsp; e1.body.y = 100

Now I test to see if everything is working fine:  (refer to the enemy class above ^)

e1:test() prints(50, 100) it works

I’m not sure whether what I’ve done here is the most efficient solution or not, but it’s the best I could do to achieve some sort of OO pattern. I was also thinking of making an entity-component system, but I’m not sure how to make the components connect with the entity, but that’s another story.

If anyone has any experience with OOP and Corona, your  suggestions would be much appreciated. 

You code looks ok what error are you getting?

There are no errors. I’m posting it to get input on whether there is a better way to use OOP with Corona.

You code looks ok what error are you getting?

There are no errors. I’m posting it to get input on whether there is a better way to use OOP with Corona.