我正在使用EaselJS進行遊戲,而我仍在嘗試這個偉大的圖書館提供的功能。EaselJS spritesheet動畫使背景消失
我可能需要的是Alphamaskfilter類& Spritesheet類。
目前,我有一個這樣的畫布:
<canvas id = 'container3' width = 320px; height = 480px;
style = 'outline: 2px solid; margin-right: 10px;float:left;'></canvas>
,並在我的劇本,我有畫有藍顏色的矩形:所以現在我有一個藍色320
var ctx3 = document.getElementById('container3').getContext('2d');
ctx3.beginPath();
ctx3.rect(0,0,320,480);
ctx3.fillStyle = 'blue';
ctx3.fill();
* 480畫布。現在我有一個精靈表動畫就可以了, 這裏是精靈和代碼,我寫道: http://i.imgur.com/XumDvic.png
PS:前景幀爲200 * 200僅供參考。
stage = new createjs.Stage(document.getElementById('container3'));
var test = new Image();
test.src = 'trans_blackball.png';
test.onload = function(){
var sprite = new createjs.SpriteSheet({
images: [test],
frames: {width: 200, height: 200},
animations: {
born: [0,3,0]
}
});
var animation = new createjs.BitmapAnimation(sprite);
animation.gotoAndPlay("born");
animation.x = 10;
animation.y = 10;
animation.currentFrame = 0;
stage.addChild(animation);
createjs.Ticker.addListener(window);
createjs.Ticker.useRAF = true;
createjs.Ticker.setFPS(10);
}
function tick(){
stage.update();
}
好吧,我的問題是:我希望在藍色背景(矩形)的放大黑色圓圈的動畫,但我得到的是先在畫布上是藍色的,但對於某些小型秒後,整個畫布變白了,動畫在白色背景上運行,這是什麼原因,我該如何解決?
這裏有兩點可以幫助:
- 我與鍍鉻的工作,和我一起F12 &控制檯檢查,畫布的填充樣式依然是藍色的,甚至它出現在精靈動畫開始後白
如果我將畫布背景屬性設置爲藍色而不是繪製藍色矩形,那麼一切都很好!
<canvas id = 'container3' width = 320px; height = 480px; style = 'background: blue; outline: 2px solid; margin-right: 10px;float:left;'></canvas>
,但顯然這不是我想要的......
的問題可以通過不使用天然的畫布矩形,但使用EaselJS的形狀繪製矩形來解決,以及:
var shape = new createjs.Shape(); shape.graphics.beginFill("#ff0000").drawRect(0, 0, 320, 480); stage.addChild(shape);
但我還是想知道爲什麼本地矩形繪製代碼是不工作...
請發表我的英文不好,謝謝閱讀和任何幫助......如果有什麼不清楚的地方,我可以詳細說明..謝謝!