mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-29 23:49:21 -04:00
Scope renderer to instance
This allows usage without global scope to attach a renderer to the VM. It also provides the ability to have multiple VMs/renderers to be used at once.
This commit is contained in:
parent
c02ee88d02
commit
499ba5235c
5 changed files with 22 additions and 16 deletions
src/engine
|
@ -19,13 +19,20 @@ var defaultBlockPackages = {
|
|||
|
||||
/**
|
||||
* Manages targets, scripts, and the sequencer.
|
||||
* @param {!RenderWebGL} renderer Renderer for the VM
|
||||
*/
|
||||
function Runtime () {
|
||||
function Runtime (renderer) {
|
||||
// Bind event emitter
|
||||
EventEmitter.call(this);
|
||||
|
||||
// State for the runtime
|
||||
|
||||
/**
|
||||
* Renderer
|
||||
* @type {!RenderWebGL}
|
||||
*/
|
||||
this.renderer = renderer;
|
||||
|
||||
/**
|
||||
* Target management and storage.
|
||||
* @type {Array.<!Target>}
|
||||
|
@ -573,8 +580,8 @@ Runtime.prototype.getTargetForStage = function () {
|
|||
* Handle an animation frame from the main thread.
|
||||
*/
|
||||
Runtime.prototype.animationFrame = function () {
|
||||
if (self.renderer) {
|
||||
self.renderer.draw();
|
||||
if (this.renderer) {
|
||||
this.renderer.draw();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue