Search code examples
spritedetectmit-scratch

How to detect where on a sprite a mouse-click occurred on scratch


So I’ve been trying to make a target type game where you click on a target and it tells you how accurate you were and where you clicked each time. After a while I have run across an issue where I couldn’t find out where on the sprite I clicked the target on. I tried googling it but all that comes up is detecting when the sprite is clicked. If anyone can help me it would be very appreciated. Thank you.


Solution

  • I think this is what you want: Create a variable (I'll call it accuracy). Then create an event for "When this sprite clicked". Have it set your variable to "distance to mouse pointer". This will give you the distance from the mouse click to the center of the sprite.

    enter image description here