How to promote pages in the Corona SDK

I am using the CORONA SDK. I have a set of pages and I would like to slide between them using swipe left-right. The page contains a set of controls (mostly text)

What is the best way to do this slide / scroll in Corona?

+1
source share
2 answers

Using touch events.

When the phase of the event "started" (the user simply touched the screen), allow the movement of three pages (actual, forward and backward).

if event.phase == "began" then page1.canMove = true page2.canMove = true page3.canMove = true initial = {} initial.x = event.x end 

If pages are allowed to move:

 if page1.canMove == true then 

Move three pages according to the x parameter of the event.

 page1.x = page1.x + event.x - initial.x page2.x = page2.x + event.x - initial.x page3.x = page3.x + event.x - initial.x 

when the phase of the event is β€œcompleted” (the user releases his finger), remove the permission to move.

 if event.phase == "end" then page1.canMove = false page2.canMove = false page3.canMove = false end 

and adjust the pages, depending on where they are.

I just came up with this solution if someone can contribute to make it more complete: D.

+1
source

You can do this using storyboard transitions.

In a storyboard, a page is a scene, you can add transitions.

 http://www.coronalabs.com/blog/2011/11/14/introducing-the-storyboard-api/ 
0
source

Source: https://habr.com/ru/post/1487545/


All Articles