Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 20th, 2012  |  syntax: JavaScript  |  size: 0.72 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. window.onload= function()
  2. {
  3.         Crafty.init(500,500)
  4.         Crafty.canvas.init()
  5.         Crafty.c("Block",
  6.         {
  7.                 ready: true,
  8.                 init: function()
  9.                 {
  10.                         this.addComponent("2D, Canvas, Mouse, Tween")
  11.                         this.w=60
  12.                         this.h=60
  13.  
  14.                        
  15.                         /*this.bind("Click", function(e)
  16.                                 {
  17.                                                 this.tween({alpha : 0.2}, 60 )
  18.                                 }
  19.                         )*/
  20.                        
  21.                         this.bind("Draw", function(e)
  22.                                 {
  23.                                         this.draw(e.ctx,e.pos)
  24.                                 }
  25.                         )
  26.                        
  27.                 },
  28.                 dimensions: function(_x,_y)
  29.                 {
  30.                         this.attr({x: _x, y:_y})
  31.                 },
  32.                 draw: function(ctx,pos)
  33.                 {
  34.                         ctx.strokeRect(this.x,this.y,this.w,this.h);
  35.                 }
  36.         }
  37.         );
  38.         for(var i=0;i<5;i++)
  39.     {
  40.         for(var j=0;j<5;j++)
  41.         {
  42.             Crafty.e("Block").dimensions(i*60,j*60);
  43.         }
  44.     }
  45. };