I want to let the player wipe some dust off of a book, then start a short animation.

Here's what it looks like:

What it looks like, with some dust wiped off

I'm using a clipping region on the "dusty" book bitmap image to progressively hide the dust as the player mouses over it.

However, I'm stuck with how to detect when the dust is all gone. What's a good way of tracking how much is left?

  • 3
    \$\begingroup\$ Keep track of how much you're removing. When it's reached a certain amount, play the animation. Alternatively, just start the animation a set amount of time after the user starts to clean the book. Further, questions that are just "Here's this code, how do I add X?" are poor questions. You should tell us what you've tried and what about it didn't work. I'd go as far as to say the code is not even required in this question at all. \$\endgroup\$
    – House
    Feb 13, 2014 at 19:04

1 Answer 1


At the moment, you seem to be changing only the view (what objects look like), rather than the model (what their state is). (I'm using the MVC terms.)

How about this for a model:

A "hotspot grid" model

It's a grid of hotspots.

Now, when the mouse is pressed, you could set the closest point on the grid to a true value. The percentage cleaned would then be the ratio of true spots to total spots.

You can of course adjust the grid density to whatever works for you.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .