swipe photo horizontally and vertically not exclusively linearly

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Bast
Posts: 1
Joined: Thu Nov 04, 2021 7:45 pm

swipe photo horizontally and vertically not exclusively linearly

Post by Bast » Thu Nov 04, 2021 9:28 pm

I look for a "swipe photo" code (Android, iOS and Windows) that would allow me to scroll the images horizontally and vertically but not exclusively linearly.

Example:
1-2-3-4 row A
5-6-7-8 row B

1-2-3-4 are placed one after the other horizontally from left to right in the first row (row A).

5-6-7-8 are placed one after the other horizontally from left to right in the second row (row B).


Here is an example:
I swipe horizontally and bi-directionally (potentially) on row A (first row) from photo 1 to photo 2 to photo 3 to photo 4.

I swipe vertically from photo 1 located on row A to photo 5 located on row B (second row located immediately below row A).

If I swipe vertically from photo 2 or photo 3 located on row A to row B, then I will be directed to photo 5 and not to photo 6 or 7.

However, if I swipe vertically from photo 4 on row A to row B, then I will be directed to photo 8 and not to photo 5.

In case I swipe vertically from photo 5 or 6 located on row B to row A then I will be directed to photo 1.

Whereas if I vertically swipe from photo 7 or 8 located on row B to row A, I will be directed to photo 4.

In any case, I will not be able to swipe vertically directly from photo 2 or 3 on row A to photo 6 or 7 on row B.

Swiping photos 2 and 3 vertically on row A to row B will automatically bring me to photo 5. I will then have to move (swipe) horizontally to reach photos 6 and 7.

I look for a "swipe photo" code that would allow me to do this kind of move.
Can someone help me? Your tips are welcome.
Attachments
Swipe_code_en.jpg

xAction
Posts: 86
Joined: Sun Oct 03, 2021 4:14 am

Re: swipe photo horizontally and vertically not exclusively linearly

Post by xAction » Fri Nov 05, 2021 6:21 am

I'm not sure I understand what you are trying to do exactly
But you need a local variable to keep track of the current column, lets call it curColumn
Oh need one for the current row, we'll call it curRow
You probably need local variables to keep track of how many colums and rows you have
using your example we'll just assume 4 columns, 2 rows
Lets assume when you swipe you send a the swipe direction to handler called checkSwipe

Code: Select all

local columns=4,rows=2,curColumn=1,curRow=1


on checkSwipe swipeDirection
switch swipeDirection

case "left"
 if curColumn < 4 then 
 add 1 to to curColumn
 else
--// go from frame 4 to 8
 add 1 to curRow
end if
break

case "right"
if curColumn > 1 then 
 subtract 1 from curColumn
 else
 --// go from frame 1 to 5
 add 1 to curRow
end if
break

case "up"
if curColumn > 6 and curRow >1 then
put 4 into curColumn
put 1 into curRow
end if
--//  back to the start
if curColumn < 7 and curRow >1 then
put 1 into curColumn
put 1 into curRow
end if
break

case "down"
if curColumn < 4 then
put 1 into curColumn
put 2 into curRow
else
--// only need a row change
put 2 into curRow
end if
break
end switch

showCurrentFrame
end checkSwipe

on showCurrentFrame
--// however you are showing your pictures based on column and row here
end showCurrentFrame

Post Reply

Return to “Android Deployment”