I've searched and can't seem to find an answer to what I'm trying to achieve - mostly because I can't think of how to summarise it other than "increment once per statement, not once per frame".
I wrote a tiny sketch to assist in explaining what I'm after (code below). Basically, I want to count how many times my mouse enters the right half of the screen. In the below code the count increases once per frame whilst my mouse is in the right half. I understand exactly why this happens, I just can't seem to get my head around what I need to implement to stop this.
What I'm after is for the count to increase by one when the mouse enters the right half and then increase by one again only when the mouse enters the right half for a second time (ie, leaves the right half and then re-enters for a second time).