Implement sprite info emitting and posting ()

This commit is contained in:
Tim Mickel 2016-10-26 13:27:12 -04:00 committed by GitHub
parent 1dc4aaa2d7
commit 56ef01745f
6 changed files with 94 additions and 1 deletions
src/engine

View file

@ -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.