0 Favourites

# How to prevent different combinations?

• 18 posts
• I intend to create a game like tangram. I thought to use duplicated sprites as marks (placeholders) but I don't know how to prevent a different combination of sprites that will be correct too. I need some suggestions. Thanks in advance.

• You can use couple of sprites for each piece or just have a "sprite variable" that you'll check.

basically if piece's A sprite variable = placeholder's A sprite variable - they stick. Otherwise - they don't.

• So, I intend to use duplicates of the tangram pieces to mark the right place but I don't know if this is the better solution (I believe not). I thought to use variables too, but the problem for me is to prevent all possibilities. You can build the same figure with several different combinations. For example: one big triangle or two small - one square or two small triangles (inverted too) - a rhombus or two small triangles, etc.

• It all depends on how you'd like it to work..

Because of the many possibilities you should think of a way to accomodate them all..

I guess overlapping is the first thing you'd want to check

If the square (for example) is overlapped by the triangle, and the triangle fits in the square, you could add conditions for it to go (or not go) to the place it fits..

• Okay. But I don't know how to prevent all possibilities (the same figure can build in all orientations) and how can I associate a shape (as I said, I intend to use duplicates to check the sprite) with two others.

• So I guess you allready got this far?

Very dirty method to get the first part working, by the way..

• Offcourse it would be much nicer to check the distance between the two objects and if close enough have them move to the destination.

The same way you could check collisions and overlap with different objects and if (for example) the triangle fits inside the square have it go to the fitting position based on distance and overlap, or not..

• So I guess you allready got this far?

Very dirty method to get the first part working, by the way..

Yes. No problem with this.

I used your example to create another one that represents what I need to understand.

I have to fit all the pieces in the figure using all possible combinations (use the spacebar to rotate the pieces).

• ok.. A few questions..

Why is there a sprite3, sprite4 and sprite5, when they are exactly the same object as sprite?

Why not use instances?

Why is there a drag and drop behaviour on both the sprites and the family all the sprites are in?

• ok.. A few questions..

Why is there a sprite3, sprite4 and sprite5, when they are exactly the same object as sprite?

Why not use instances?

Why is there a drag and drop behaviour on both the sprites and the family all the sprites are in?

Okay. No problem to use instances and sorry about the behavior duplication. I tried to create a new project quickly.

• Please, guys. I still need a little help with this subject.

• I'd be more than willing to help, if helping didn't mean creating it for you..

I gave a very badly made example and all you did was add one event that didn't work as expected..

I was hoping to see your code and give some advice as to how to get closer to your objective..

So what you'd like to do is when sprite is overlapping another sprite, check if the sprite would fit.

All you would have to do is create conditions on drag and drop drop, to check these..

A rotated triangle won't fit inside a non-rotated square, etcetera..

• I myself would go for a different approach and create two families..

One for the pieces and one for the example/background..

family1 is overlapping family2 - check some variables and act accordingly..

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

Construct 3 users don't see these ads
• I'd be more than willing to help, if helping didn't mean creating it for you..

I gave a very badly made example and all you did was add one event that didn't work as expected..

I was hoping to see your code and give some advice as to how to get closer to your objective..

So what you'd like to do is when sprite is overlapping another sprite, check if the sprite would fit.

All you would have to do is create conditions on drag and drop drop, to check these..

A rotated triangle won't fit inside a non-rotated square, etcetera..

I don't ask for a project or example either. You did it because you wanted, and I just prepared the other example because you didn't understood what I'm looking for.

• 18 posts