Using custom textures

When you create a sheet you can always access its HTML5 2d drawing context using the context property. Thus it is quite easy to use custom textures, since you just have to draw on the sheet's canvas using its context:

var sheet = new sheetengine.Sheet({x:0,y:0,z:40}, {alphaD:0,betaD:0,gammaD:0}, {w:80,h:80});
var img = new Image();
img.onload = function() {
  sheet.context.drawImage(img, 0,0);

  // draw the scene
img.src = 'images/myimage.png';      
Just make sure you call drawScene only after the image has been loaded and drawn onto the canvas. If you want to change texture after the sheet has been displayed you will have to call the

after drawing on the context. See an example for this case at sprite animation.

Last edited Dec 11, 2012 at 8:08 PM by dobsonl, version 3


No comments yet.