I am developing a very simple game in libGDX for android devices. Simply, the game is a character who runs and jumps over obstacles, every time the character jumps over one of said obstacles, a counter increments and the score is displayed.
I am currently detecting the character jumping over the obstacles by creating two Rectangle objects (invisible) - one small one for the center of the character and the second is a long thin line from the center of the obstacle. I use the 'overlaps()' command to check whether or not the character has passed said line.
This issue I am having is that because I am calling to check on the overlap in my update method, it is called many times in a second and hence sometimes adds two points to the score as the small rectangles are still overlapping on the second round of checking.
I have got the sizes down to a near perfect size with the occurrence of incorrect scores at a minimum, however they do still happen.
So my question is what would a better way be to detect a line crossing / collision?