【发布时间】:2014-03-20 17:09:31
【问题描述】:
我已经创建了 hello world 文本和一个可点击的按钮。当我点击按钮时,hello world 会随机跳动。
问题:我不知道如何让我的程序计算我点击了多少次按钮。
我的进步:
local myHeight = display.contentHeight
local myWidth = display.contentWidth
local topRightHeight = display.newText ("Height "..myHeight, 300 , 40 ,nil,15)
local topRightWidth = display.newText ("Width "..myWidth, 300,60,nil,15)
local redButton = display.newImage ("button.png",0,0)
redButton.x = display.contentWidth -60
redButton.y = display.contentHeight -62.5
local textObj = display.newText ("Hello World",0,0,native.systemFont,18)
textObj: setFillColor(0,250,0)
textObj.x = 40
textObj.y = 30
local number = 0
number = display.newText (number, 30, 30 , native.systemFont, 25)
function moveButtonRandom (event)
textObj.x = math.random(50, display.contentWidth -50)
textObj.y = math.random(50, display.contentHeight -50)
end
redButton: addEventListener ("tap", moveButtonRandom)
【问题讨论】:
-
你为什么用
iOS标记这个问题?