ptotheaul Posted February 12, 2018 Share Posted February 12, 2018 I have a polygon and a sprite inside of an extended group that I'm trying to check .contains on. Even though the polygon and the sprite are visually overlapping the contains is returning false. Would the .contains be relative to the stage even though //hitx , hity are points in the main game world passed into this which is an extended group that is placed at a position on the stage Building.prototype.checkbuildingoverlap = function(hitx, hity) { //this is just set up so i can see the spot i'm checking in the .contains this.tempspot.x = hitx - this.x; this.tempspot.y = hity - this.y; //this.buildinggraphics is a polygon shape if (this.buildinggraphics.contains(hitx - this.x, hity - this.y)) { console.log("CONTAINS IS HAPPENING"); } } Link to comment Share on other sites More sharing options...
samme Posted February 12, 2018 Share Posted February 12, 2018 A Polygon knows only its own coordinates so contains(x, y) must be relative to the Polygon. Use debug.spriteCoords(sprite) to verify the sprite coordinates. Link to comment Share on other sites More sharing options...
Recommended Posts