Advertisement
Guest User

GameObject

a guest
Aug 17th, 2010
1,245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var GameObject = new Class({
  2.     Extends : LibCanvas.Interfaces.Drawable,
  3.  
  4.     initialize : function () {
  5.         this.bind('libcanvasSet', function (){
  6.             this.shape = new LibCanvas.Shapes.Circle({
  7.                 center : this.createPosition(),
  8.                 radius : this.radius
  9.             });
  10.         });
  11.     },
  12.  
  13.     // Получение полного ректангла - вынесли в метод и кешируем. Оно нам еще понадобится
  14.     getFull : function () {
  15.         return (this.full = this.full || this.libcanvas.ctx.getFullRectangle());
  16.     },
  17.  
  18.     // по-умолчанию берем случайную точку, и только если надо иначе - переопределяем метод
  19.     createPosition : function () {
  20.         return this.getFull().getRandomPoint();
  21.     },
  22.  
  23.     draw : function () {
  24.         this.libcanvas.ctx.fill(this.shape, this.color);
  25.     }
  26. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement