Add when touching hat
This commit is contained in:
1 parent
c2645f3da5
commit
431d4bd66b
1 file changed
+17
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user