Checking for Overlap
Rattlehead
Member Posts: 485
Hi everyone,
I've been lurking around the forums for about a month now and have been playing around with GameSalad when I have time and so far I have really enjoyed sitting down and putting things together in a really short amount of time.
But I have ran into a problem that I am hoping someone can push me into the right direction...
I am working on a puzzle/matching type of game where the player needs to grab pieces from the sidebar and drop them onto a matching outline on the main playing area; so for example, if there is an outline of a circle in the playing area, the player needs to grab the matching piece from those made available to them and drag and drop onto the outline where it will then fill in the outline to show that the match was made.
The drag and drop was simple enough but I have been relying on the overlap in the rule component and it makes it waaaaaay to easy since they barely have to get the two actors/pieces to make contact.
So my question: Is there a way to check for a certain percentage of coverage/overlap without having to place an additional, smaller, invisible actor piece inside each outline piece in my playing area? From what I have been following on the forum is that actors are fairly precious resources and to double the count like that would not be optimal.
Any ideas?
Thanks in advance and I'm glad to finally have an opportunity to join in what are very collaborative forums.
I've been lurking around the forums for about a month now and have been playing around with GameSalad when I have time and so far I have really enjoyed sitting down and putting things together in a really short amount of time.
But I have ran into a problem that I am hoping someone can push me into the right direction...
I am working on a puzzle/matching type of game where the player needs to grab pieces from the sidebar and drop them onto a matching outline on the main playing area; so for example, if there is an outline of a circle in the playing area, the player needs to grab the matching piece from those made available to them and drag and drop onto the outline where it will then fill in the outline to show that the match was made.
The drag and drop was simple enough but I have been relying on the overlap in the rule component and it makes it waaaaaay to easy since they barely have to get the two actors/pieces to make contact.
So my question: Is there a way to check for a certain percentage of coverage/overlap without having to place an additional, smaller, invisible actor piece inside each outline piece in my playing area? From what I have been following on the forum is that actors are fairly precious resources and to double the count like that would not be optimal.
Any ideas?
Thanks in advance and I'm glad to finally have an opportunity to join in what are very collaborative forums.
Comments
Like you said, you can have a tiny, invisible actor that acts as the real collision spot (the shape outline is just a dummy background graphic, or you can use the magnitude function. it compares the distance between two points.
Say you have a circular outline that has a diameter of 100 pixels. If this actor were centred on the screen (of size 480 pixels by 360 pixels), its x and y coordinates would be 240 and 180 respectively. It would cover the area from x=190 to x=290, and from y=130 to y=230.
To ensure that your matching piece sufficiently covers the outline area, I might create a rule to ensure that its x-coordinate was, say, greater than 215 and less than 265; and its y-coordinate was greater than 155 and less than 205.
Does this make sense?
My complicated explanation was summed up very nicely with his "you can use the magnitude function. it compares the distance between two points". My hats off to you, firemaplegames.