Page 1 of 1

Visual Effect swipe

Posted: Fri Jul 08, 2011 4:21 pm
by Kaubs
I am trying to apply visual effect push left and right to select cards in my stack. I would like to be able to push both left and right. Is there something I need to add to my code to make this happen? Right now I have a problem where I push left and it just goes back to the card I was currently on because I have no separation between visual effect push right, visual effect push left.

on mouseUp
visual effect push left fast
go to the next card
visual effect push right fast
go to previous card
end mouseUp

Thanks for any help!

Re: Visual Effect swipe

Posted: Fri Jul 08, 2011 4:39 pm
by Klaus
Hi Kaubs,

do this:

Code: Select all

on mouseUp
  visual effect push left fast
  go to this cd
  visual effect push right fast
  go to this cd
end mouseUp
Tested and works :D


Best

Klaus

Re: Visual Effect swipe

Posted: Fri Jul 08, 2011 5:22 pm
by Kaubs
Klaus,

Thanks for the suggestion. However, I am still experiencing the same issue. So that you can have a visual, I have about 6 cards in a stack that I want to apply the swipe effect to. There are about 31 cards total in the stack so it cannot be applied to the stack as a whole. I took three cards, applied the suggested code to them...card 1 moves to card 2 just fine card 2 moves to card 3 and then rubberbands back to card 1 because card 2 contains both push right and push left. Does that make sense? Yes the effect works kind of...but mouseup will not work with two visual effect push options on a single card...it just goes to whatever the last card specified or the last action on mouseup is.

Re: Visual Effect swipe

Posted: Fri Jul 08, 2011 5:54 pm
by Klaus
Hi Kaubs,

sorry, still don't get it?

So you want to go to "the next" card with BOTH visual effects pus left and right?
Is that corect?
What and where are your scripts?


Best

Klaus

Re: Visual Effect swipe

Posted: Fri Jul 08, 2011 6:24 pm
by dglass
Card 1 can only move to Card 2, right?
Card 3 can only move to Card 2, right?
Card 2 can move to Card 1 or Card 3, right?

If that is the case, I can't see how you'll be able to have a single button handle the navigation on Card 2. How would it know which card you wanted to go to?

So Card 2 will need two buttons, one for 'previous' and one for 'next', each with a single visual effect, and 'go to card' command.

Re: Visual Effect swipe

Posted: Fri Jul 08, 2011 6:38 pm
by Kaubs
Lol Im an idiot,
Thanks for the help. This is what ended up working.


# the event id and initial swipe time and position
local sTouchId, sInitTime, sInitX


# maximum swipe time in millisecs
local sSwipeTime


# minimum swipe distance
local sSwipeDistance


on opencard
# set up swipe values - experiment with these for required effect
put 500 into sSwipeTime
put 150 into sSwipeDistance
end opencard


on touchMove pId, pX, pY
if pId <> sTouchId then
# record initial values for start of swipe
put pId into sTouchId
put the millisecs into sInitTime
put pX into sInitX
end if

# check the action was fast enough for a swipe
if the millisecs - sInitTime <= sSwipeTime then
# check we have covered enough distance
put pX - sInitX into tDistanceX
if abs(tDistanceX) > sSwipeDistance then
if tDistanceX < 0 then
# finger is swiping left
send "swipeLeft" to me in 0 millisecs
else
# finger is swiping right
send "swipeRight" to me in 0 millisecs
end if
end if
end if
end touchMove


command swipeRight
visual effect scroll right normal
go prev card
end swipeRight


command swipeLeft
visual effect scroll left normal
go next card
end swipeLeft


Thanks for all the help!

Re: Visual Effect swipe

Posted: Fri Jul 08, 2011 6:39 pm
by Kaubs
On mouseup was just a screen touch or a click...not a swipe like what I was looking for. I didn't specify clearly enough and was approaching the project in the wrong manner.

Re: Visual Effect swipe

Posted: Fri Jul 08, 2011 6:41 pm
by Klaus
AHA! :D

Glad you got it working!


Best

Klaus