我有以下使用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