Drop & Drag in Boxes

Get help using Construct 2

Post » Tue Aug 14, 2012 6:44 pm

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
B
15
S
6
Posts: 17
Reputation: 1,927

Post » Tue Aug 14, 2012 6:48 pm

why not on drag end, pick nearest object (the grid square) and move to the object?
B
36
S
10
G
6
Posts: 948
Reputation: 11,101

Post » Tue Aug 14, 2012 7:05 pm

How would that handle multiple pieces? Can you show me with a capx?

Thanks,
B
15
S
6
Posts: 17
Reputation: 1,927

Post » Tue Aug 14, 2012 10:07 pm

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
B
82
S
26
G
62
Posts: 4,827
Reputation: 45,194

Post » Tue Aug 14, 2012 10:28 pm

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.
ImageImageImageImageImageImage
Image
B
95
S
21
G
16
Posts: 1,337
Reputation: 20,955

Post » Tue Aug 14, 2012 11:21 pm

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.
B
15
S
6
Posts: 17
Reputation: 1,927


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot] and 22 guests