local canfire = "cooldown" --"canfire" "cooldown" local interval=0 scheduler.scheduleUpdateGlobal(function() print(canfire) print(interval) if canfire == "cooldown" then interval=interval+1 if interval > 60*2 then canfire="canfire" interval=0 end end end) local layer = display.newLayer():addTo(self) layer:setTouchEnabled(true) layer:setTouchMode(cc.TOUCH_MODE_ONE_BY_ONE) layer:addNodeEventListener(cc.NODE_TOUCH_EVENT, function (event) local x, y, prevX, prevY = event.x, event.y, event.prevX, event.prevY if event.name == "began" then print("touch") if canfire == "canfire" then print("fire") canfire = "cooldown" end elseif event.name == "moved" then elseif event.name == "ended" then end return true end)
时间: 2024-10-12 20:45:23