mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Import and store video state
This commit is contained in:
parent
2d9bd92140
commit
5dc8e51c6d
2 changed files with 42 additions and 3 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue