js/Scene/default/Hud.js
function (destCtx, debug) {
                if (!this.visible) {
                    return;
                }

                // auto goto next frame
                if (this.currentAnimName.length) {
                    this.advanceFrame(this.currentAnimName);
                }

                var w = this.getCurrentWidth(),
                    scaledW = w * this.scale,
                    h = this.getCurrentHeight(),
                    scaledH = h * this.scale,
                    subScaledW = (scaledW / 2) | 0,
                    subScaledH = (scaledH / 2) | 0,
                    x = this.getCurrentOffsetX(),
                    y = this.getCurrentOffsetY(),
                    drawX = this.x + this.getCurrentShiftX(),
                    drawY = this.y + this.getCurrentShiftY(),
                    mapOffsetX = this.currentMap && this.currentMap.viewportX || 0,

                    mapOffsetY = this.currentMap && this.currentMap.viewportY || 0;

                // TODO: fix map position when rotate is used
                if ($.isEmptyObject(this.fxQueue)) {
                    if (this.type === 'enemy1' && window.todo)
                        var date = new Date().getTime();
                    destCtx.drawImage(this.image, x, y, w, h, drawX + mapOffsetX, drawY + mapOffsetY, scaledW, scaledH);
                    if (this.type === 'enemy1' && window.todo) {
                        var date2 = new Date().getTime();
                        console.log('drawSprite call duration:', date2 - date);
                    }
                    if (this.isDebug === true || debug === true) {
                        this.showHitBox(destCtx);
                    }
                } else {
                    this.executeFx(destCtx);
                    // translate to keep the object as its position
                    destCtx.save();
                    destCtx.translate(drawX + mapOffsetX + subScaledW, drawY + mapOffsetY + subScaledH);
                    destCtx.rotate(this.angle);
                    destCtx.drawImage(this.image, x, y, w, h, -subScaledW, -subScaledH, scaledW, scaledH);
                    if (this.isDebug === true || debug === true) {
                        this.showHitBox(destCtx);
                    }
                    destCtx.restore();
                }
            }
function (destCtx, debug) {
                if (!this.visible) {
                    return;
                }

                // auto goto next frame
                if (this.currentAnimName.length) {
                    this.advanceFrame(this.currentAnimName);
                }

                var w = this.getCurrentWidth(),
                    scaledW = w * this.scale,
                    h = this.getCurrentHeight(),
                    scaledH = h * this.scale,
                    subScaledW = (scaledW / 2) | 0,
                    subScaledH = (scaledH / 2) | 0,
                    x = this.getCurrentOffsetX(),
                    y = this.getCurrentOffsetY(),
                    drawX = this.x + this.getCurrentShiftX(),
                    drawY = this.y + this.getCurrentShiftY(),
                    mapOffsetX = this.currentMap && this.currentMap.viewportX || 0,

                    mapOffsetY = this.currentMap && this.currentMap.viewportY || 0;

                // TODO: fix map position when rotate is used
                if ($.isEmptyObject(this.fxQueue)) {
                    if (this.type === 'enemy1' && window.todo)
                        var date = new Date().getTime();
                    destCtx.drawImage(this.image, x, y, w, h, drawX + mapOffsetX, drawY + mapOffsetY, scaledW, scaledH);
                    if (this.type === 'enemy1' && window.todo) {
                        var date2 = new Date().getTime();
                        console.log('drawSprite call duration:', date2 - date);
                    }
                    if (this.isDebug === true || debug === true) {
                        this.showHitBox(destCtx);
                    }
                } else {
                    this.executeFx(destCtx);
                    // translate to keep the object as its position
                    destCtx.save();
                    destCtx.translate(drawX + mapOffsetX + subScaledW, drawY + mapOffsetY + subScaledH);
                    destCtx.rotate(this.angle);
                    destCtx.drawImage(this.image, x, y, w, h, -subScaledW, -subScaledH, scaledW, scaledH);
                    if (this.isDebug === true || debug === true) {
                        this.showHitBox(destCtx);
                    }
                    destCtx.restore();
                }
            }
function ( destCtx , debug ) { if ( ! this . visible ) { return ; } // auto goto next frame if ( this . currentAnimName . length ) { this . advanceFrame ( this . currentAnimName ) ; } var w = this . getCurrentWidth ( ) , scaledW = w * this . scale , h = this . getCurrentHeight ( ) , scaledH = h * this . scale , subScaledW = ( scaledW / 2 ) | 0 , subScaledH = ( scaledH / 2 ) | 0 , x = this . getCurrentOffsetX ( ) , y = this . getCurrentOffsetY ( ) , drawX = this . x + this . getCurrentShiftX ( ) , drawY = this . y + this . getCurrentShiftY ( ) , mapOffsetX = this . currentMap && this . currentMap . viewportX || 0 , mapOffsetY = this . currentMap && this . currentMap . viewportY || 0 ; // TODO: fix map position when rotate is used if ( $ . isEmptyObject ( this . fxQueue ) ) { if ( this . type === 'enemy1' && window . todo ) var date = new Date ( ) . getTime ( ) ; destCtx . drawImage ( this . image , x , y , w , h , drawX + mapOffsetX , drawY + mapOffsetY , scaledW , scaledH ) ; if ( this . type === 'enemy1' && window . todo ) { var date2 = new Date ( ) . getTime ( ) ; console . log ( 'drawSprite call duration:' , date2 - date ) ; } if ( this . isDebug === true || debug === true ) { this . showHitBox ( destCtx ) ; } } else { this . executeFx ( destCtx ) ; // translate to keep the object as its position destCtx . save ( ) ; destCtx . translate ( drawX + mapOffsetX + subScaledW , drawY + mapOffsetY + subScaledH ) ; destCtx . rotate ( this . angle ) ; destCtx . drawImage ( this . image , x , y , w , h , - subScaledW , - subScaledH , scaledW , scaledH ) ; if ( this . isDebug === true || debug === true ) { this . showHitBox ( destCtx ) ; } destCtx . restore ( ) ; } }
we simply override the draw method
we simply override the draw method