").css({
top:0,
position:'relative'
}).appendTo(Q.el);
this.dom = this.el[0];
this.wrapper = this.el.wrap('
').parent().css({
position:'absolute',
left:0,
top:0
});
this.scale = 1;
this.wrapper_dom = this.wrapper[0];
this._super(scene);
},
insert: function(itm) {
if(itm.dom) { this.dom.appendChild(itm.dom); };
return this._super(itm);
},
destroy: function() {
this.wrapper.remove();
this._super();
},
rescale: function(scale) {
this.scale = scale;
Q.scaleDOM(this.wrapper_dom,scale);
},
centerOn: function(x,y) {
this.x = Q.width/2/this.scale - x;
this.y = Q.height/2/this.scale - y;
Q.positionDOM(this.dom,this.x,this.y);
}
});
}
Q.domOnly = function() {
Q.Stage = Q.DOMStage;
Q.setup = Q.setupDOM;
Q.Sprite = Q.DOMSprite;
return Q;
};
Q.DOMTileMap = Q.DOMSprite.extend({
// Expects a sprite sheet, along with cols and rows properties
init:function(props) {
var sheet = Q.sheet(props.sheet);
this._super(_(props).extend({
w: props.cols * sheet.tilew,
h: props.rows * sheet.tileh,
tilew: sheet.tilew,
tileh: sheet.tileh
}));
this.shown = [];
this.domTiles = [];
},
setImage: function() { },
setup: function(tiles,hide) {
this.tiles = tiles;
for(var y=0,height=tiles.length;y= 0 && y < this.p.rows) &&
(x >= 0 && x < this.p.cols);
},
get: function(x,y) { return this.validTile(x,y) ?
this.tiles[y][x] : null; },
getDom: function(x,y) { return this.validTile(x,y) ?
this.domTiles[y][x] : null; },
set: function(x,y,frame) {
if(!this.validTile(x,y)) return;
this.tiles[y][x] = frame;
var domTile = this.getDom(x,y);
this._setFile(domTile,frame);
},
show: function(x,y) {
if(!this.validTile(x,y)) return;
if(this.shown[y][x]) return;
this.getDom(x,y).style.visibility = 'visible';
this.shown[y][x] = true;
},
hide: function(x,y) {
if(!this.validTile(x,y)) return;
if(!this.shown[y][x]) return;
this.getDom(x,y).style.visibility = 'hidden';
this.shown[y][x] = false;
}
});
};