Snap to Grid: With a Little less Snap
Hi, I've been working with this demo I got off the forum from @MarkOnTheIron , here's the link...http://forums.gamesalad.com/discussion/32131/
He credits @FireMapleGames for the math and also @TShirtBooth for helping him.
What I have been trying to do is have the block (my Icon in this case) be able to snap to a grid, but with a little less snap. Right now the block seems to hit the outside of the grid and then suddenly snap into the grid. I was hoping for more of a smooth transition maybe rather than a constrain self.x and Y attribute, the block could be interpolated into place?
When not snapped I would like the block to have gravity and have the user be able to drag and drop it into anyplace on the grid.
Heres a vid of how it looks now....http://tinypic.com/m/ixsj89/2
I know it's a lot thanks for any help.
Comments
I've also been playing with setting up a rule in the blank space that the block would snap to, like....
Rule: when the actor rec's. Mouse button is down.
Constrain ATt: self.distanceFromBlock to Mag(self.PosX- game.selectedX, self.Pos.Y-game.selectedY)
Then set up another rule inside that that says When Att: self.distanceFromBlock is <=than 100
Cha_Att: game.canSnap to true.
Back in the block...
When actor rec's mouse button is up and Att: game.canSnap is true
Interpolate self.PosX to the blank PosX As well as the Y position.
But I couldn't figure out how to do this with a grid....