Skip to content

Clean code & fix screen resize/orientation events #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Clean code & fix screen resize/orientation events #3

wants to merge 1 commit into from

Conversation

XeduR
Copy link

@XeduR XeduR commented Apr 17, 2021

There were a few localised functions that were never used. There was also a large chunk of code concerning display.capture() and/or screenshot, but none of the calculated variables were actually used for anything, so I removed them.

The larger changes were concerning the touch/tap blocking sensors and the scene transition effects.

The current (old) version of Composer creates touch/tap blocking sensors, but one of them would be mispositioned if the app is using graphics v1 compatibility mode. Also, neither of these sensors move or update in size if the screen orientation or display size change. They were also using display.contentWidth and display.contentHeight, so they didn't block touch/tap events on devices with different display aspect ratios than defined in config.lua.

The current version of Composer also creates a table for scene transition effects when the library gets required for the first time. This means that if the screen size changes due to orientation or resize event, then future scene transition effects will still play out like the screen dimensions hadn't changed. These effects were also not using actual display width and height values, so they jumped in and out of the screen if the display's aspect ratio differed from config.lua's values.

With these changes, Composer library will use the correct values when it is first required. It also adds a new API, composer.onScreenChange(), which the user may call at any time during or after orientation and resize events to update Composer's touch sensors and scene transition effects. NB! This does not resize or reposition on-going scene transitions.


This commit leaves the composer_scene as is, but there is a known problem that requiring Composer in a project will automatically require physics and json libraries as a part of composer_scene. This is a relic of the old Corona SDK Composer GUI Beta product.


Here are two sample projects that demonstrate the aforementioned issues. The third sample project contains the revised Composer library (this commit), where these issues are fixed.
problem #1 - orientation change.zip
problem #2 - touch issues & scene transitions.zip
solution - test project.zip

There were a few localised functions that were never used. There was also a large chunk of code concerning display.capture() and/or screenshot, but none of the calculated variables were actually used for anything, so I removed them.

The larger changes were concerning the touch/tap blocking sensors and the scene transition effects.

The current (old) version of Composer creates touch/tap blocking sensors, but one of them would be mispositioned if the app is using graphics v1 compatibility mode. Also, neither of these sensors move or update in size if the screen orientation or display size change. They were also using display.contentWidth and display.contentHeight, so they didn't block touch/tap events on devices with different display aspect ratios than defined in config.lua.

The current version of Composer also creates a table for scene transition effects when the library gets required for the first time. This means that if the screen size changes due to orientation or resize event, then future scene transition effects will still play out like the screen dimensions hadn't changed. These effects were also not using actual display width and height values, so they jumped in and out of the screen if the display's aspect ratio differed from config.lua's values.

With these changes, Composer library will use the correct values when it is first required. It also adds a new API, `composer.onScreenChange()`, which the user may call at any time during or after orientation and resize events to update Composer's touch sensors and scene transition effects. NB! This does not resize or reposition on-going scene transitions.

---

This commit leaves the composer_scene as is, but there is a known problem that requiring Composer in a project will automatically require physics and json libraries as a part of composer_scene. This is a relic of the old Corona SDK Composer GUI Beta product.
@XeduR
Copy link
Author

XeduR commented Apr 17, 2021

For reviewing the changes for lines 70-570, it'll probably be easier to download the revised file and look at that. It takes the original table of effects and recreates it within a function. This extra indentation makes the GitHub code changes view show a bit too much red.

@IlSui
Copy link

IlSui commented Apr 17, 2021

Just to give a little contribute, I've tested these 3 apps on the simulator and 2 different devices (Android 11), and I confirm the issues are fixed.

@CLAassistant
Copy link

CLAassistant commented Aug 16, 2021

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants