re.c('draw') .statics({ l:[], draw:function(c){ var lis = this.l; for(var i=0, b; i me){ //swap var t = l[him]; l[him] = l[me]; l[me] = t; } return this; }, drawBefore:function(en){ var l = re.c('draw').l; var him = l.indexOf(en); var me = l.indexOf(this); if(him < me){ //swap var t = l[him]; l[him] = l[me]; l[me] = t; } return this; }, screenX:function(x){ if(x){ this.posX = x + re.screen.posX; return this; } return this.posX - re.screen.posX; }, screenY:function(y){ if(y){ this.posY = y + re.screen.posY; return this; } return this.posY - re.screen.posY; }, /* Returns true or false wether the object is visible on screen. */ visible:function(){ return re.screen.hit(this.posX - this.regX, this.posY - this.regY, this.sizeX, this.sizeY); } }) .namespaces({ render:function(c){ this.draw_before(c); this.draw(c); this.draw_after(c); }, before:function(c){ c.save(); if(this.alpha != 1) c.staticsAlpha = this.alpha; if(this.screenable) c.translate(this.screenX(), this.screenY()); else c.translate(this.posX, this.posY); if(this.rotation) c.rotate(this.rotation * Math.PI / 180); if(this.scaleX != 1 || this.scaleY != 1) c.scale(this.scaleX, this.scaleY); }, after:function(c){ c.restore(); } });