mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Moving touchingObject into rendered target
This commit is contained in:
parent
431d4bd66b
commit
1a72512a62
3 changed files with 19 additions and 19 deletions
|
@ -63,15 +63,7 @@ class Scratch3EventBlocks {
|
||||||
}
|
}
|
||||||
|
|
||||||
touchingObject (args, util) {
|
touchingObject (args, util) {
|
||||||
const requestedObject = args.TOUCHINGOBJECTMENU;
|
return util.target.touchingObject(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) {
|
hatGreaterThanPredicate (args, util) {
|
||||||
|
|
|
@ -150,16 +150,7 @@ class Scratch3SensingBlocks {
|
||||||
}
|
}
|
||||||
|
|
||||||
touchingObject (args, util) {
|
touchingObject (args, util) {
|
||||||
const requestedObject = args.TOUCHINGOBJECTMENU;
|
return util.target.touchingObject(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);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
touchingColor (args, util) {
|
touchingColor (args, util) {
|
||||||
|
|
|
@ -724,6 +724,23 @@ class RenderedTarget extends Target {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether touching the mouse, an edge, or a sprite.
|
||||||
|
* @param {string} requestedObject an id for mouse or edge, or a sprite name.
|
||||||
|
* @return {boolean} True if the sprite is touching the object.
|
||||||
|
*/
|
||||||
|
touchingObject (requestedObject) {
|
||||||
|
if (requestedObject === '_mouse_') {
|
||||||
|
if (!this.runtime.ioDevices.mouse) return false;
|
||||||
|
const mouseX = this.runtime.ioDevices.mouse.getClientX();
|
||||||
|
const mouseY = this.runtime.ioDevices.mouse.getClientY();
|
||||||
|
return this.isTouchingPoint(mouseX, mouseY);
|
||||||
|
} else if (requestedObject === '_edge_') {
|
||||||
|
return this.isTouchingEdge();
|
||||||
|
}
|
||||||
|
return this.isTouchingSprite(requestedObject);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether touching a point.
|
* Return whether touching a point.
|
||||||
* @param {number} x X coordinate of test point.
|
* @param {number} x X coordinate of test point.
|
||||||
|
|
Loading…
Reference in a new issue