Skip to content

Commit

Permalink
renamed to reorderLayers, button.action set optional
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdugne committed Oct 30, 2019
1 parent 64f81ce commit 3b569fa
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 24 deletions.
46 changes: 24 additions & 22 deletions cherry/components/button.lua
Original file line number Diff line number Diff line change
Expand Up @@ -198,29 +198,31 @@ function Button:create(options)
local SCALE = 0.8
local scaleFrom = 1

gesture.onTap(
button,
function()
if (button.locked) then
return
end
button.locked = true
animation.touchEffect(
button,
{
scaleTo = SCALE,
scaleFrom = scaleFrom,
onComplete = function()
if (button.scale) then
button:scale(scaleFrom / SCALE, scaleFrom / SCALE)
button.locked = false
timer.performWithDelay(10, options.action)
if (options.action) then
gesture.onTap(
button,
function()
if (button.locked) then
return
end
button.locked = true
animation.touchEffect(
button,
{
scaleTo = SCALE,
scaleFrom = scaleFrom,
onComplete = function()
if (button.scale) then
button:scale(scaleFrom / SCALE, scaleFrom / SCALE)
button.locked = false
timer.performWithDelay(10, options.action)
end
end
end
}
)
end
)
}
)
end
)
end

return button
end
Expand Down
2 changes: 1 addition & 1 deletion cherry/core/app.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ local App = {
transversalFrontLayer = display.newGroup(),
hud = display.newGroup(),
-----------------------------------------
resetLayers = function()
reorderLayers = function()
App.transversalBackLayer:toBack()
Background:toBack()
App.transversalFrontLayer:toFront()
Expand Down
2 changes: 1 addition & 1 deletion cherry/core/router.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local Router = {
--------------------------------------------------------------------------------

function Router:resetScreen()
App.resetLayers()
App.reorderLayers()
if (Screen.reset) then
Screen:reset()
end
Expand Down

0 comments on commit 3b569fa

Please sign in to comment.