Hi all. I've been working on making a game like Battleship. I've created a grid and have sprites that can be dragged onto the grid. Please see the link below and you'll see what I'm trying to accomplish.
The Capx
Everything works basically but the code seems too complex and repetitive. Does anyone have any ideas on how to simplify? Or a different way to do it?
Thanks
why not on drag end, pick nearest object (the grid square) and move to the object?
Develop games in your browser. Powerful, performant & highly capable.
How would that handle multiple pieces? Can you show me with a capx?
Thanks,
There are a few ways to simplify:
* Use families.
* Use less object types.
* Use the drag drop behavior.
http://dl.dropbox.com/u/5426011/fixed/rootzm.capx
You can detect the box X and Y by checking if the mouse is over the object, and releasing the mouse button and setting to the object be the same of X and Y of that box. Later, you can also check if the box is empty or filled, etc.
Thank you for the replies and to R0J0hound is particular for the capx. I'll be studying your example. The Scirra community continues to impress.