Terence Tan
unread,May 27, 2011, 10:07:43 PM5/27/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to The Render Engine
I was prototyping extending a Canvas context but it seems the
sourceRect are being ignored. I looked through to code and it seems
that unless I supply a 'GameObject', with width/height are ignored?
Code follows:
var Palette = function() {
return R.rendercontexts.CanvasContext.extend({
palettes: null,
paletteid:0,
targetRect:null,
constructor: function() {
this.base("Palette", 128, 128);
$(this.getSurface()).css("display", "none");
this.targetRect = R.math.Rectangle2D.create(0,0,32,32);
},
update: function(renderContext, time) {
if (this.palettes == null)
return;
renderContext.pushTransform();
this.base(renderContext, time);
var palette = this.palettes[0];
var attr = palette.info.tiles[0];
var tile = palette.getTile(attr.displayFrame);
renderContext.drawImage(this.targetRect,
palette.image,tile.sourceRect); <- The source rect is 0,0,32,32 and
the target rect is 0,0,32,32.
//this.get2DContext().putImageData(this.imgData, 0, 0);
renderContext.popTransform();
},