您如何扫描javascript中是否有活动的东西

时间:2019-04-15 23:14:23

标签: javascript function object

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();}
}
};

我想每次按下鼠标和输出都不同

1 个答案:

答案 0 :(得分:0)

您还没有定义mouseIsPressed-使其看起来像这样:

var mouseIsPressed = 0;
document.body.onmousedown = () => ++mouseIsPressed;
document.body.onmouseup = () => --mouseIsPressed;