title: How to create onUpdate function with callback
body: <p>I would like to create a copy of a game called "Hill Climb Racing" using pixi.js and matter.js. I have found a simple scene manager and scene object written in TypeScript and I converted it to JavaScript but some part of code is not working... I would like to use the function <code>onUpdate</code> like this: <code>gameplay.onUpdate(function() {} );</code>, but I do not know how to call the callback in <code>onUpdate</code> function by function <code>this.update()</code>.</p>
  
  <pre class="lang-js prettyprint-override"><code>var callback = function() {}
  this.onUpdate = function(callback) {
    if (callback &amp;&amp; typeof callback == "function") {
      callback();
      console.log("looP");
    }
  }
  this.update = function() {
    callback();
  }
  </code></pre>