Iphone 如何创建Jetpack Joyride jackpot杠杆动画

Iphone 如何创建Jetpack Joyride jackpot杠杆动画,iphone,ios,uianimation,Iphone,Ios,Uianimation,只是想知道是否有人知道如何重现触摸杆的动作 不知道确切的动画是什么,但如果您必须向下拉动操纵杆才能激活,而不仅仅是单击操纵杆,那么您需要获得初始触摸位置并将其与最终触摸位置进行比较。当前触摸在2个开始和结束位置之间的百分比指示正在使用的动画帧 假设杠杆动画中有10帧: function lengthOf(a, b) local width, height = b.x-a.x, b.y-a.y return (width*width + height*height)^0.5 end

只是想知道是否有人知道如何重现触摸杆的动作


不知道确切的动画是什么,但如果您必须向下拉动操纵杆才能激活,而不仅仅是单击操纵杆,那么您需要获得初始触摸位置并将其与最终触摸位置进行比较。当前触摸在2个开始和结束位置之间的百分比指示正在使用的动画帧

假设杠杆动画中有10帧:

function lengthOf(a, b)
    local width, height = b.x-a.x, b.y-a.y
    return (width*width + height*height)^0.5
end

local startBox, endBox
local beingPulled = false
if isOver(touchPos, startBox) and touch.phase == "began" then
   beingPulled = true
end
if touch.phase == "moved" then
   if beingPulled then
      local lengthA = lengthOf(touch, startBox)
      local lengthB = lengthOf(touch, endBox)
      local totalLength = lengthA+lengthB
      local percentage = totalLength/lengthA

      lever:setFrame( math.ceil(percentage*10) )
   end
end
if touch.phase == "ended" then
   lever:resetPosition()
   beingPulled = false
end

您可能需要3d对象(可以稍微旋转一点)来制作动画,也可能已经在设置对象动画时预渲染了所有动画帧(例如,您有一个“杠杆”对象)

我也做过类似的事情——我有一个旋转立方体的预渲染图像。我将所有这些图像设置为动画帧,如本例所示:

我把不可见的滚动视图放在这个
UIImageView
上面。然后,当调用
scrollViewDidScroll
时,我只是更改了当前
UIImageView
动画帧

因此,在本例中-它可能是一个
UIScrollView
,它在上-例如:

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
将ContentOffset设置为
CGPoint(0,0)
point。(带动画)


这是我的建议。祝你好运

你好,大卫,谢谢你的回复。是的,只是一个下拉动画谢谢分享动画视频@大卫,杠杆动画是我需要的。