Skip to content

Instantly share code, notes, and snippets.

@unstoppablecarl
Created February 28, 2013 22:55
Show Gist options
  • Save unstoppablecarl/5060862 to your computer and use it in GitHub Desktop.
Save unstoppablecarl/5060862 to your computer and use it in GitHub Desktop.
// add tile
ig.game.addItem({
_layer : 'bg',
update: function(){
var mainMap = ig.game.getMapByName('main'),
tileSize = mainMain.tilesize,
ctx = ig.game.bgCanvasContext,
x = tileSize * x * ig.system.scale,
y = tileSize * y * ig.system.scale;
ctx.save();
ctx.fillStyle = 'tan';
ctx.fillRect(x,y,tileSize,tileSize);
ctx.restore();
},
draw:function(){
// empty the array we dont want to draw anything with these objects
ig.game.layers[this._layer] = [];
}
});
// remove tile
ig.game.addItem({
_layer : 'bg',
update: function(){
var mainMap = ig.game.getMapByName('main'),
tileSize = mainMain.tilesize,
ctx = ig.game.bgCanvasContext,
x = tileSize * x * ig.system.scale,
y = tileSize * y * ig.system.scale;
ctx.save();
ctx.clearRect(x,y,tileSize,tileSize);
ctx.restore();
},
draw:function(){
// empty the array we dont want to draw anything with these objects
ig.game.layers[this._layer] = [];
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment