0
これはapplabで実行されています。私のコードの55行目でエラーが発生しています。 TypeError:stringは関数ではありません。私はそれが、それが正しく実行されていない上記のコードのどこかにある関数であるかどうかわからない、誰かが見て、問題が何であるかを見ることができれば大いに感謝するだろう。Javascript 'TypeError:文字列が関数ではありません。'
onEvent("startButton", "click", function() {
setScreen("safeScreen");
endGame();
});//changes to the main games screen,after 2 minutes ends game
onEvent("retryButton", "click", function() {
setScreen("welcomeScreen");
});// changes screen to welcome screen from win screen
onEvent("againButto", "click", function() {
setScreen("welcomeScreen");
});//changes screen to welcome screen from lose screen
function endGame(){
setTimeout(function(){
setScreen("loseScreen");
},120000);
}
var input1=0;
setText("comboDisplay1",input1);//sets display1 to 0
var input2=0;
setText("comboDisplay2",input2);//sets display2 to 0
var input3=0;
setText("comboDisplay3",input3);//sets display3 to 0
onEvent("upButton1", "click", function(){
input1 = input1 + 1;
setText("comboDisplay1",input1);
});//when up button1 is pressed the number display changes
onEvent("upButton2", "click", function(){
input2= input2 + 1;
setText("comboDisplay2",input2);
});//when up button2 is pressed the number display changes
onEvent("upButton3", "click", function(){
input3= input3 + 1;
setText("comboDisplay3",input3);
});//when up button3 is pressed the display changes
onEvent("downButton1", "click", function(){
input1 = input1 - 1;
setText("comboDisplay1",input1);
});//when down button1 is pressed the number display changes
onEvent("downButton2", "click", function(){
input2 = input2 - 1;
setText("comboDisplay2",input2);
});//when down button2 is pressed the number display changes
onEvent("downButton3", "click", function(){
input3 = input3 - 1;
setText("comboDisplay3",input3);
});//when down button3 is pressed the number display changes
var playerInput;
var combination;
combination = [randomNumber(0,9),randomNumber(0,9),randomNumber(0,9)];//generates a random list of 3 numbers from 0 to 9
console.log(combination);
playerInput += getText("comboDisplay1","comboDisplay2","comboDisplay3");//assings the display numbers to the variable playerInput
function yellowLight() {
if (getNumber("comboDisplay1") != combination(0)) {
if (getNumber("comboDisplay1") == (combination(1)||combination(2))) {
showElement("yellowLight1");
}
}
if (getNumber("comboDisplay2") != combination(1)) {
if (getNumber("comboDisplay2") == (combination(0) || combination(2))) {
showElement("yellowLIght2");
}
}
if (getNumber("comboDisplay3") != combination(3)) {
if (getNumber("comboDisplay3") == (combination(0) || combination(1))) {
showElement("yellowLight3");
}
}
}
function greenLight(){
if(getNumber("comboDisplay1") == combination(0));
showElement("greenLight1");
if(getNumber("comboDisplay2") == combination(1));
showElement("greenLight2");
if(getNumber("comboDisplay3") == combination(2));
showElement("greenLight3");
}
//checks and shows a green light if the number is correct and in the right place
onEvent("submitButto", "click", function(){
if(playerInput== combination){
greenLight();
}
yellowLight();
});
55行目のコードはどれですか? – Arg0n
55行目はどこですか? – Weedoze
あなたはarray型の 'combination'変数を使い、'() 'を使ってアクセスしようとします。 '[] '構文を使う必要があります。 'コンビネーション[2]' – szymon