Advertisement
Guest User

Player

a guest
Aug 17th, 2010
3,316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var Player = new Class({
  2.     Extends : LibCanvas.Interfaces.Drawable,
  3.  
  4.     radius : 15,
  5.     color : '#080',
  6.  
  7.     initialize : function () {
  8.         // Элемент libcanvas присвоится после создания игрока
  9.         // и после вызова метода initialize, потому необходимо
  10.         // подождать это славное событие (по аналогии с domready)
  11.         this.bind('libcanvasSet', function (){
  12.             this.shape = new LibCanvas.Shapes.Circle({
  13.                 // центр мышки - объект LibCanvas.Point, указан по ссылке как центр
  14.                 // текущего круга, потому круг всегда будет следовать за указателем
  15.                 center : this.libcanvas.mouse.point,
  16.                 radius : this.radius
  17.             });
  18.         });
  19.     },
  20.  
  21.     draw : function () {
  22.         if (this.libcanvas.mouse.inCanvas) {
  23.             this.libcanvas.ctx.fill(this.shape, this.color);
  24.         }
  25.     }
  26. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement