我需要一些指導,因爲我不清楚我做錯了什麼。我所要做的只是在畫布的中心加載一個位圖,但它沒有顯示出來。我的文件路徑是正確的,我沒有看到我可能編碼不正確,我哪裏錯了?位圖圖片沒有顯示在畫布上
var canvas, stage, centerX, centerY;
function init() {
'use strict';
canvas = document.getElementById("easel");
stage = new createjs.Stage(canvas);
centerX = canvas.width/2;
centerY = canvas.height/2;
var ship = new createjs.Bitmap("../images/millenium.png"),
shipCenterX = ship.width/2,
shipCenterY = ship.height/2;
ship.x = centerX;
ship.y = centerY;
ship.regX = shipCenterX;
ship.regY = shipCenterY;
stage.addChild(ship);
stage.update();
}
這裏的關鍵是你必須確保在圖像加載後的階段更新。 – Lanny