diff --git a/src/sprites/rendered-target.js b/src/sprites/rendered-target.js index 98172f67..a032b1ec 100644 --- a/src/sprites/rendered-target.js +++ b/src/sprites/rendered-target.js @@ -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 diff --git a/test/unit/sprites_rendered-target.js b/test/unit/sprites_rendered-target.js index 3ff40e2c..4a8b9fb9 100644 --- a/test/unit/sprites_rendered-target.js +++ b/test/unit/sprites_rendered-target.js @@ -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(); +});