iphone - 如何创建 Jetpack Joyride 大奖杠杆动画
<p><p>只是想知道是否有人知道如何重新创建触摸杆 Action ?</p>
<p> <a href="http://www.wired.com/geekdad/wp-content/uploads/2011/08/JJ-jackpot.jpg" rel="noreferrer noopener nofollow">http://www.wired.com/geekdad/wp-content/uploads/2011/08/JJ-jackpot.jpg</a> </p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>不知道确切的动画是什么,但如果您必须拉下控制杆来激活而不是点击控制杆,那么您需要获取初始触摸位置并将其与最终触摸位置进行比较。当前触摸在 2 个开始和结束位置之间的百分比决定了正在使用动画的哪一帧。</p>
<p>假设您的杠杆动画中有 10 帧:</p>
<pre><code>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
</code></pre></p>
<p style="font-size: 20px;">关于iphone - 如何创建 Jetpack Joyride 大奖杠杆动画,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/13004963/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/13004963/
</a>
</p>
页:
[1]