So If I Wanted To Attempt To Make Plants Vs Zombies On Flowlab, How Would I Make It So Whenever I Spawn A Plant It Snaps To A Grid? Is That Even Possible??
You could use Grid based placement as in this example from the help section:
Otherwise there are more options using expressions, but those details depend on your specific situation. Grid size, allowed movements etc.
You started something and have a link?
I Do Have A Game But All It Is, Is Background Stuff : /
Heres A Link Anyways https://flowlab.io/game/play/1525057
Definitly possible.
As said, for the initial placement you can use the grid option.
For the movement (left/right) you extract the own X position and add or substract 32 for the next placement.
I’m on the phone, can’t at the moment but might be worth to dig through existing games.
Otherwise, give it a go and ask away
If you use an expression, you can try
(Math.round(A/32))*32
A is where the cursor is.
The output is the position of the block.
Do this with the mouse x and mouse y.
Edit:
32 is the grid size in the editor
Here is a simple example using @JR01’s suggestion above: https://flowlab.io/game/play/1513028
this expression worked best for me Math.round(A / 8) / 4 my favorite thing about it is that it snaps to the flowlab grid not a different one
Well true @GGSTUDIOS, that’s if you use the “grid” option in the position behavior.
Only problem is that the position behavior (set to grid) is the only behavior that can use those numbers.
(and I’m lazy and use the pixel measurements for all behaviors lol)
So here’s a new expression that gives the correct pixel placements that matches Flowlab’s grid placement:
(Math.round((A-16)/B))*B+16
A = Mouse X or Mouse Y
B = The Grid Size you want (8, 16, 32, 64, etc.)
Thanks For All The Support!
I’ll Try And See What I Can Do c: