我一直在尝试使用 Javascript 和 HTML5 创建游戏,但我无法检查 ScoreValue 文本字段(附加到 Score 变量)以查看玩家是赢还是输。
评分:
var Contacts;
var Contacts2;
var Contact;
var Contact2;
var Contact3;
var Contact4;
var Contact5;
var Contact6;
var Contact7;
var Contact8;
var Score;
var Score = 1;
var Contact = function(){
document.getElementById('Alien1').style.display="none";
document.getElementById('ScoreValue').innerHTML = Score++;
};
var Contact2 = function(){
//for(var Contacts = 1; Contacts > 2;)
document.getElementById('Alien2').style.display="none";
document.getElementById('ScoreValue').innerHTML = Score++;
};
var Contact3 = function(){
//for(var Contacts = 1; Contacts > 2;)
document.getElementById('Alien3').style.display="none";
document.getElementById('ScoreValue').innerHTML = Score++;
//Contacts++
};
var Contact4 = function(){
//for(var Contacts = 1; Contacts > 2;)
document.getElementById('Alien4').style.display="none";
document.getElementById('ScoreValue').innerHTML = Score++;
//Contacts++
};
var Contact5 = function(){
//for(var Contacts = 1; Contacts > 2;)
document.getElementById('Alien5').style.display="none";
document.getElementById('ScoreValue').innerHTML = Score++;
//Contacts++
};
var Contact6 = function(){
//for(var Contacts = 1; Contacts > 2;)
document.getElementById('Alien6').style.display="none";
document.getElementById('ScoreValue').innerHTML = Score++;
//Contacts++
};
var Contact7 = function(){
//for(var Contacts = 1; Contacts > 2;)
document.getElementById('Alien7').style.display="none";
document.getElementById('ScoreValue').innerHTML = Score++;
//Contacts++
};
var Contact8 = function(){
//for(var Contacts = 1; Contacts > 2;)
document.getElementById('Alien8').style.display="none";
document.getElementById('ScoreValue').innerHTML = Score++;
//Contacts++
};
到目前为止的分数检查:
//timer = setTimeout(LevelChangeCheck,1000000);
//var LevelChangeCheck = function(){
if (document.getElementById('ScoreValue').value == "8"){
if(confirm("Hello, do you like cake?")){
alert("BLAH")
};
};
//};
注意-这是一个故意的小样本(整页是 1000 多行混合代码),所以如果你想查看完整的东西,请访问 hordeattack.tumblr.com