Love2d isDown 相当于触摸控制?

Love2d isDown equivalent for touch control?

我有这个鼠标代码:

if love.mouse.isDown(1) then
   self.player:fire()
end

所以只要按住鼠标按钮,枪就会开火。我有屏幕上的触摸按钮,我可以用 love.touchpressed 捕捉单个触摸,但这一次会开枪。

我想要它,这样玩家就可以触摸屏幕上的按钮,只要按住它,枪就会连续开火。

使用:

if next(love.touch.getTouches()) ~= nil then
    self.player:fire()
end

或定义函数is_emptyany:

function is_empty(t)
    return next(t) == nil
end

if not is_empty(love.touch.getTouches()) then
    self.player:fire()
end

function any(t)
    return next(t) ~= nil
end

if any(love.touch.getTouches()) then
    self.player:fire()
end