Add when touching hat

This commit is contained in:
Eric Rosenbaum committed 2018-06-06 13:39:23 -04:00
1 parent c2645f3da5
commit 431d4bd66b
1 file changed
+17
+17
View File
@@ -24,6 +24,7 @@ class Scratch3EventBlocks {
*/
getPrimitives () {
return {
event_whentouchingobject: this.touchingObject,
event_broadcast: this.broadcast,
event_broadcastandwait: this.broadcastAndWait,
event_whengreaterthan: this.hatGreaterThanPredicate
@@ -41,6 +42,10 @@ class Scratch3EventBlocks {
event_whenthisspriteclicked: {
restartExistingThreads: true
},
event_whentouchingobject: {
restartExistingThreads: false,
edgeActivated: true
},
event_whenstageclicked: {
restartExistingThreads: true
},
@@ -57,6 +62,18 @@ class Scratch3EventBlocks {
};
}
touchingObject (args, util) {
const requestedObject = args.TOUCHINGOBJECTMENU;
if (requestedObject === '_mouse_') {
const mouseX = util.ioQuery('mouse', 'getClientX');
const mouseY = util.ioQuery('mouse', 'getClientY');
return util.target.isTouchingPoint(mouseX, mouseY);
} else if (requestedObject === '_edge_') {
return util.target.isTouchingEdge();
}
return util.target.isTouchingSprite(requestedObject);
}
hatGreaterThanPredicate (args, util) {
const option = Cast.toString(args.WHENGREATERTHANMENU).toLowerCase();
const value = Cast.toNumber(args.VALUE);