mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Merge pull request #1014 from ericrosenbaum/bugfix/video-state
Import and store video state
This commit is contained in:
commit
21ae14c499
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