diff --git a/src/serialization/sb2.js b/src/serialization/sb2.js index 2bc0ff3cb..5d41f2ccd 100644 --- a/src/serialization/sb2.js +++ b/src/serialization/sb2.js @@ -341,6 +341,18 @@ const parseScratchObject = function (object, runtime, extensions, topLevel) { if (object.hasOwnProperty('tempoBPM')) { target.tempo = object.tempoBPM; } + if (object.hasOwnProperty('videoAlpha')) { + // SB2 stores alpha as opacity, where 1.0 is opaque. + // We convert to a percentage, and invert it so 100% is full transparency. + target.videoTransparency = 100 - (100 * object.videoAlpha); + } + if (object.hasOwnProperty('info')) { + if (object.info.hasOwnProperty('videoOn')) { + if (object.info.videoOn) { + target.videoState = RenderedTarget.VIDEO_STATE.ON; + } + } + } target.isStage = topLevel; diff --git a/src/sprites/rendered-target.js b/src/sprites/rendered-target.js index 2cc5b31af..35204ec93 100644 --- a/src/sprites/rendered-target.js +++ b/src/sprites/rendered-target.js @@ -118,16 +118,31 @@ class RenderedTarget extends Target { this.rotationStyle = RenderedTarget.ROTATION_STYLE_ALL_AROUND; /** - * Current tempo (used by the music extension) + * Loudness for sound playback for this target, as a percentage. + * @type {number} + */ + this.volume = 100; + + /** + * Current tempo (used by the music extension). + * This property is global to the project and stored in the stage. * @type {number} */ this.tempo = 60; /** - * Loudness for sound playback for this target, as a percentage. + * The transparency of the video (used by extensions with camera input). + * This property is global to the project and stored in the stage. * @type {number} */ - this.volume = 100; + this.videoTransparency = 50; + + /** + * The state of the video input (used by extensions with camera input). + * This property is global to the project and stored in the stage. + * @type {string} + */ + this.videoState = RenderedTarget.VIDEO_STATE.OFF; } /** @@ -194,6 +209,18 @@ class RenderedTarget extends Target { return "don't rotate"; } + /** + * Available states for video input. + * @type {object} + */ + static get VIDEO_STATE () { + return { + 'OFF': 'off', + 'ON': 'on', + 'ON-FLIPPED': 'on-flipped' + }; + } + /** * Set the X and Y coordinates. * @param {!number} x New X coordinate, in Scratch coordinates.