From 453a5865c0f2182438aa41cdb7d523875c624202 Mon Sep 17 00:00:00 2001 From: Mark Sandell Date: Thu, 18 Jan 2024 20:32:38 -0800 Subject: [PATCH] correct transition locations when a device is rotated Signed-off-by: Mark Sandell --- composer.lua | 853 ++++++++++++++++++++++++++------------------------- 1 file changed, 433 insertions(+), 420 deletions(-) diff --git a/composer.lua b/composer.lua index 3705744..95696e8 100644 --- a/composer.lua +++ b/composer.lua @@ -73,485 +73,490 @@ local isGraphicsV1 = ( 1 == display.getDefault( "graphicsCompatibility" ) ) -- TRANSITION EFFECTS -local effectList = { - ["fade"] = - { - ["from"] = +local effectList +local function setTransitionEffectsList() + effectList = { + ["fade"] = { - alphaStart = 1.0, - alphaEnd = 0, + ["from"] = + { + alphaStart = 1.0, + alphaEnd = 0, + }, + + ["to"] = + { + alphaStart = 0, + alphaEnd = 1.0 + } }, - ["to"] = + ["zoomOutIn"] = { - alphaStart = 0, - alphaEnd = 1.0 - } - }, - - ["zoomOutIn"] = - { - ["from"] = - { - xEnd = displayW*0.5, - yEnd = displayH*0.5, - xScaleEnd = 0.001, - yScaleEnd = 0.001 + ["from"] = + { + xEnd = displayW*0.5, + yEnd = displayH*0.5, + xScaleEnd = 0.001, + yScaleEnd = 0.001 + }, + + ["to"] = + { + xScaleStart = 0.001, + yScaleStart = 0.001, + xScaleEnd = 1.0, + yScaleEnd = 1.0, + xStart = displayW*0.5, + yStart = displayH*0.5, + xEnd = 0, + yEnd = 0 + }, + hideOnOut = true }, - ["to"] = + ["zoomOutInFade"] = { - xScaleStart = 0.001, - yScaleStart = 0.001, - xScaleEnd = 1.0, - yScaleEnd = 1.0, - xStart = displayW*0.5, - yStart = displayH*0.5, - xEnd = 0, - yEnd = 0 - }, - hideOnOut = true - }, - - ["zoomOutInFade"] = - { - ["from"] = - { - xEnd = displayW*0.5, - yEnd = displayH*0.5, - xScaleEnd = 0.001, - yScaleEnd = 0.001, - alphaStart = 1.0, - alphaEnd = 0 + ["from"] = + { + xEnd = displayW*0.5, + yEnd = displayH*0.5, + xScaleEnd = 0.001, + yScaleEnd = 0.001, + alphaStart = 1.0, + alphaEnd = 0 + }, + + ["to"] = + { + xScaleStart = 0.001, + yScaleStart = 0.001, + xScaleEnd = 1.0, + yScaleEnd = 1.0, + xStart = displayW*0.5, + yStart = displayH*0.5, + xEnd = 0, + yEnd = 0, + alphaStart = 0, + alphaEnd = 1.0 + }, + hideOnOut = true }, - ["to"] = - { - xScaleStart = 0.001, - yScaleStart = 0.001, - xScaleEnd = 1.0, - yScaleEnd = 1.0, - xStart = displayW*0.5, - yStart = displayH*0.5, - xEnd = 0, - yEnd = 0, - alphaStart = 0, - alphaEnd = 1.0 - }, - hideOnOut = true - }, - - ["zoomInOut"] = - { - ["from"] = + ["zoomInOut"] = { - xEnd = -displayW*0.5, - yEnd = -displayH*0.5, - xScaleEnd = 2.0, - yScaleEnd = 2.0 + ["from"] = + { + xEnd = -displayW*0.5, + yEnd = -displayH*0.5, + xScaleEnd = 2.0, + yScaleEnd = 2.0 + }, + + ["to"] = + { + xScaleStart = 2.0, + yScaleStart = 2.0, + xScaleEnd = 1.0, + yScaleEnd = 1.0, + xStart = -displayW*0.5, + yStart = -displayH*0.5, + xEnd = 0, + yEnd = 0 + }, + hideOnOut = true }, - ["to"] = + ["zoomInOutFade"] = { - xScaleStart = 2.0, - yScaleStart = 2.0, - xScaleEnd = 1.0, - yScaleEnd = 1.0, - xStart = -displayW*0.5, - yStart = -displayH*0.5, - xEnd = 0, - yEnd = 0 - }, - hideOnOut = true - }, - - ["zoomInOutFade"] = - { - ["from"] = - { - xEnd = -displayW*0.5, - yEnd = -displayH*0.5, - xScaleEnd = 2.0, - yScaleEnd = 2.0, - alphaStart = 1.0, - alphaEnd = 0 + ["from"] = + { + xEnd = -displayW*0.5, + yEnd = -displayH*0.5, + xScaleEnd = 2.0, + yScaleEnd = 2.0, + alphaStart = 1.0, + alphaEnd = 0 + }, + + ["to"] = + { + xScaleStart = 2.0, + yScaleStart = 2.0, + xScaleEnd = 1.0, + yScaleEnd = 1.0, + xStart = -displayW*0.5, + yStart = -displayH*0.5, + xEnd = 0, + yEnd = 0, + alphaStart = 0, + alphaEnd = 1.0 + }, + hideOnOut = true }, - ["to"] = - { - xScaleStart = 2.0, - yScaleStart = 2.0, - xScaleEnd = 1.0, - yScaleEnd = 1.0, - xStart = -displayW*0.5, - yStart = -displayH*0.5, - xEnd = 0, - yEnd = 0, - alphaStart = 0, - alphaEnd = 1.0 - }, - hideOnOut = true - }, - - ["flip"] = - { - ["from"] = + ["flip"] = { - xEnd = displayW*0.5, - xScaleEnd = 0.001 + ["from"] = + { + xEnd = displayW*0.5, + xScaleEnd = 0.001 + }, + + ["to"] = + { + xScaleStart = 0.001, + xScaleEnd = 1.0, + xStart = displayW*0.5, + xEnd = 0 + } }, - ["to"] = + ["flipFadeOutIn"] = { - xScaleStart = 0.001, - xScaleEnd = 1.0, - xStart = displayW*0.5, - xEnd = 0 - } - }, - - ["flipFadeOutIn"] = - { - ["from"] = - { - xEnd = displayW*0.5, - xScaleEnd = 0.001, - alphaStart = 1.0, - alphaEnd = 0 - }, - - ["to"] = - { - xScaleStart = 0.001, - xScaleEnd = 1.0, - xStart = displayW*0.5, - xEnd = 0, - alphaStart = 0, - alphaEnd = 1.0 - } - }, - - ["zoomOutInRotate"] = - { - ["from"] = - { - xEnd = displayW*0.5, - yEnd = displayH*0.5, - xScaleEnd = 0.001, - yScaleEnd = 0.001, - rotationStart = 0, - rotationEnd = -360 + ["from"] = + { + xEnd = displayW*0.5, + xScaleEnd = 0.001, + alphaStart = 1.0, + alphaEnd = 0 + }, + + ["to"] = + { + xScaleStart = 0.001, + xScaleEnd = 1.0, + xStart = displayW*0.5, + xEnd = 0, + alphaStart = 0, + alphaEnd = 1.0 + } }, - ["to"] = - { - xScaleStart = 0.001, - yScaleStart = 0.001, - xScaleEnd = 1.0, - yScaleEnd = 1.0, - xStart = displayW*0.5, - yStart = displayH*0.5, - xEnd = 0, - yEnd = 0, - rotationStart = -360, - rotationEnd = 0 - }, - hideOnOut = true - }, - - ["zoomOutInFadeRotate"] = - { - ["from"] = + ["zoomOutInRotate"] = { - xEnd = displayW*0.5, - yEnd = displayH*0.5, - xScaleEnd = 0.001, - yScaleEnd = 0.001, - rotationStart = 0, - rotationEnd = -360, - alphaStart = 1.0, - alphaEnd = 0 + ["from"] = + { + xEnd = displayW*0.5, + yEnd = displayH*0.5, + xScaleEnd = 0.001, + yScaleEnd = 0.001, + rotationStart = 0, + rotationEnd = -360 + }, + + ["to"] = + { + xScaleStart = 0.001, + yScaleStart = 0.001, + xScaleEnd = 1.0, + yScaleEnd = 1.0, + xStart = displayW*0.5, + yStart = displayH*0.5, + xEnd = 0, + yEnd = 0, + rotationStart = -360, + rotationEnd = 0 + }, + hideOnOut = true }, - ["to"] = - { - xScaleStart = 0.001, - yScaleStart = 0.001, - xScaleEnd = 1.0, - yScaleEnd = 1.0, - xStart = displayW*0.5, - yStart = displayH*0.5, - xEnd = 0, - yEnd = 0, - rotationStart = -360, - rotationEnd = 0, - alphaStart = 0, - alphaEnd = 1.0 - }, - hideOnOut = true - }, - - ["zoomInOutRotate"] = - { - ["from"] = + ["zoomOutInFadeRotate"] = { - xEnd = displayW*0.5, - yEnd = displayH*0.5, - xScaleEnd = 2.0, - yScaleEnd = 2.0, - rotationStart = 0, - rotationEnd = -360 + ["from"] = + { + xEnd = displayW*0.5, + yEnd = displayH*0.5, + xScaleEnd = 0.001, + yScaleEnd = 0.001, + rotationStart = 0, + rotationEnd = -360, + alphaStart = 1.0, + alphaEnd = 0 + }, + + ["to"] = + { + xScaleStart = 0.001, + yScaleStart = 0.001, + xScaleEnd = 1.0, + yScaleEnd = 1.0, + xStart = displayW*0.5, + yStart = displayH*0.5, + xEnd = 0, + yEnd = 0, + rotationStart = -360, + rotationEnd = 0, + alphaStart = 0, + alphaEnd = 1.0 + }, + hideOnOut = true }, - ["to"] = - { - xScaleStart = 2.0, - yScaleStart = 2.0, - xScaleEnd = 1.0, - yScaleEnd = 1.0, - xStart = displayW*0.5, - yStart = displayH*0.5, - xEnd = 0, - yEnd = 0, - rotationStart = -360, - rotationEnd = 0 - }, - hideOnOut = true - }, - - ["zoomInOutFadeRotate"] = - { - ["from"] = + ["zoomInOutRotate"] = { - xEnd = displayW*0.5, - yEnd = displayH*0.5, - xScaleEnd = 2.0, - yScaleEnd = 2.0, - rotationStart = 0, - rotationEnd = -360, - alphaStart = 1.0, - alphaEnd = 0 + ["from"] = + { + xEnd = displayW*0.5, + yEnd = displayH*0.5, + xScaleEnd = 2.0, + yScaleEnd = 2.0, + rotationStart = 0, + rotationEnd = -360 + }, + + ["to"] = + { + xScaleStart = 2.0, + yScaleStart = 2.0, + xScaleEnd = 1.0, + yScaleEnd = 1.0, + xStart = displayW*0.5, + yStart = displayH*0.5, + xEnd = 0, + yEnd = 0, + rotationStart = -360, + rotationEnd = 0 + }, + hideOnOut = true }, - ["to"] = + ["zoomInOutFadeRotate"] = { - xScaleStart = 2.0, - yScaleStart = 2.0, - xScaleEnd = 1.0, - yScaleEnd = 1.0, - xStart = displayW*0.5, - yStart = displayH*0.5, - xEnd = 0, - yEnd = 0, - rotationStart = -360, - rotationEnd = 0, - alphaStart = 0, - alphaEnd = 1.0 - }, - hideOnOut = true - }, - - ["fromRight"] = - { - ["from"] = - { - xStart = 0, - yStart = 0, - xEnd = 0, - yEnd = 0, - transition = easing.outQuad + ["from"] = + { + xEnd = displayW*0.5, + yEnd = displayH*0.5, + xScaleEnd = 2.0, + yScaleEnd = 2.0, + rotationStart = 0, + rotationEnd = -360, + alphaStart = 1.0, + alphaEnd = 0 + }, + + ["to"] = + { + xScaleStart = 2.0, + yScaleStart = 2.0, + xScaleEnd = 1.0, + yScaleEnd = 1.0, + xStart = displayW*0.5, + yStart = displayH*0.5, + xEnd = 0, + yEnd = 0, + rotationStart = -360, + rotationEnd = 0, + alphaStart = 0, + alphaEnd = 1.0 + }, + hideOnOut = true }, - ["to"] = + ["fromRight"] = { - xStart = displayW, - yStart = 0, - xEnd = 0, - yEnd = 0, - transition = easing.outQuad - }, - concurrent = true, - sceneAbove = true - }, - - ["fromLeft"] = - { - ["from"] = - { - xStart = 0, - yStart = 0, - xEnd = 0, - yEnd = 0, - transition = easing.outQuad + ["from"] = + { + xStart = 0, + yStart = 0, + xEnd = 0, + yEnd = 0, + transition = easing.outQuad + }, + + ["to"] = + { + xStart = displayW, + yStart = 0, + xEnd = 0, + yEnd = 0, + transition = easing.outQuad + }, + concurrent = true, + sceneAbove = true }, - ["to"] = - { - xStart = -displayW, - yStart = 0, - xEnd = 0, - yEnd = 0, - transition = easing.outQuad - }, - concurrent = true, - sceneAbove = true - }, - - ["fromTop"] = - { - ["from"] = + ["fromLeft"] = { - xStart = 0, - yStart = 0, - xEnd = 0, - yEnd = 0, - transition = easing.outQuad + ["from"] = + { + xStart = 0, + yStart = 0, + xEnd = 0, + yEnd = 0, + transition = easing.outQuad + }, + + ["to"] = + { + xStart = -displayW, + yStart = 0, + xEnd = 0, + yEnd = 0, + transition = easing.outQuad + }, + concurrent = true, + sceneAbove = true }, - ["to"] = + ["fromTop"] = { - xStart = 0, - yStart = -displayH, - xEnd = 0, - yEnd = 0, - transition = easing.outQuad - }, - concurrent = true, - sceneAbove = true - }, - - ["fromBottom"] = - { - ["from"] = - { - xStart = 0, - yStart = 0, - xEnd = 0, - yEnd = 0, - transition = easing.outQuad + ["from"] = + { + xStart = 0, + yStart = 0, + xEnd = 0, + yEnd = 0, + transition = easing.outQuad + }, + + ["to"] = + { + xStart = 0, + yStart = -displayH, + xEnd = 0, + yEnd = 0, + transition = easing.outQuad + }, + concurrent = true, + sceneAbove = true }, - ["to"] = - { - xStart = 0, - yStart = displayH, - xEnd = 0, - yEnd = 0, - transition = easing.outQuad - }, - concurrent = true, - sceneAbove = true - }, - - ["slideLeft"] = - { - ["from"] = + ["fromBottom"] = { - xStart = 0, - yStart = 0, - xEnd = -displayW, - yEnd = 0, - transition = easing.outQuad + ["from"] = + { + xStart = 0, + yStart = 0, + xEnd = 0, + yEnd = 0, + transition = easing.outQuad + }, + + ["to"] = + { + xStart = 0, + yStart = displayH, + xEnd = 0, + yEnd = 0, + transition = easing.outQuad + }, + concurrent = true, + sceneAbove = true }, - ["to"] = + ["slideLeft"] = { - xStart = displayW, - yStart = 0, - xEnd = 0, - yEnd = 0, - transition = easing.outQuad - }, - concurrent = true, - sceneAbove = true - }, - - ["slideRight"] = - { - ["from"] = - { - xStart = 0, - yStart = 0, - xEnd = displayW, - yEnd = 0, - transition = easing.outQuad + ["from"] = + { + xStart = 0, + yStart = 0, + xEnd = -displayW, + yEnd = 0, + transition = easing.outQuad + }, + + ["to"] = + { + xStart = displayW, + yStart = 0, + xEnd = 0, + yEnd = 0, + transition = easing.outQuad + }, + concurrent = true, + sceneAbove = true }, - ["to"] = - { - xStart = -displayW, - yStart = 0, - xEnd = 0, - yEnd = 0, - transition = easing.outQuad - }, - concurrent = true, - sceneAbove = true - }, - - ["slideDown"] = - { - ["from"] = + ["slideRight"] = { - xStart = 0, - yStart = 0, - xEnd = 0, - yEnd = displayH, - transition = easing.outQuad + ["from"] = + { + xStart = 0, + yStart = 0, + xEnd = displayW, + yEnd = 0, + transition = easing.outQuad + }, + + ["to"] = + { + xStart = -displayW, + yStart = 0, + xEnd = 0, + yEnd = 0, + transition = easing.outQuad + }, + concurrent = true, + sceneAbove = true }, - ["to"] = + ["slideDown"] = { - xStart = 0, - yStart = -displayH, - xEnd = 0, - yEnd = 0, - transition = easing.outQuad - }, - concurrent = true, - sceneAbove = true - }, - - ["slideUp"] = - { - ["from"] = - { - xStart = 0, - yStart = 0, - xEnd = 0, - yEnd = -displayH, - transition = easing.outQuad + ["from"] = + { + xStart = 0, + yStart = 0, + xEnd = 0, + yEnd = displayH, + transition = easing.outQuad + }, + + ["to"] = + { + xStart = 0, + yStart = -displayH, + xEnd = 0, + yEnd = 0, + transition = easing.outQuad + }, + concurrent = true, + sceneAbove = true }, - ["to"] = - { - xStart = 0, - yStart = displayH, - xEnd = 0, - yEnd = 0, - transition = easing.outQuad - }, - concurrent = true, - sceneAbove = true - }, - - ["crossFade"] = - { - ["from"] = + ["slideUp"] = { - alphaStart = 1.0, - alphaEnd = 0, + ["from"] = + { + xStart = 0, + yStart = 0, + xEnd = 0, + yEnd = -displayH, + transition = easing.outQuad + }, + + ["to"] = + { + xStart = 0, + yStart = displayH, + xEnd = 0, + yEnd = 0, + transition = easing.outQuad + }, + concurrent = true, + sceneAbove = true }, - ["to"] = + ["crossFade"] = { - alphaStart = 0, - alphaEnd = 1.0 - }, - concurrent = true + ["from"] = + { + alphaStart = 1.0, + alphaEnd = 0, + }, + + ["to"] = + { + alphaStart = 0, + alphaEnd = 1.0 + }, + concurrent = true + } } -} -lib.effectList = effectList + lib.effectList = effectList +end + +setTransitionEffectsList() ----------------------------------------------------------------------------------------- @@ -1600,6 +1605,14 @@ lib.printMemUsage = function() print("WARNING: composer.printMemUsage() has been removed.") end +local function onResize(event) + -- Make sure transitions originate from the proper location if the device is rotated. + displayW = display.contentWidth + displayH = display.contentHeight + setTransitionEffectsList() +end +Runtime:addEventListener( "resize", onResize ) + lib.setVariable = function( key, value ) if nil ~= key and nil ~= value then lib.variables[ key ] = value