1 decade ago by Joncom
It would be nice if ig.Image.draw() contained flipX and flipY parameters.
Currently only drawTile() has it, which is handy... but I've had to inject() the same feature into draw() when I don't want to be restricted to using a whole tile.
EDIT
If anybody is interested in how this is done, I found this useful:
Currently only drawTile() has it, which is handy... but I've had to inject() the same feature into draw() when I don't want to be restricted to using a whole tile.
EDIT
If anybody is interested in how this is done, I found this useful:
ig.Image.inject({ draw: function( targetX, targetY, sourceX, sourceY, width, height, flipX, flipY ) { if( !this.loaded ) { return; } var scale = ig.system.scale; sourceX = sourceX ? sourceX * scale : 0; sourceY = sourceY ? sourceY * scale : 0; width = (width ? width : this.width) * scale; height = (height ? height : this.height) * scale; var scaleX = flipX ? -1 : 1; var scaleY = flipY ? -1 : 1; if( flipX || flipY ) { ig.system.context.save(); ig.system.context.scale( scaleX, scaleY ); } ig.system.context.drawImage( this.data, sourceX, sourceY, width, height, ig.system.getDrawPos(targetX) * scaleX - (flipX ? width : 0), ig.system.getDrawPos(targetY) * scaleY - (flipY ? height : 0), width, height ); if( flipX || flipY ) { ig.system.context.restore(); } ig.Image.drawCount++; }, });