Sprite::isTouchingMousePointer()
Returns true if the sprite is touched by the mouse pointer.
Examples
import org.openpatch.scratch.*;
public class SpriteIsTouchingMousePointer {
public SpriteIsTouchingMousePointer() {
Stage myStage = new Stage(600, 240);
Sprite mySprite = new Sprite("zeta", "assets/zeta_green_badge.png");
mySprite.changeX(-100);
mySprite.changeY(30);
myStage.add(mySprite);
while (myStage.getTimer().forMillis(3000)) {
mySprite.say("Is touching mouse? " + mySprite.isTouchingMousePointer());
}
myStage.exit();
}
public static void main(String[] args) {
new SpriteIsTouchingMousePointer();
}
}
Syntax
Java
.isTouchingMousePointer()
Scratch
Return
boolean