I tried it still isn’t working i wrote
sceneGroup:insert( player.view )
but it gives me an error
level1.lua:51: ERROR table expected. if this is a fuction call you might have used '.' instead of ':'
I tried it still isn’t working i wrote
sceneGroup:insert( player.view )
but it gives me an error
level1.lua:51: ERROR table expected. if this is a fuction call you might have used '.' instead of ':'
I use a method like this :
http://theindiestone.com/forums/index.php/topic/8023-simple-lua-oop-without-metatables/
I should have included this link originally, but I had lost it from my reference folder. I had to search google again to find it for you.
I do not know which method is better or best. This one works for me. There are apparently several ways to create an ‘oop’ style in lua, but I don’t have time to play around and find which is best. I settled on this method; and like I say it works for me.
If you are going to do some serious coding with corona, you benefit yourself to research several of the articles out there about oop and lua/corona and find the one you understand the best and works for you. I don’t know enough about all of them to steer you in any direction, that is why i provided several links and the suggestion to search for further articles on oop.
Good Luck.
Bob
no offense intended, but you should probably start w something simpler – learn from that first, then make it more complicated as you become more comfortable with some basic things. for example, ignore your Player.lua entirely for now, and just try this simple test near the bottom of scene:create()
player={} -- just an empty table as an "object", not a "class" player.img=display.newImage("crate.png",10,10) -- give it a display object as a property self.view:insert(player.img) -- put that display object into scene's display group
Once you can get something like that to work, THEN maybe you can consider pulling it out into a module/etc.
Right now your problem really isn’t the oop/class/module stuff – you just have some “simple” problems with Corona fundamentals.