From 474df9671f28eba934d63b02f93e882acb199045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20M?= <UsualDeveloper@users.noreply.github.com> Date: Fri, 28 Aug 2015 11:31:44 +0200 Subject: [PATCH 1/2] Separate method building sprite costume image URI Sprite costume image URI construction moved to a separate method. --- js/Sprite.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js/Sprite.js b/js/Sprite.js index d9b788f..d32987d 100644 --- a/js/Sprite.js +++ b/js/Sprite.js @@ -113,6 +113,11 @@ var Sprite = function(data) { this.stacks = []; }; +// Creates a formatted URI for a costume image resource. +Sprite.prototype.formatCostumeImageUri = function(costume, io) { + return io.asset_base + costume.baseLayerMD5 + io.asset_suffix; +}; + // Attaches a Sprite (<img>) to a Scratch scene Sprite.prototype.attach = function(scene) { // Create textures and materials for each of the costumes. @@ -142,7 +147,7 @@ Sprite.prototype.attach = function(scene) { }) .attr({ 'crossOrigin': 'anonymous', - 'src': io.asset_base + this.costumes[c].baseLayerMD5 + io.asset_suffix + 'src': this.formatCostumeImageUri(this.costumes[c], io) }); } From 7b677aec3abb33791ceb9b36a8a8af9e6e938653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20M?= <UsualDeveloper@users.noreply.github.com> Date: Fri, 28 Aug 2015 12:05:07 +0200 Subject: [PATCH 2/2] Handling function added for 'stopScripts' operation. Handling function added for 'stopScripts' operation. --- js/Interpreter.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/js/Interpreter.js b/js/Interpreter.js index 2c1a517..7669372 100644 --- a/js/Interpreter.js +++ b/js/Interpreter.js @@ -306,6 +306,9 @@ Interpreter.prototype.initPrims = function() { this.primitiveTable['timerReset'] = function(b) { interp.timerBase = Date.now(); }; this.primitiveTable['timer'] = function(b) { return (Date.now() - interp.timerBase) / 1000; }; + // added by Lucas + this.primitiveTable['stopScripts'] = function(b) { interp.activeThread = new Thread(null); interp.threads = []; }; + new Primitives().addPrimsTo(this.primitiveTable); };