mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-21 10:49:50 -04:00
Implement sprite info emitting and posting (#320)
This commit is contained in:
parent
1dc4aaa2d7
commit
56ef01745f
6 changed files with 94 additions and 1 deletions
src/engine
|
@ -185,6 +185,12 @@ Runtime.BLOCK_GLOW_OFF = 'BLOCK_GLOW_OFF';
|
|||
*/
|
||||
Runtime.VISUAL_REPORT = 'VISUAL_REPORT';
|
||||
|
||||
/**
|
||||
* Event name for sprite info report.
|
||||
* @const {string}
|
||||
*/
|
||||
Runtime.SPRITE_INFO_REPORT = 'SPRITE_INFO_REPORT';
|
||||
|
||||
/**
|
||||
* How rapidly we try to step threads by default, in ms.
|
||||
*/
|
||||
|
@ -542,6 +548,7 @@ Runtime.prototype.setEditingTarget = function (editingTarget) {
|
|||
// Script glows must be cleared.
|
||||
this._scriptGlowsPreviousFrame = [];
|
||||
this._updateGlows();
|
||||
this.spriteInfoReport(editingTarget);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -661,6 +668,23 @@ Runtime.prototype.visualReport = function (blockId, value) {
|
|||
this.emit(Runtime.VISUAL_REPORT, blockId, String(value));
|
||||
};
|
||||
|
||||
/**
|
||||
* Emit a sprite info report if the provided target is the editing target.
|
||||
* @param {!Target} target Target to report sprite info for.
|
||||
*/
|
||||
Runtime.prototype.spriteInfoReport = function (target) {
|
||||
if (target !== this._editingTarget) {
|
||||
return;
|
||||
}
|
||||
this.emit(Runtime.SPRITE_INFO_REPORT, {
|
||||
x: target.x,
|
||||
y: target.y,
|
||||
direction: target.direction,
|
||||
visible: target.visible,
|
||||
rotationStyle: target.rotationStyle
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a target by its id.
|
||||
* @param {string} targetId Id of target to find.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue