Created
January 10, 2011 17:32
-
-
Save geoffb/773101 to your computer and use it in GitHub Desktop.
ImpactJS Weltmiester: Don't consider entity offset when snapping to grid.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/htdocs/lib/weltmeister/edit-entities.js b/htdocs/lib/weltmeister/edit-entities.js | |
index f9d9250..6272f3e 100644 | |
--- a/htdocs/lib/weltmeister/edit-entities.js | |
+++ b/htdocs/lib/weltmeister/edit-entities.js | |
@@ -141,7 +141,7 @@ wm.EditEntities = ig.Class.extend({ | |
for( var i = 0; i < this.entities.length; i++ ) { | |
var ent = this.entities[i]; | |
if( ent.touches(this.selector) ) { | |
- this.selector.offset = {x: (x - ent.pos.x + ent.offset.x), y: (y - ent.pos.y + ent.offset.y)}; | |
+ this.selector.offset = {x: (x - ent.pos.x), y: (y - ent.pos.y)}; | |
this.selectEntity( ent ); | |
this.wasSelectedOnScaleBorder = this.isOnScaleBorder( ent, this.selector ); | |
return ent; | |
@@ -236,11 +236,9 @@ wm.EditEntities = ig.Class.extend({ | |
moveSelectedEntity: function( x, y ) { | |
x = | |
- ( (x - this.selector.offset.x ) / this.gridSize ).round() | |
- * this.gridSize + this.selectedEntity.offset.x; | |
+ ( (x - this.selector.offset.x ) / this.gridSize ).round() * this.gridSize; | |
y = | |
- ( (y - this.selector.offset.y ) / this.gridSize ).round() | |
- * this.gridSize + this.selectedEntity.offset.y; | |
+ ( (y - this.selector.offset.y ) / this.gridSize ).round() * this.gridSize; | |
// new position? | |
if( this.selectedEntity.pos.x != x || this.selectedEntity.pos.y != y ) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment