簡単なゲームを作ろうとしていますが、弾むボールの画像が必要な場合はどうすればよいですか? 私はこれをやっています-
function draw() {
ctx.clearRect(0, 0, 300, 300);
if (ctx.getContext) {
Snooker = new Image();
Snooker.onload = loadingComplete;
Snooker.src = "http://www.wpclipart.com/toys/balls/red_snooker_ball.png";
}
x += dx;
y += dy;
bounce();
}
そして->
function init() {
var ctx = document.getElementById("canvas");
return setInterval(draw, 10);
}
これでキャンバスは空白です。
ここにフィドルリンクがあります - http://jsfiddle.net/stackmanoz/QcLTw/1/
この単純なボールの代わりに追加したい画像 - http://www.wpclipart.com/toys/balls/red_snooker_ball.png