我最終這樣做了。如果您有更好的方法,請發佈您的答案!
local direction = 0
function scene:move()
crate.rotation = crate.rotation + direction
end
Runtime:addEventListener("enterFrame", scene.move)
local function onButtonEvent(event)
if event.phase == "press" then
direction = 1 -- (-1 to reverse direction)
elseif event.phase == "moved" then
elseif event.phase == "release" then
direction = 0
end
return true
end
local button = widget.newButton{
id = "rotate_button",
label = "Rotate",
font = "HelveticaNeue-Bold",
fontSize = 16,
yOffset = -2,
labelColor = { default={ 65 }, over={ 0 } },
emboss = true,
onEvent = onButtonEvent
}