###わからないこと
javascriptのfor文の閉じかっこのところで
Uncaught SyntaxError: Unexpected token )
と、エラーが出てしまいます。
for(var i = 0; i < shot_poi.length, i++) { ctx.fillRect(shot_poi[i][0], shot_poi[i][1], width, width); }
原因がよく分かりません。
よく起こります。
とても初歩的な質問ですが、回答お願いします。
###備考
var player = function() { var pos = [rand(0,70) * 20, rand(0,34) * 20]; var shot_poi = []; this.draw = function() { ctx.beginPath(); ctx.fillStyle = '#ed7000'; ctx.arc(pos[0] + width/2, pos[1] + width/2, width/2,0,2*Math.PI); ctx.fill(); ctx.beginPath(); ctx.fillStyle = '#fff'; ctx.arc(pos[0] + width/2, pos[1] + width/2, width/3,0,2*Math.PI); ctx.fill(); ctx.beginPath(); ctx.fillStyle = '#8B008B'; for(var i = 0; i < shot_poi.length, i++) { ctx.fillRect(shot_poi[i][0], shot_poi[i][1], width, width); } } this.shot = function() { var x = pos[0] + width; var y = pos[1] + width; if (shot_poi.indexOf([x,y]) || x >= canvas.width || y>= canvas.height) { return; } shot_poi.push([x,y]); console.log(shot_poi[0]); console.log(shot_poi[0][0]); console.log(shot_poi[0][1]); } this.clear = function() { ctx.clearRect(0,0,canvas_width,canvas_height); drawStage(); } this.move = function(x) { switch(x) { case 37: this.clear(); pos[0] -= 20; this.draw(); break; case 38: this.clear(); pos[1] -= 20; this.draw(); break; case 39: this.clear(); pos[0] += 20; this.draw(); break; case 40: this.clear(); pos[1] += 20; this.draw(); break; } } this.draw(); }
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/04/14 04:38