mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
parent
c449f14280
commit
fbb6d63e03
1 changed files with 21 additions and 2 deletions
|
@ -4,6 +4,7 @@ const RenderedTarget = require('../sprites/rendered-target');
|
|||
const uid = require('../util/uid');
|
||||
const StageLayering = require('../engine/stage-layering');
|
||||
const getMonitorIdForBlockWithArgs = require('../util/get-monitor-id');
|
||||
const MathUtil = require('../util/math-util');
|
||||
|
||||
/**
|
||||
* @typedef {object} BubbleState - the bubble state associated with a particular target.
|
||||
|
@ -67,6 +68,14 @@ class Scratch3LooksBlocks {
|
|||
return 330;
|
||||
}
|
||||
|
||||
/**
|
||||
* Limit for ghost effect
|
||||
* @const {object}
|
||||
*/
|
||||
static get EFFECT_GHOST_LIMIT (){
|
||||
return {min: 0, max: 100};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Target} target - collect bubble state for this target. Probably, but not necessarily, a RenderedTarget.
|
||||
* @returns {BubbleState} the mutable bubble state associated with that target. This will be created if necessary.
|
||||
|
@ -479,13 +488,23 @@ class Scratch3LooksBlocks {
|
|||
const effect = Cast.toString(args.EFFECT).toLowerCase();
|
||||
const change = Cast.toNumber(args.CHANGE);
|
||||
if (!util.target.effects.hasOwnProperty(effect)) return;
|
||||
const newValue = change + util.target.effects[effect];
|
||||
let newValue = change + util.target.effects[effect];
|
||||
if (effect === 'ghost') {
|
||||
newValue = MathUtil.clamp(newValue,
|
||||
Scratch3LooksBlocks.EFFECT_GHOST_LIMIT.min,
|
||||
Scratch3LooksBlocks.EFFECT_GHOST_LIMIT.max);
|
||||
}
|
||||
util.target.setEffect(effect, newValue);
|
||||
}
|
||||
|
||||
setEffect (args, util) {
|
||||
const effect = Cast.toString(args.EFFECT).toLowerCase();
|
||||
const value = Cast.toNumber(args.VALUE);
|
||||
let value = Cast.toNumber(args.VALUE);
|
||||
if (effect === 'ghost') {
|
||||
value = MathUtil.clamp(value,
|
||||
Scratch3LooksBlocks.EFFECT_GHOST_LIMIT.min,
|
||||
Scratch3LooksBlocks.EFFECT_GHOST_LIMIT.max);
|
||||
}
|
||||
util.target.setEffect(effect, value);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue