Omnimaga
Calculator Community => TI Calculators => Lua => Topic started by: cypressx1 on July 09, 2011, 07:40:13 am
-
event1=class()
function event1:paint(gc)
gc:drawString("XX",x1,y1)
timer.start(0.1)
end
function event1:timer()
x1=x1+1
y1=y1+1
platform.window.invalidate()
end
event2=class()
function event2:paint(gc)
gc:drawString("XXX",x2,y2)
timer.start(1)
end
function event2:timer()
x2=x2+1
y2=y2+1
platform.window.invalidate()
end
function on.paint(gc)
event1():paint(gc)
event2():paint(gc)
end
function on.timer()
event1():timer()
event2():timer()
end
------you know, it doesn't work. what should l do?
-
are you trying to run both functions at once?
-
You forgot to define event1:init() and event2:init(), and then, you forgot to call them once.
This is a restriction of using class(), you may define a constructor, and call it to create the object
-
what should l write in event:init() ?
-
what should l write in event:init() ?
Nothing, if you don't need so.
Actually, class() seperates the meta-tables and creates a new one to let you call event1 as a specific class. init() initializes the meta-table.
class() is not part of Lua, it is part of the TI Nspire framework, thus, it computerizes some routines to represent classes in Lua, even if it is not an object oriented language.
-
Got it !
-
:love: do you have an E-mail address ?
-
:love: do you have an E-mail address ?
I'm not sure if this is the right place to ask for it, try PMing him.
-
And, don't double post within 6 hours.
-
And, don't double post within 6 hours.
Indeed, I totally forgot that.
You can double post, but only if it's an update for a project or if it has been a long time since the last post.