What do the parameters of Shape:testPoint do?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
kristinamay
Prole
Posts: 3
Joined: Sat Nov 12, 2022 6:15 pm
Contact:

What do the parameters of Shape:testPoint do?

Post by kristinamay »

Hello,

I'm implementing basic mouse click overlap for (convex) polygons. I have the polygon, now I just need to understand how to use testPoint(). The docs don't do an adequate job of explaining how exactly to use testPoint - what do the t- parameters do? Could someone provide the most basic example of what each of the parameters is for and how to use them? There's no example in the docs, searching the forums and Stack Overflow yielded nada.

If you need an example, let's say that my polygon is:

p = love.physics.newPolygonShape(30, 30, 30, 60, 75, 75, 75, 30)

And it's smack in the middle of a 200 by 300 window.

My mouse point is at 40, 40 (which is an overlap).

Thanks so much!
Ross
Citizen
Posts: 99
Joined: Tue Mar 13, 2018 12:12 pm
Contact:

Re: What do the parameters of Shape:testPoint do?

Post by Ross »

Is your shape actually attached to a Body? If that's the case, just use Fixture:testPoint(x, y).

If you're actually using a Shape that's not in the world at all, then I would assume that tx, ty, and tr are just offsets for the shape from the origin. Or in other words: the position and rotation of the Body that you imagine it being attached to.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests