File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed
examples/shapes/js/entities Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -32,16 +32,19 @@ game.ShapeObject = me.Entity.extend({
32
32
pointerMove : function ( event ) {
33
33
this . hover = false ;
34
34
35
- // calculate the final coordinates, as the move event is global (viewport);
36
- var parentPos = this . ancestor . getBounds ( ) . pos ;
37
- var x = event . gameX - this . pos . x - parentPos . x ;
38
- var y = event . gameY - this . pos . y - parentPos . y ;
39
-
40
- // the pointer event system will use the object bounding rect, check then with with all defined shapes
41
- for ( var i = this . body . shapes . length , shape ; i -- , ( shape = this . body . shapes [ i ] ) ; ) {
42
- if ( shape . containsPoint ( x , y ) ) {
43
- this . hover = true ;
44
- break ;
35
+ // move event is global (relative to the viewport)
36
+ if ( this . getBounds ( ) . containsPoint ( event . gameX , event . gameY ) ) {
37
+ // calculate the final coordinates
38
+ var parentPos = this . ancestor . getBounds ( ) . pos ;
39
+ var x = event . gameX - this . pos . x - parentPos . x ;
40
+ var y = event . gameY - this . pos . y - parentPos . y ;
41
+
42
+ // the pointer event system will use the object bounding rect, check then with with all defined shapes
43
+ for ( var i = this . body . shapes . length , shape ; i -- , ( shape = this . body . shapes [ i ] ) ; ) {
44
+ if ( shape . containsPoint ( x , y ) ) {
45
+ this . hover = true ;
46
+ break ;
47
+ }
45
48
}
46
49
}
47
50
You can’t perform that action at this time.
0 commit comments