**||** Snap To Grid Code Help **||**
Ok so I have a piece of code that almost does what I want. I want the screen divided into 40x40 quadrants. I have a game attribute of Cell Width and Height at 40 each. Here is my code for the snap to grid:
(ceil((floor(((game.Touches.Touch 1.Y + game.Camera Y Offset)/game.Cell Height)*2))/2))*game.Cell Height
The issue I am having with this is it is placing them with a snap to grid except I want it to snap to the center of the 40x40 ... instead it is snapping to the corner of the 4 quadrants in the region clicked. If you have any ideas on how to modify this to accomplish what I'm doing I would really appreciate it. Thanks.
**Oh and btw that same code is the exact same for the X with the exception of it being the X's.
(ceil((floor(((game.Touches.Touch 1.Y + game.Camera Y Offset)/game.Cell Height)*2))/2))*game.Cell Height
The issue I am having with this is it is placing them with a snap to grid except I want it to snap to the center of the 40x40 ... instead it is snapping to the corner of the 4 quadrants in the region clicked. If you have any ideas on how to modify this to accomplish what I'm doing I would really appreciate it. Thanks.
**Oh and btw that same code is the exact same for the X with the exception of it being the X's.
Comments
How about remaking your background image with the gridlines starting 20 over and down?
----------------------------------------------
http://davidgriffinapps.co.uk/
iPad: End of the Earth game coming soon to the iTunes App Store....
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
I did a demo a while ago look if it can help you: http://forums.gamesalad.com/discussion/32131/
________________________________
Mark On The Iron - 【ツ】iPhone Icon Pack【ツ】 - 【ツ】Graphic Pack【ツ】
Free GS demos: High score simple and advanced; Game Center; App Rating System; Custom Font Score and Countdown; Advanced Snap to Grid
Thanks for replying each of you. Ya after tampering around I did find that +20 to the Y did get it about right looking. The problem with it on the X is it moves it to incorrect location. So lets say I have a block of 40x40. If I plug the box in the very bottom left corner of the screen it goes (so it is at location 20x20). If I click directly next to it would push it one block over or up or somewhere else. It just isn't landing in the right spot. So I may have to just deal with it and just make the grid match the location of where it is actually making them spawn. Unless you have any ideas?