如何在 p5.js 中将 keyPressed() 转换为移动触摸保持

How to Convert keyPressed() to touch hold for mobile in p5.js

我刚刚使用 p5.js 制作了一个游戏。在那场比赛中,我只需要按住 spacebar 就可以移动。现在我想为移动版制作它,但我不知道如何将按住 space 栏转换为触摸并按住移动版。那么有人知道如何转换它们吗?

您可以使用 mouseIsPressed 布尔值。

function draw() { 
    ...
    if (mouseIsPressed) {
        movement(); // or add whatever you are using for movement here
    }
    ...
}