Families

Get help using Construct 2

Post » Fri Nov 01, 2013 10:08 am

Hi, I'm a Construct newby and a first timer on the forum.

Im experimenting with a Puzzle game. It has 16 pieces which have to be dropped on a grid to complete the puzzle. Each of the pieces consists of a separate sprite which I have put into a family called famPieces. The grid on which the pieces have to be dropped also consists of 16 squares each a sprite. I have put these into a family called famGrid.

My questions is as follow: How do I test for a correct placement of famPieces on famGrid as there seems no way to pinpoint the sprite in famPieces (being dragged) with the current underlying gridsquare in famGrid. Something like fampieces.sprite-being-dropped with famGrid.block-on-which-being-dropped. Sorry if that sounds totally stupid, but its the best way I can try to explain. Is families the correct approach in this case? Is there a better way of doing this except for writing 16 conditions for every puzzle (20 puzzles = 320 conditions!)

Thanks for any help or
B
9
S
2
G
1
Posts: 8
Reputation: 1,201

Post » Fri Nov 01, 2013 10:33 am

Give them both an instance variable and set that variable for the corresponding pieces to the same values (0 for first piece, 1 for second and so on).
Then
for each family1:
- family1 is overlapping family2 AND family1.variable equal to family2.variable: do stuff

use system: compare two values for the second condition. Beware that overlapping would mean this triggers every tick.
Reduce the collision polygon of the grid and puzzle pieces if you don't want it to activate when just the edges of the pieces touch.mindfaQ2013-11-01 10:45:01
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Fri Nov 01, 2013 10:39 am

Hi, thanks for your quick response. Problem is that families do not make the instance variables of the sprites contained therein visible... it seems...
B
9
S
2
G
1
Posts: 8
Reputation: 1,201

Post » Fri Nov 01, 2013 10:46 am

No no, it works like I described. I updated my post and added a for each family1 to make it check for every puzzle piece, if you missed that.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Fri Nov 01, 2013 11:05 am

Hey mate, had an idea for an event that works that should give better performance and doesn't require you to meddle with collision boxes in order to prevent it from going off too early:

for each family1
- family2: pick nearest to puzzle.x, puzzle.y AND family1.variable = family2.variable AND distance(family1.x,family1.y,family2.x,family2.y) less than 5: do stuff
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Fri Nov 01, 2013 12:52 pm

Hi thanks man. I'll try out your suggestion and report back. :)
B
9
S
2
G
1
Posts: 8
Reputation: 1,201


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], leandrogenske, R0J0hound, TylerJS and 8 guests