UNPKG

cdf

Version:

A library for creating oldschool demo-like animations with JavaScript

22 lines (15 loc) 501 B
var Scene = function(){ var scene = this; var initialized = false; this.draw = function(){ if(!initialized) this.init(); return this.trigger('draw',[this], this); } var isPlaying = this.state = true; this.toggle = function(toggle){ isPlaying = this.state = toggle===undefined ? !isPlaying : !!toggle; return scene.trigger(isPlaying?'pause':'play',[this],this); }; this.animate = this.__animate = function(){if(isPlaying)scene.draw();}; }; module.exports = Scene;