как вы сканируете, если есть что-то активное в JavaScript - PullRequest
0 голосов
/ 16 апреля 2019

stage3 - после этапа 2. Я хочу знать, как определить, активны ли mouseIsPressed и stage2.

Я уже попробовал if(mouseIsPressed&&stage2===true){so on}

var hp=100;
var name=["boromon","telemon","heptamon","coromon"];
var boromon={
eyecolor:"blue",
skincolor:[0,0,255],
abilitys:["beam of life","blinding bite","stare strike"]
};
var enemy=[hp,name[1]];
fill(255, 0, 0);
text(name[0]+" wants to be your freind"+"                               click to accept",10,10);
var currentCharacter=[];


fill(41, 23, 23);
text(currentCharacter,10,10);
var stage2=function(){
background(255, 0, 0);
text(currentCharacter+" is now your freind                          click to continue",10,10);

};

var stage3=function(){
background(0, 174, 255);
var star=getImage("space/star");
image(star,10,10);
image(star,10,10);
image(star,10,10);
image(star,10,10);
};


draw=function() {
    if(mouseIsPressed)
{currentCharacter=name[0];}

if (mouseIsPressed){
    stage2();

if(mouseIsPressed){stage3();}
}
};

Iхочу нажать кнопку мыши и вывод будет разным каждый раз

1 Ответ

0 голосов
/ 16 апреля 2019

Вы не определили mouseIsPressed - сделайте так, чтобы:

var mouseIsPressed = 0;
document.body.onmousedown = () => ++mouseIsPressed;
document.body.onmouseup = () => --mouseIsPressed;
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...