1
我已經使用隊列中的圖像創建了一個位圖。接下來,我試圖通過更新image.src屬性來更改圖像,但它不起作用,因爲它需要路徑指向圖像的位置。在這種情況下,如何將第一張圖像更改爲第二張圖像。我假設過渡將平穩,因爲圖像已經加載。如何使用preloadjs加載圖像時在createjs中更改位圖圖像?
var queue = new createjs.LoadQueue();
queue.on("complete", loaded);
queue.loadManifest([{
id: "one",
src: "image1.png"
},
{
id: "two",
src: "image2.png"
}
]);
var stage = new createjs.Stage('canvas'),
img1 = queue.getResult("one"),
img2 = queue.getResult("two");
var changingImage = new createjs.Bitmap(img1);
stage.addChild(childImage);
stage.update();
function changeImage() {
changingImage.image.src = img2;
stage.update();
}
在調用函數changeImage()時,圖像必須在changesImage中更改。
謝謝@gMirian –