SFML community forums

Help => Graphics => Topic started by: GabrielS on May 31, 2013, 03:03:30 pm

Title: event on a clic on a Shape
Post by: GabrielS on May 31, 2013, 03:03:30 pm
Hello guys !

I am new to SFML ( how come I didn't know about it before :P ), and looking at the documentation + some topics on the forum, I didn't find function that permits to get an event if the user clicks on a ConvexShape.
If you have any idea/solution, I would like to have advices.
( I've seen the function getGlobalBounds, But I'd rather have the shape itself and not a rectangle containing the shape ).

Thanks in advance,

Gabriel.
Title: Re: event on a clic on a Shape
Post by: Laurent on May 31, 2013, 03:09:23 pm
There's no built-in function for that, you have to write it yourself. There are two algorithms that can be used for the point-in-convex test, I'm sure Wikipedia or Google know them ;)
Title: Re: event on a clic on a Shape
Post by: JayArby on May 31, 2013, 11:10:53 pm
FYI, after a convex shape (or anything else) is drawn on the screen, SFML (or the window or anything else) is not aware that there is a shape there. This is something you would have to write the framework for. SFML just deals with the multimedia aspects of your application; it does not provide the whole structure that would be required for what you are suggesting.
Title: Re: event on a clic on a Shape
Post by: Laurent on June 01, 2013, 09:07:15 am
Quote
FYI, after a convex shape (or anything else) is drawn on the screen, SFML (or the window or anything else) is not aware that there is a shape there. This is something you would have to write the framework for. SFML just deals with the multimedia aspects of your application; it does not provide the whole structure that would be required for what you are suggesting.
Well, the ConvexShape class knows about its points, so the structure is already there. All he needs is the algorithm.