Checking for Overlap

RattleheadRattlehead Member Posts: 485
edited November -1 in Working with GS (Mac)
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.

Comments

  • firemaplegamesfiremaplegames Member Posts: 3,211
    there's two ways:

    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.
  • JackBQuickJackBQuick Member Posts: 524
    I haven't done this before but here's what I think:

    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?
  • RattleheadRattlehead Member Posts: 485
    Thanks a lot you guys for the insight. I'm stuck at work right now but I am going to try those ideas tonight! Both definitely have merit and are better than what I am doing right now.
  • JackBQuickJackBQuick Member Posts: 524
    I just read what firemaplegames wrote and, as usual, he's right. (In the time that I took to type a response, he had already contributed to the forum.)

    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.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    aw shucks...
Sign In or Register to comment.