Families

0 favourites
  • 6 posts
  • Hi, I'm a Construct newby and a first timer on the forum.

    I?m 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 it?s 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

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi, thanks for your quick response. Problem is that families do not make the instance variables of the sprites contained therein visible... it seems...

  • 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.

  • 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
  • Hi thanks man. I'll try out your suggestion and report back. :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)