Skip to content

Commit

Permalink
Ticket #135 : fixed floating object position and click area when map …
Browse files Browse the repository at this point in the history
…are smaller than screen
  • Loading branch information
obiot committed Oct 16, 2012
1 parent c6848fc commit e37d881
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/GUI/HUD.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,8 @@
}
}
}
// make sure we keep the HUD at the default origin 0,0 screen position
var map_pos = me.game.currentLevel.pos;
// draw the HUD
context.drawImage(this.HUDCanvasSurface.canvas, this.pos.x -map_pos.x, this.pos.y -map_pos.y);
context.drawImage(this.HUDCanvasSurface.canvas, this.pos.x, this.pos.y);
// reset the flag
this.HUD_invalidated = false;
}
Expand Down
8 changes: 6 additions & 2 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -995,8 +995,12 @@ var me = me || {};
// save the current context
context.save();
// translate by default to screen coordinates
context.translate(-posx, -posy);

context.translate(-posx, -posy)

// substract the map offset to current the current pos
posx -= me.game.currentLevel.pos.x;
posy -= me.game.currentLevel.pos.y;

// if feature disable, we only have one dirty rect (the viewport area)
for ( var r = dirtyRects.length, rect; r--, rect = dirtyRects[r];) {
// parse all objects
Expand Down
2 changes: 1 addition & 1 deletion src/input/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
if (handler.floating===false) {
var v = {x: x + vpos.x - map_pos.x, y: y + vpos.y - map_pos.y };
} else {
var v = {x: x, y: y};
var v = {x: x - map_pos.x, y: y - map_pos.y};
}
// call the defined handler
if ((handler.rect === null) || handler.rect.containsPoint(v)) {
Expand Down

0 comments on commit e37d881

Please sign in to comment.