簡體   English   中英

你如何掃描javascript中是否有活動的東西

[英]how do you scan if there is something active in javascript

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

我想每次都按下鼠標和輸出不同

你還沒有定義mouseIsPressed - 讓它變得如此:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM