提示コードですが下記のエラーコードが出る原因が知りたいです。なぜ定義してるにも関わらず未定義というエラーが出るのでしょうか?原因わかりません。上から下に向かって読み込んでいくのはずなのでここで定義されているのではないのでしょうか?
エラーコード
Game.js:76 Uncaught ReferenceError: getColor is not defined at new Puyo (Game.js:76:9) at new Game (Game.js:111:21) at Main.js:3:14
javascript
1 2// ################################################################ 3// # ぷよ クラス 4// ################################################################ 5class Puyo 6{ 7 /////////////////////////////////////////////////////////////////////// 8 getColor(rand) 9 { 10 if(rand == 0) 11 { 12 return fill(255,0,0); 13 } 14 else if(rand == 1) 15 { 16 return fill(0,255,0); 17 } 18 else if(rand == 2) 19 { 20 return fill(0,0,255); 21 } 22 else if(rand == 3) 23 { 24 return fill(255,255,0); 25 } 26 else if(rand == 4) 27 { 28 return fill(128,0,128); 29 } 30 31 32 } 33//////////////////////////////////////////////////////////////////////// 34 constructor() 35 { 36 this.color = getColor(random(0,5)); //色 37 this.position = new Vector(0,0); //座標 38 } 39 40 setPosition(pos) 41 { 42 this.position = pos; 43 } 44 45 46 47 Renderer() 48 { 49 fill(this.color); 50 noStroke(); 51 circle(this.position.x,this.position.y,CELL_SIZE); 52 53 } 54 55 56} 57 58 59 60 61 62// ################################################################ 63// # ループ クラス 64// ################################################################ 65class Game 66{ 67 68//////////////////////////////////////////////////////////////// 69 constructor() 70 { 71 this.puyo = new Puyo(); 72 //this.control = new Control(); 73 } 74////////////////////////////////////////////////////////////// 75 Update() 76 { 77 //puyo.setPosition(this.control.getPosition()); 78 } 79 80 Renderer() 81 { 82 //this.puyo.Renderer(); 83 //fill(color(0,255,0,255)); 84 //noStroke(); 85 //circle(this.position.x,this.position.y,CELL_SIZE); 86 } 87 88 89}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。