Drag and drop tile puzzle

Get help using Construct 2

Post » Wed Apr 23, 2014 3:15 pm

Hey guys, I've created a drag-and-drop sliding tile puzzle minigame that I'm setting within a larger RPG level. It is mostly functional, however, I have run into a behaviour that seems to occur somewhat randomly that breaks it. I'll explain my workflow:

-----------------------------

I first created an invisible grid on Layer 0 with placeholders 1 through 9 ("Place1" to "Place9"):

Untitled1.jpg


I then inserted my image as a sliced sprite animation set (speed set to 0) and scrambled it on the grid on Layer 1:

Untitled2.jpg


I put together code which does the following:
-Assigns each piece of the image a number (as an instance variable) according to which tile it is currently on (every tick).
-Checks each piece (on DragDrop > Drop) firstly which piece it is (according to the variable), and secondly where it can be placed.
-This is done by checking firstly whether that piece is overlapping a particular "Place#" on the grid, and also if that particular "Place#" is empty (with a variable 1 or 0), and then setting its position to the x and y coordinates of that grid place. In the same event I include actions to set the destination place to "Full", and the source to "Empty".
-An else statement underneath the possible locations sends the tile piece back to its origin (in the case it is dropped in an invalid space).
-I also have code regarding winning conditions, but they don't concern me right now.

-----------------------------

Here's my problem:

When I move two or three tiles, everything seems to be working fine. Then I will try to drop another tile on an empty space, and it springs back to it's origin. This might be fine (assuming it just hadn't overlapped properly or something), but it also seems to set the "Full" variable of the destination to 1 (on), even though it has sprung back to the origin. With the empty space "Full", no tiles are allowed to move there, and the game is broken.



My code is attached, if anyone can help me reorganise it to solve this issue, I would be stoked.
You do not have the required permissions to view the files attached to this post.
B
3
Posts: 4
Reputation: 183

Post » Wed Apr 23, 2014 3:19 pm

Here's a video of the issue:

View My Video

http://tinypic.com/r/1ghx8z/8
B
3
Posts: 4
Reputation: 183

Post » Fri Apr 25, 2014 6:14 am

Seriously guys, if I could get some feedback on this soon I might be able to move on with the rest of my level. Any help would be hugely appreciated.
B
3
Posts: 4
Reputation: 183

Post » Mon Apr 28, 2014 10:32 am

Well in case anyone else has the same problem, I have solved this.

There needs to be an 'else' statement attached to each of the sub-sub-event branches of the "on-drag drop" event.

e.g.
- 14 - Circuits | Is overlapping Place2
Place2 | Full = 0

- 15 - [System] | [ Else]
Circuits | Is overlapping Place5
....
B
3
Posts: 4
Reputation: 183


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 19 guests