Different classes

Dear Corona enthusiasts,

I’m just starting to learn to work with Corona.
But in alot of corona samples, everything is put together in the main.lua file.

Is this because this is faster in corona, or because this is the only way to do it? Or is it simply done because the samples are small and putting it all in other scripts would be obscure?

I’m used to working with OOP languages where every single object has it’s own script. Should I also do this in Corona or should I put everything in main.lua?

Thanks in advance

Alexander

[import]uid: 118839 topic_id: 22032 reply_id: 322032[/import]

Hi.
You can definitly work object oriented if you want. I personally structure my projects in classes.
I usually build my classes like this :

[lua] Class = {}
Class.__index = Class

function Class.new()

local this = {}

local function foo() – private function

end

function this:start() – public function

end

return setmetatable(this,Class)

end

– create an instance of the class

local classInstance = Class.new()[/lua] [import]uid: 103182 topic_id: 22032 reply_id: 87554[/import]

Thanks, i’m going to try to get it to work! [import]uid: 118839 topic_id: 22032 reply_id: 87662[/import]