Grid snap into place


  • Posts: 161
Hi I want to try and make a grid and lets you drag a item to the grid it will snap into place into one of the grids squares im not too sure how to make the grid and snap the items into a slot.

Miasmos Games

  • Posts: 878
You should just be able to use the "drag and drop" behaviour that comes with Stencyl, combined with some logic that gets the actor's x/y positions and rounds them to the nearest grid line. That would look something like this:
set x : round([x of self]/[size of grid width])x[size of grid width]
Repeat for y.
The problem you'll face though is that it will snap to this grid all the time. So you're going to have to look at making it only snap if the actor is within a certain limit of the grid. I might do it for a future pre-shipped behaviour but for now you will probably have to do this for yourself, although I can probably help.

Cupcake Bounce


  • Posts: 161
Wow thanks for the reply. Will proberly have to give it a try in the morning as its 22:43 here. Tell you how it goes soon.