我有以下使用mootools和mootools畫布庫編寫的代碼片段。使用javascript需要幫助使用此功能銷燬畫布上的項目
CANVAS.init({ canvasElement : 'canvas', interactive : true });
var itemlayer = CANVAS.layers.add({ id : 'items' });
for(var j = 0; j < 5; j++)
{
for(var i = 0; i < 5; i++)
{
itemlayer.add({
id : 'item-'+i + '-' + j,
x : 51 * i,
y : 51 * j,
w : 50,
h : 50,
state : 'normal',
interactive : true, //although they have no interactive events!
colors : { normal : '#f00', hover : '#00f' },
events : {
onDraw : function(ctx){
ctx.fillStyle = this.colors[this.state];
ctx.fillRect(this.x,this.y,this.w,this.h);
this.setDims(this.x,this.y,this.w,this.h);
}
}
});
}
}
CANVAS.addThread(new Thread({
id : 'myThread',
onExec : function(){
CANVAS.clear().draw();
}
}));
現在我想要做的就是在畫布上繪製後立即摧毀廣場。
的文檔,這樣做中給出的函數是
item.destroy();
問題是,無論我怎麼做,我都無法從畫布上銷燬對象!什麼是正確的方法來做到這一點?
參考code here implemented on js fiddle.
投票刪除它。這個問題是由於一個錯誤而產生的,並且在一個相關的問題中得到解決。 – Shouvik 2010-10-12 04:52:52