Hi,
Im using Character.GetAtScreenXY for detecting if there is an enemy at the location of players sword. It works fine, but the problem is when there is multiple characters at the same location. So is there way of identifying all overlapping characters in some x,y position?
I think you want the AreThingsOverlapping (http://www.adventuregamestudio.co.uk/wiki/Room_functions#AreThingsOverlapping) function?
It should be noted that this will compare the rectangular bounding boxes of the two objects.
To detect multiple characters at a single coordinate location, you could try turning all the characters unclickable, then turn them clickable for the test. I don't know if this will work during a single game loop though.
bool IsAt(this Character*, int x, int y) {
this.Clickable = true;
bool r = Character.GetAtScreen(x, y) == this;
this.Clickable = false;
return r;
}
// enemies have IDs 3-9
int i = 3;
while (i < 10) {
if (character[i].IsAt(sword_x, sword_y)) character[i].hit();
i++;
}
Thank you both. I got it working with that clickable thing.