Merge pull request #526 from paulkaplan/report-sound-costume-data

Report sound costume data
This commit is contained in:
Paul Kaplan authored and GitHub committed 2017-04-06 11:45:50 -04:00
commit aa2e255add
2 files changed
+40

No files matched your search

+10
View File
@@ -440,6 +440,14 @@ RenderedTarget.prototype.getCostumes = function () {
return this.sprite.costumes;
};
/**
* Get full sound list
* @return {object[]} list of sounds
*/
RenderedTarget.prototype.getSounds = function () {
return this.sprite.sounds;
};
/**
* Update all drawable properties for this rendered target.
* Use when a batch has changed, e.g., when the drawable is first created.
@@ -767,6 +775,8 @@ RenderedTarget.prototype.toJSON = function () {
direction: this.direction,
draggable: this.draggable,
costume: this.getCurrentCostume(),
costumes: this.getCostumes(),
sounds: this.getSounds(),
costumeCount: this.getCostumes().length,
visible: this.visible,
rotationStyle: this.rotationStyle
+30
View File
@@ -21,3 +21,33 @@ test('#stopAll clears graphics effects', function (t) {
t.equals(a.effects[effectName], 0);
t.end();
});
test('#getCostumes returns the costumes', function (t) {
var spr = new Sprite();
var a = new RenderedTarget(spr, null);
var costumes = [1, 2, 3];
a.sprite.costumes = costumes;
t.equals(a.getCostumes(), costumes);
t.end();
});
test('#getSounds returns the sounds', function (t) {
var spr = new Sprite();
var a = new RenderedTarget(spr, null);
var sounds = [1, 2, 3];
a.sprite.sounds = sounds;
t.equals(a.getSounds(), sounds);
t.end();
});
test('#toJSON returns the sounds and costumes', function (t) {
var spr = new Sprite();
var a = new RenderedTarget(spr, null);
var sounds = [1, 2, 3];
var costumes = ['a', 'b', 'c'];
a.sprite.sounds = sounds;
a.sprite.costumes = costumes;
t.same(a.toJSON().sounds, sounds);
t.same(a.toJSON().costumes, costumes);
t.end();
});