Guest User

GameObject

a guest
Aug 17th, 2010
988
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. });
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×