From 6c0d257a63e478640ef335889b89f1624faf8c7b Mon Sep 17 00:00:00 2001 From: Karishma Chadha Date: Wed, 4 Apr 2018 18:54:05 -0400 Subject: [PATCH] Deserialize tempo, volume, and video related state. --- src/serialization/sb3.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/serialization/sb3.js b/src/serialization/sb3.js index 7566d6cfb..24f91c50b 100644 --- a/src/serialization/sb3.js +++ b/src/serialization/sb3.js @@ -345,8 +345,12 @@ const serializeTarget = function (target) { obj.currentCostume = target.currentCostume; obj.costumes = target.costumes.map(serializeCostume); obj.sounds = target.sounds.map(serializeSound); - if (!obj.isStage) { - // Stage does not need the following properties + if (target.hasOwnProperty('volume')) obj.volume = target.volume; + if (obj.isStage) { // Only the stage should have these properties + if (target.hasOwnProperty('tempo')) obj.tempo = target.tempo; + if (target.hasOwnProperty('videoTransparency')) obj.videoTransparency = target.videoTransparency; + if (target.hasOwnProperty('videoState')) obj.videoState = target.videoState; + } else { // The stage does not need the following properties, but sprites should obj.visible = target.visible; obj.x = target.x; obj.y = target.y; @@ -700,6 +704,18 @@ const parseScratchObject = function (object, runtime, extensions, zip) { // Create the first clone, and load its run-state from JSON. const target = sprite.createClone(); // Load target properties from JSON. + if (object.hasOwnProperty('tempo')) { + target.tempo = object.tempo; + } + if (object.hasOwnProperty('volume')) { + target.volume = object.volume; + } + if (object.hasOwnProperty('videoTransparency')) { + target.videoTransparency = object.videoTransparency; + } + if (object.hasOwnProperty('videoState')) { + target.videoState = object.videoState; + } if (object.hasOwnProperty('variables')) { for (const varId in object.variables) { const variable = object.variables[varId];