mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-11 13:59:23 -04:00
Use targetWasCreated
event to clone pen state
Remove explicit cloning of `_customState` in favor of smarter, state-specific cloning.
This commit is contained in:
parent
04871e24d6
commit
06d5994a32
4 changed files with 43 additions and 1 deletions
src/engine
|
@ -968,6 +968,16 @@ class Runtime extends EventEmitter {
|
|||
return this._cloneCounter < Runtime.MAX_CLONES;
|
||||
}
|
||||
|
||||
/**
|
||||
* Report that a new target has been created, possibly by cloning an existing target.
|
||||
* @param {Target} newTarget - the newly created target.
|
||||
* @param {Target} [sourceTarget] - the target used as a source for the new clone, if any.
|
||||
* @fires Runtime#targetWasCreated
|
||||
*/
|
||||
fireTargetWasCreated (newTarget, sourceTarget) {
|
||||
this.emit('targetWasCreated', newTarget, sourceTarget);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a target representing the Scratch stage, if one exists.
|
||||
* @return {?Target} The target, if found.
|
||||
|
@ -1014,4 +1024,12 @@ class Runtime extends EventEmitter {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event fired after a new target has been created, possibly by cloning an existing target.
|
||||
*
|
||||
* @event Runtime#targetWasCreated
|
||||
* @param {Target} newTarget - the newly created target.
|
||||
* @param {Target} [sourceTarget] - the target used as a source for the new clone, if any.
|
||||
*/
|
||||
|
||||
module.exports = Runtime;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue