Text

I’m probably missing something really obvious, sorry for being clueless.
Heres my code-

loginScreen = class()

function loginScreen:init()
    -- you can accept and set parameters here
    self.startText = "Tap anywhere to start"

end

function loginScreen:draw()
    -- Codea does not automatically call this method
    pushStyle()
    fill(60, 255, 0, 255)
    font("AmericanTypewriter-Bold")
    fontSize(40)
    text(self.startText,WIDTH/2,HEIGHT/2)
    popStyle()
end

And then in my draw function i have

loginScreen:draw() 

And when i run the code, it gives an error and says that self.startText is nil
What am i doing wrong?

Have you run loginScreen:init() before you call loginScreen:draw()?

you can’t use the class name in your code. You need to create an “instance” of your class and draw that.

So you need to do something like this

--in the setup function
--create an "instance"
login = loginScreen()

--in draw
login:draw()

Thank you for helping

if you’re new to classes, you’ll find some posts on them here, look for the heading “Classes”

https://coolcodea.wordpress.com/2013/06/19/index-of-posts/