Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ImpactJS Weltmiester: Don't consider entity offset when snapping to grid.
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