Hundreds of features to explore
Games made in Construct
Your questions answered
Popular & trusted by schools and Universities world-wide
Construct 3 runs in the browser & works offline
Students do not need accounts with us
Our educational partners
Free education resources to use in the classroom
World class complete documentation
Official and community submitted guides
Learn and share with other game developers
Upload and play games from the Construct community
Game development stories & opinions
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.
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?
why not on drag end, pick nearest object (the grid square) and move to the object?
How would that handle multiple pieces? Can you show me with a capx?
Develop games in your browser. Powerful, performant & highly capable.
There are a few ways to simplify:
* Use families.
* Use less object types.
* Use the drag drop behavior.
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.