1 decade ago by jizaymes
Hello,
I've run into an issue thats led me down the path of having multiple canvases to overcome some deficiencies. First i'll state those which, if anyone has any help, may render my endeavor moot.
The game i'm working on has background layers and a layer on top of the entities layer so that I can have the feeling of being able to walk behind trees and such.
this.backdrop = new ig.Image( 'media/backdrop.png' ); this.canvas = ig.$new('canvas'); this.canvas.height = ig.system.realHeight; this.canvas.width = ig.system.realWidth; this.context = this.canvas.getContext('2d');
draw() code:
index.html
I've run into an issue thats led me down the path of having multiple canvases to overcome some deficiencies. First i'll state those which, if anyone has any help, may render my endeavor moot.
The game i'm working on has background layers and a layer on top of the entities layer so that I can have the feeling of being able to walk behind trees and such.
this.backdrop = new ig.Image( 'media/backdrop.png' ); this.canvas = ig.$new('canvas'); this.canvas.height = ig.system.realHeight; this.canvas.width = ig.system.realWidth; this.context = this.canvas.getContext('2d');
draw() code:
this.oldValues = { system: { context: ig.system.context }, game: { screen: { x: ig.game.screen.x, y: ig.game.screen.y } } }; ig.system.context = this.context; // either of these both work if the context switch above is commented. // this.backdrop.draw(ig.game.HUD.X,ig.game.HUD.Y); ig.system.context.drawImage( this.backdrop.data, ig.game.HUD.X, ig.game.HUD.Y, this.size.x, this.size.y ); <.. do stuff ..> ig.system.context = this.oldValues.system.context;
index.html
<canvas id="canvas"></canvas> <canvas id="hudLayer"></canvas>