As a newbie, I always like to find out what corona can do. I did some code to print the text at centre. But I find out if I don’t clear the backgroud then all the text will print ontop of each other.
I build a btn to add the value again and again.
I add the clearspace function to cover the previous text, I want to know any other good method to do that.
Sorry to ask such question, but my last programming experience is many years ago with BASIC on my apple.
Hope someone can help.
KC
Bonvivid
module(…, package.seeall)
function new()
local localGroup = display.newGroup()
local _H = display.contentHeight
local _W = display.contentWidth
local movieclip = require(“movieclip”)
local function AreUready()
local total = 100
local park
local dataGroup = display.newGroup()
localGroup:insert(dataGroup)
local clearspace = function( event )
if event.phase == “release” then
local display_txt2 = display.newRect(0,0,100,100);
display_txt2:setFillColor(255,255,255)
display_txt2:setReferencePoint(display.CenterReferencePoint);
display_txt2.x = _W/2; display_txt2.y = _H/2;
dataGroup:insert(display_txt2)
addtotal()
end
end
addtotal = function( event )
total = total + 999
local display_txt = display.newText(total, 0, 0 , native.systemFont, 32);
display_txt:setTextColor(255,0,255)
display_txt:setReferencePoint(display.CenterReferencePoint);
display_txt.x = _W/2; display_txt.y = _H/2;
dataGroup:insert(display_txt)
end
totalbtn = ui.newButton{
defaultSrc = “playnow-btn.png”,
defaultX = 59,
defaultY = 59,
overSrc = “playnow-btn-over.png”,
overX = 59,
overY = 59,
onEvent = clearspace,
id = “total”,
text = “”,
font = “Helvetica”,
textColor = { 255, 255, 255, 255 },
size = 16,
emboss = false
}
totalbtn.xOrigin = 180; totalbtn.yOrigin = 300
totalbtn.isVisible = true
localGroup:insert( totalbtn)
end
local function initVars ()
AreUready()
end
initVars()
return localGroup
end [import]uid: 94613 topic_id: 6833 reply_id: 65425[/import]