Permalink
Browse files

when determining which entity the mouse is over take the map set by a…

…reamap into account.

The behavior was changed in d93e87d which caused isometric games to malfunction.
This fixes 115 (well, the issue raised in the coment of that ticket)
  • Loading branch information...
sorenbs committed Aug 18, 2011
1 parent 3e0fe0d commit b6694af580fcae0bf14d2efbfb7c6f14ccb23e66
Showing with 5 additions and 2 deletions.
  1. +3 −0 src/2D.js
  2. +2 −2 src/controls.js
View
@@ -385,6 +385,9 @@ Crafty.c("2D", {
* an object can't be passed. The arguments require the x and y value
*/
isAt: function(x,y) {
+ if(this.map) {
+ return this.map.containsPoint(x,y);
+ }
return this.x <= x && this.x + this.w >= x &&
this.y <= y && this.y + this.h >= y;
},
View
@@ -32,10 +32,10 @@ Crafty.extend({
tar = tar.parentNode;
}
ent = Crafty(parseInt(tar.id.replace('ent', '')))
- if (ent.has('Mouse'))
+ if (ent.has('Mouse') && ent.isAt(x,y))
closest = ent;
}
- else {
+ if(!closest) {
//search for all mouse entities
q = Crafty.map.search({_x: x, _y:y, _w:1, _h:1}, false);

0 comments on commit b6694af

Please sign in to comment.