Hi. What I want is pretty simple. So I have this function running on pointerdown. The thing is that the e.clientX/Y gives me the coordinates for the pointer in the current browser position, and then I get all the polypoints from the obj and then make an array with all the points and send to the tools.inside() function to check if that click is inside that polygon. This works fine if the obj doesn't move. But I have the objects with Anchor behaviour and they move. So what happens is that the polyPoints array is using the coordinates of the obj in the original game resolution (540 x 270). But the pointer uses the window position coordinates with the current resolution from the browser (915 x 412). So when I check if the point is inside the polygon it doesn't match.
I have tried changing the point position from one resolution but it doesn't work. Is there any function or way to make this work ?
Thanks
runtime.addEventListener('pointerdown', (e) => {
let view = e.runtime.getViewportSize();
let x = e.clientX - ((window.innerWidth - c3canvas.clientWidth) / 2);
let y = e.clientY - ((window.innerHeight - c3canvas.clientHeight) / 2);
let arr = [];
for (let j = 0; j < obj.getPolyPointCount(); j++){
arr.push([
((obj.getPolyPointX(j) * c3canvas.clientWidth) / view[0]),
((obj.getPolyPointY(j) * c3canvas.clientHeight) / view[1])
]);
}
if(tools.inside(x,y, arr) && obj.isVisible) {
this.CallFunction(func);
}
});