-1
私は本当に不満です、JSは私のために働きません。私が今回作った小さな間違いは分かりませんが、もしあなたがそれを指摘すれば、私は感謝しています。私はアニメーションや何かをしたくない、誰かが私にエラーを教えてくれればうれしい。JavaScriptキャンバス白いスクリーン
window.onload = function(){
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
canvas.width = window.innerWidth();
canvas.height = window.innerHeight();
var ship = function() {
this.x = canvas.width/2;
this.y = canvas.height/2;
this.velocityX = 0;
this.velocityY = 0;
this.accelerationX = 0;
this.accelerationY = 0;
this.show = function() {
//background
context.fillStyle = 'rgb(0,0,0)';
context.fillRect(0,0,canvas.width,canvas.height);
//update
this.velocityX += this.accelerationX;
this.velocityY += this.accelerationY;
this.x += this.velocityX;
this.y += this.velocityY;
//draw
context.save();
context.translate(this.x,this.y) ;
context.fillStyle = 'rgb(0,0,0)';
context.fillRect(0,0,20,30);
context.restore();
};
};
var myship = new ship();
myship.show();
};
画面上の 'canvas'は何色ですか? –
私は黒い矩形も黒いオブジェクトも見ることができないので、私はそれをしました、白い画面が表示されます – udbhavs
いいえ、JSHintも試しました。私はcodepenでこれをやっています。 – udbhavs