
Untitled
By: a guest on
Jun 20th, 2012 | syntax:
JavaScript | size: 0.72 KB | hits: 17 | expires: Never
window.onload= function()
{
Crafty.init(500,500)
Crafty.canvas.init()
Crafty.c("Block",
{
ready: true,
init: function()
{
this.addComponent("2D, Canvas, Mouse, Tween")
this.w=60
this.h=60
/*this.bind("Click", function(e)
{
this.tween({alpha : 0.2}, 60 )
}
)*/
this.bind("Draw", function(e)
{
this.draw(e.ctx,e.pos)
}
)
},
dimensions: function(_x,_y)
{
this.attr({x: _x, y:_y})
},
draw: function(ctx,pos)
{
ctx.strokeRect(this.x,this.y,this.w,this.h);
}
}
);
for(var i=0;i<5;i++)
{
for(var j=0;j<5;j++)
{
Crafty.e("Block").dimensions(i*60,j*60);
}
}
};