我有一個水龍頭按鈕,可以讓我的角色一拳,但如果快速連續敲擊,我的角色只是在他完成之前繼續執行拳擊動畫,所以他只是在奇怪地抽搐......我一直在擺弄它幾個小時,但可以似乎沒有弄明白。in corona如何讓精靈圖片動畫在被允許再次播放前結束播放?
我想這工作的龍頭,但沒有工作不夠快後去除按鈕事件監聽器(我仍然設法在兩個或三個水龍頭把它踢之前)
我試圖具有一個「ispunching」變量頂部被切換到真正的動畫播放,但我仍然可以得到一些水龍頭之前,踢在任何..
我知道這可能是一種簡單的方法,我是愚蠢的!任何幫助感謝!
謝謝!
子畫面數據和序列:
local sheetData1 = { width=175, height=294, numFrames=11, sheetContentWidth=1925, sheetContentHeight=294}
local sheet1 = graphics.newImageSheet("guy.png", sheetData1)
local sheetData2 = { width=220, height=294, numFrames=4, sheetContentWidth=880, sheetContentHeight=294 }
local sheet2 = graphics.newImageSheet("guy2.png", sheetData2)
local sheetData3 = { width=261, height=300, numFrames=8, sheetContentWidth=2088, sheetContentHeight=300 }
local sheet3 = graphics.newImageSheet("guy3.png", sheetData3)
local sequenceData = {
{ name="walk", sheet=sheet1, start=5, count=4, time=800, loopCount=0 },
{ name="idle", sheet=sheet1, frames={ 1,2,3,4 }, time=2000, loopCount=0 },
{ name="punch", sheet=sheet2, start=1, count=4, time=400, loopCount=1 },
{ name="kick", sheet=sheet3, start=1, count=4, time=400, loopCount=1 },
{ name="kick2", sheet=sheet3, start=5, count=4, time=400, loopCount=1 },
{ name="jump", sheet=sheet1, start=9, count=3, time=400, loopCount=1 }
}
字符:
guy = display.newSprite(group, sheet1, sequenceData)
physics.addBody(guy, "static", { friction=0.5, bounce=0 })
guy.x = 600
guy.y = 600
空閒姿勢:
local function idlePose()
guy:setSequence("idle")
guy:play()
end
顯示按鈕:
local btn1 = display.newImage ("button1.png")
btn1.x = 1100
btn1.y = 510
btn1:scale (1.5,1.5)
btn1.alpha=0.5
group:insert(btn1)
按鈕代碼:
local function onTap(event)
if guy.sequence == "punch" and guy.isPlaying == true then
print("isplaying")
return
else
print("notplaying")
guy:setSequence("punch")
guy:play()
timer.performWithDelay(400, idlePose)
end
end
btn1:addEventListener("tap", onTap)
您能否提供您正在使用的示例代碼...? –
剛剛爲我的按鈕添加代碼歡呼 – user3059109