I want the npc to walk only when the button is pressed.
I don’t care about controlling it with dom.
I want it to stop when I’m not pressing a button, just like the player.
jumpbutton.addEventListener('mouseover', () => {
onEvent1();
return;
});
function onEvent1() {
for (const npcSprite of npc.getChildren()) {
if (npcSprite.body.onFloor()) {
npcSprite.setVelocityX(30);
}
// npcSprite.play('rightNpc', true);
}
}
type or paste code here