Hey Guys,
So I bought a book on Corona & one of the projects I am supposed to create is a calculator. I’m trying to get the text to display a local display variable. Can someone show me how I would do this?
I would think it would go like this:
local display
local textDisplay = display.newText(display, 10, 10, “GrilledCheese BTN Toasted”, 20)
Also, sometimes in a calculator it does not display anything. Would I just say in that case that display = nil?
Thank you guys in advance!
Looking forward to learning more about Corona!
Matt [import]uid: 50842 topic_id: 14408 reply_id: 314408[/import]
You don’t need to declare ‘display’. Display is defined by Corona. When you declare the variable name ‘display’ as a local variable…
[lua]local display – get rid of this[/lua]
You actually end up destroying the ‘display’ class that is defined by Corona. So you won’t create any text at all. So drop that line.
You don’t need to put “display” in the function parameters. And the order that you put your function parameters is important. So the first line should be:
I seem to be doing something wrong. If you look in the screenshot below, you’ll notice that the iPhone is actually displaying the font name, GrilledCheese Toasted BTN; instead of nothing (nil)
Any suggestions?
in line 11, use
local Display = display.newText("",0,0,nil,14)
and if GrilledCheese … is your font name, then make line 11 as so
local Display = display.newText("",0,0,“GrilledCheese BTN Toasted”,14)
another thing that was rightly asked by duneunit, why do you want to call the variable Display?
why do you not simply call it textDisplay or displayText ?
I made a mistake and didn’t notice that “GrilledCheese…” was the font name! But looks like you got it all sorted out! Good job! [import]uid: 10818 topic_id: 14408 reply_id: 53292[/import]
instead of using images for each button why not use display.newRect and use a custom font with display.newText
would this not be less memory usage [import]uid: 7911 topic_id: 14408 reply_id: 53304[/import]