This site requires JavaScript, please enable it in your browser!
Greenfoot back
fejfo
fejfo wrote ...

2014/12/17

World cell size & centering actors

fejfo fejfo

2014/12/17

#
I don't understand the effect of the worlds cell size. I tried ( whit to world cell size ) to always center an actor in a cell ( for a board game ) so I didn't had to calculate all the coordinates in multiples of 64. I know all this is fairly easy without a cell size. What I wanted to do that's more difficult without is be able to click on a button and generate an object at the mouses position and when the mouse clicks on the object make it so It doesn't follows the mouse and place it in the center of a cell. this is difficult without because u have to find the nearest multiplier of 32 (to the X and Y) and then check if one of those is a multiplier of 64 and if it is ignore it and find a the second closets. Maby there is an easier way to to do this with to cell size.
davmac davmac

2014/12/17

#
I don't understand the effect of the worlds cell size
It's the cell size (width and height) of the world in pixels. All co-ordinates used in world methods refer to cells.
I tried ( whit to world cell size ) to always center an actor in a cell ( for a board game ) so I didn't had to calculate all the coordinates in multiples of 64
Actors will always be centered in a cell.
What I wanted to do that's more difficult without is be able ...
Without what?
to click on a button and generate an object at the mouses position
Do you mean the mouse's cell position?
and when the mouse clicks on the object make it so It doesn't follows the mouse
Do you mean the object that you just created? It won't follow the mouse anyway, unless you have specifically made it do so. Your message is quite confusing, but I will say this: having a cell size greater than 1 might work for you, but you need to be aware that objects can only be positioned in cells. You cannot have an object 'smoothly' follow the mouse at a greater resolution, for instance.
fejfo fejfo

2014/12/17

#
My question was quite unclear but I think u answered my question . Thank you
You need to login to post a reply.