mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Use a global mirror state
This commit is contained in:
parent
90166dc732
commit
46b4ef4d80
2 changed files with 12 additions and 5 deletions
|
@ -117,7 +117,6 @@ class Scratch3VideoSensingBlocks {
|
|||
const offset = time - this._lastUpdate;
|
||||
if (offset > Scratch3VideoSensingBlocks.INTERVAL) {
|
||||
const frame = this.runtime.ioDevices.video.getFrame({
|
||||
mirror: true,
|
||||
format: Video.FORMAT_IMAGE_DATA,
|
||||
dimensions: Scratch3VideoSensingBlocks.DIMENSIONS
|
||||
});
|
||||
|
@ -340,12 +339,14 @@ class Scratch3VideoSensingBlocks {
|
|||
}
|
||||
|
||||
videoToggle (args) {
|
||||
// imported blocks have VIDEO_STATE "off", "on", "on-flipped" as opposed to the numerics?
|
||||
const state = Number(args.VIDEO_STATE);
|
||||
// 1 == off, 2 & 3 are on (3 is flipped)
|
||||
if (state > 1) {
|
||||
this.runtime.ioDevices.video.requestVideo();
|
||||
} else {
|
||||
if (args.VIDEO_STATE === 'off' || state === 1) {
|
||||
this.runtime.ioDevices.video.disableVideo();
|
||||
} else {
|
||||
this.runtime.ioDevices.video.requestVideo();
|
||||
this.runtime.ioDevices.video.mirror = args.VIDEO_STATE === 'on' || state === 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,12 @@ class Video {
|
|||
*/
|
||||
this.runtime = runtime;
|
||||
|
||||
/**
|
||||
* Default value for mirrored frames.
|
||||
* @type boolean
|
||||
*/
|
||||
this.mirror = true;
|
||||
|
||||
/**
|
||||
* Cache frames for this many ms.
|
||||
* @type number
|
||||
|
@ -136,7 +142,7 @@ class Video {
|
|||
*/
|
||||
getFrame ({
|
||||
dimensions = Video.DIMENSIONS,
|
||||
mirror = true,
|
||||
mirror = this.mirror,
|
||||
format = Video.FORMAT_IMAGE_DATA,
|
||||
cacheTimeout = this._frameCacheTimeout
|
||||
}) {
|
||||
|
|
Loading…
Reference in a new issue