2014-05-17 2 views
0

나는 이미지 group.Like이 이미지의 그룹을 만들 slideshow.By 이미지를 만들 수 있습니다슬라이드 스크린의 속도를 계산하는 방법은 무엇입니까? - Livecode

enter image description here

지금은이 같은 예제 코드를 움직이지 마 마우스를 사용하여 슬라이드를 할 수 있습니다.

local sScrolling 
local sInitialMouseX, sInitialMouseY 
local sInitialHScroll, sInitialVScroll 

on mouseDown 
    ## Allow the group to scroll 
    put true into sScrolling 

    ## Record the initial touch position 
    put item 1 of the mouseLoc into sInitialMouseX 
    put item 2 of the mouseLoc into sInitialMouseY 

    ## Record the initial hScroll and vScroll 
    put the vScroll of me into sInitialVScroll 
    put the hScroll of me into sInitialHScroll 
end mouseDown 

on mouseMove mouseX, mouseY 
    ## If the screen is being touched then 
    if sScrolling then  
     ## Calculate how far the touch has moved since it started 
     put mouseY - sInitialMouseY into tVChange 
     put mouseX- sInitialMouseX into tHChange 

     ## Reset the hScroll and vScroll to follow the touch 
     lock screen 
     --  set the vScroll of me to sInitialVScroll - tVChange 
     set the hScroll of me to sInitialHScroll - tHChange 
     unlock screen 
     put the hScroll of me && tHChange into fld "labS" 
    end if 
end mouseMove 

on mouseRelease 
    mouseUp 
end mouseRelease 

on mouseUp 
    put false into sScrolling 
end mouseUp 

나는 댐핑을 원하고 IOS의 다양한 응용 프로그램에서 슬라이드 쇼와 같은 스냅 사진을 가지고 있습니다.

나를위한 가이드는 코드를 미리 보거나 미리 보시기 바랍니다.

+0

"댐핑을 원하고 스냅 사진이 있습니까?"는 것은 정확히 무엇을 의미합니까? 나는 당신이 시각적 효과를 원한다고 생각합니다. iOS 또는 Android 용 앱을 만들고 있습니까? 그런 다음 scrollerDidScroll, scrollerBeginDrag 및 scrollerEndDrag 메시지를 살펴볼 수 있습니다. scrollerDidScroll 메시지를 스크롤하면 scrollerEndDrag 메시지가 끝까지 슬라이드할지 여부와 적용 할 효과를 결정할 시간임을 알리는 동안 스크롤 할 수 있습니다. – Mark

답변

0

코드에 몇 가지 질문이 제기됩니다. 예 : 정확히 무엇을 스크롤하고 있습니까? 당신의 사진은 너무 계몽 적이 지 않습니다. 내 생각에 mouseUp 이후 스크롤을 계속할지 또는 hscroll을 원래 값으로 되돌릴지를 결정해야합니다. 분명히, 당신은 임계 값이 필요하고 임계 값의 값을 모른다. 그래서 당신은 지금 그것을 알아 내야 만한다.

on mouseUp 
    put false into sScrolling 
    if (sInitialMouseX - sInitialHScroll) > myThreshold then 
    set the hScroll of me to myScrollTillTheEnd 
    else 
     set the hScroll of me to sInitialHScroll 
    end if 
end mouseUp 

는 그룹의 다른쪽에 반전하도록하고, 사용자가 50 개 픽셀만큼 손가락의 이동 만 결정하면,이어서 50 임계 값이고는 50

으로 myThreshold를 대체 할
+0

한계점이란 무엇입니까? – KemChat

+0

임계 값 = ธรณีประตู. (정확한 번역이 아닐 수도 있습니다. 예를 들어 경계 값과 같은 한도를 의미합니다. 예를 들어, 사용자가 손가락을 50 픽셀 이상 움직이는 경우에만 50을 손가락으로 움직여야합니다. 임계 값 및 myThreshold를 50으로 바꿀 수 있습니다. – Mark

1

이 예제가 댐핑에 대한 아이디어를 줄 수 있기를 바랍니다. (나는 가속/감속을 의미한다고 가정합니다.) 나는이 단순한 간편함을 사용했습니다. 간단히 말해서, 네이티브 스크롤러보다는 내 자신의 스크롤러를 사용한 게임 및 응용 프로그램의 공식.

"볼"라는 이름의 그래픽을 새로운 스택을 만들고 추가 (예 http://dogtales.splash21.com/chapter1-2.php ...을 '개 이야기'응용 프로그램에 애니메이션에서 볼 수있다). 카드에 다음 코드를 입력하십시오.

command moveBall 
    local tSpeed 
    set the left of graphic "Ball" to 0 
    repeat with tIndex = 1 to 100 
     put 10 * easeOut(100, tIndex) into tSpeed 
     set the left of graphic "Ball" to the left of graphic "Ball" + tSpeed 
     wait for 2 millisecs 
    end repeat 
end moveBall 


function easeIn pMax, pVal, pPow 
    local tResult 
    if pPow is not a number then put 1.25 into pPow 
    put (pVal/pMax)^pPow into tResult 
    if tResult > 1 then 
     return 1 
    else if tResult < 0 then 
     return 0 
    else 
     return tResult 
    end if 
end easeIn 


function easeOut pMax, pVal, pPow 
    local tResult 
    if pPow is not a number then put 1.25 into pPow 
    put 1 - (pVal/pMax)^pPow into tResult 
    if tResult > 1 then 
     return 1 
    else if tResult < 0 then 
     return 0 
    else 
     return tResult 
    end if 
end easeOut 
+0

나는 당신이 나에게 말했던 것을 이해하지만 속도의 가치를 어떻게 평가해야하는지 이해하지 못합니까? 그렇지 않으면이 프로세스에 대해 저에게 모범을 보여줄 수 있습니까? 암시. – KemChat

관련 문제