Page 1 of 1

snap to grid question ?

PostPosted: Sun Nov 03, 2013 2:08 pm
by tinkergnome
how could someone code a function to force an object travelling to obey the edit time grid of squares ??

is it possible ?

Re: snap to grid question ?

PostPosted: Sun Nov 03, 2013 3:54 pm
by DarkParadox
You can use a function like this one I made, add it by clicking "Scripts" in the main menu, clicking global code, pasting it in, giving it a title, and adding it.
Code: Select all
int lockToGrid(int val, int delimiter)
{
    return round(val/delimiter)*delimiter;
} // This function will return the nearest multiple of the delimiter to your value.


Use it by going to whatever actor you need to lock down as you say, adding an event with a script editor action and putting in something like this:
Code: Select all
x = lockToGrid(x, 10); // The current actors X value will now round to the nearest 10th pixel.

Re: snap to grid question ?

PostPosted: Mon Nov 04, 2013 10:17 am
by tinkergnome
x = lockToGrid(x, 10); // The current actors X value will now round to the nearest 10th pixel.

^^^ i'm not sure exactly how to express that in a keypress function ... or a mouse button press... hmmm