Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The first error the compiler gives you is here...</p> <pre><code>Sprite.load </code></pre> <p>It detects that there is no property or function on the Sprite object called <code>load</code>.</p> <p>The second error is here...</p> <pre><code>var tile = Sprite(this); </code></pre> <p>The Sprite constructor takes five parameters and you have only passed 1.</p> <p>Third up...</p> <pre><code>window.Sprite </code></pre> <p>The Window object doesn't have a property named Sprite.</p> <p>All of the other problems are variations of this issue.</p> <p>Here is a suggestion to get things working with minimal changes. The better solution would be to rewrite your Sprite as a class in TypeScript</p> <pre><code>var Sprite; (function () { function LoaderProxy() { return { draw: $.noop, fill: $.noop, frame: $.noop, update: $.noop, width: null, height: null }; } Sprite = function (image, sourceX, sourceY, width, height) { sourceX = sourceX || 0; sourceY = sourceY || 0; width = width || image.width; height = height || image.height; return { draw: function(canvas, x, y) { canvas.drawImage( image, sourceX, sourceY, width, height, x, y, width, height ); }, fill: function(canvas, x, y, width, height, repeat) { repeat = repeat || "repeat"; var pattern = canvas.createPattern(image, repeat); canvas.fillColor(pattern); canvas.fillRect(x, y, width, height); }, width: width, height: height }; }; Sprite.load = function(url, loadedCallback) { var img = new Image(); var proxy = LoaderProxy(); img.onload = function() { var tile = Sprite(this); $.extend(proxy, tile); if(loadedCallback) { loadedCallback(proxy); } }; img.src = url; return proxy; }; var spriteImagePath = "images/"; Sprite = function(name, callback) { return Sprite.load(spriteImagePath + name + ".png", callback); }; Sprite.EMPTY = LoaderProxy(); Sprite.load = Sprite.load; }()); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload