Mathias Panzenböck avatar Mathias Panzenböck committed ea0230a

behavior selection and follow position fixes

Comments (0)

Files changed (1)

 				if (this.following.img.parentNode) {
 					dest   = this.dest_position;
 					dest.x = this.following.current_position.x;
-					dest.y = this.following.current_position.y;
-					dest.x += this.following.facing_right ?
-						this.current_behavior.x : -this.current_behavior.x;
-					dest.y += this.current_behavior.y;
+
+					if (this.following.facing_right) {
+						dest.x += this.current_behavior.x - this.following.paint_behavior.rightcenter.x;
+//						dest.x += this.current_behavior.x - this.following.paint_behavior.rightcenter.x + 40;
+//						dest.x += -this.following.paint_behavior.rightcenter.x + 50;
+					}
+					else {
+						dest.x += -this.current_behavior.x + this.following.paint_behavior.leftcenter.x;
+//						dest.x += -this.current_behavior.x + this.following.paint_behavior.leftcenter.x - 20;
+//						dest.x += this.following.paint_behavior.leftcenter.x - 30;
+					}
+					dest.y = this.following.current_position.y + this.current_behavior.y;
 					dist = distance(curr, dest);
 					if (!this.current_behavior.x && !this.current_behavior.y &&
 						dist <= curr.width * 0.5) {
 		},
 		randomBehavior: function (forceMovement) {
 			var behaviors;
-			var current_group = this.current_behavior ? this.current_behavior.group : null;
+			var current_group = this.current_behavior ? this.current_behavior.group : 0;
 			
 			if (this === dragged && this.canDrag()) {
 				behaviors = this.pony.dragged_behaviors;
 				// don't filter looping behaviors because getNearestInstance filteres
 				// looping instances and then it just degrades to a standard behavior
 				if (forceMovement && !behavior.isMoving()) continue;
-				if (current_group !== null && behavior.group !== 0 && behavior.group !== current_group) continue;
+				if (current_group !== 0 && behavior.group !== 0 && behavior.group !== current_group) continue;
 				sumprob += behavior.probability;
 				filtered.push(behavior);
 			}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.