summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCode WvS <code-wvs@quantentunnel.de>2015-02-27 18:29:29 +0100
committerCode WvS <code-wvs@quantentunnel.de>2015-02-27 18:29:29 +0100
commitce2d8c203d872a59ae329c7b4dae31c423dc7e4a (patch)
treee901e02cd337f1d78023fe5534435de114305aff
parent1ce7a259f2182e9ddecff1a95a123495d7b293ea (diff)
downloadsnap-yow-ce2d8c203d872a59ae329c7b4dae31c423dc7e4a.tar.gz
snap-yow-ce2d8c203d872a59ae329c7b4dae31c423dc7e4a.zip
fix sprite costume bugs
-rw-r--r--objects.js16
-rw-r--r--store.js5
2 files changed, 16 insertions, 5 deletions
diff --git a/objects.js b/objects.js
index c29fad5..845a274 100644
--- a/objects.js
+++ b/objects.js
@@ -1336,8 +1336,8 @@ SpriteMorph.prototype.init = function (globals) {
this.variables = new VariableFrame(globals || null, this);
this.scripts = new ScriptsMorph(this);
this.customBlocks = [];
- this.costume = new Costume(window.defaultCostume, "marker");
- this.costumes = new List([this.costume]);
+ this.costumes = new List();
+ this.costume = null;
this.sounds = new List();
this.normalExtent = new Point(60, 60); // only for costume-less situation
this.scale = 1;
@@ -1377,7 +1377,12 @@ SpriteMorph.prototype.init = function (globals) {
this.isDown = false;
// Snap! - YOW code
- this.geoposition = window.map.getCenter();
+ var markerCostume = new Costume(window.defaultCostume, "marker-" + this.name);
+ this.costumes.add(markerCostume);
+ this.costume = markerCostume;
+
+ this.geoposition = [window.map.getCenter().lat,
+ window.map.getCenter().lng];
// TODO this is a bit hacky
this.marker = L.spriteMarker(this.geoposition);
@@ -2600,6 +2605,7 @@ SpriteMorph.prototype.addCostume = function (costume) {
};
SpriteMorph.prototype.wearCostume = function (costume) {
+ if (costume == null) return; // Snap! YOW
var x = this.xPosition ? this.xPosition() : null,
y = this.yPosition ? this.yPosition() : null,
isWarped = this.isWarped;
@@ -2671,7 +2677,7 @@ SpriteMorph.prototype.doSwitchToCostume = function (id) {
(id instanceof Array ? id[0] : null)
)
) {
- this.costume = new Costume(window.defaultCostume, "marker");
+ this.costume = null;
} else {
if (id === -1) {
this.doWearPreviousCostume();
@@ -2683,7 +2689,7 @@ SpriteMorph.prototype.doSwitchToCostume = function (id) {
if (costume === null) {
num = parseFloat(id);
if (num === 0) {
- this.costume = new Costume(window.defaultCostume, "marker");
+ this.costume = null;
} else {
costume = arr[num - 1] || null;
}
diff --git a/store.js b/store.js
index 056767f..d810985 100644
--- a/store.js
+++ b/store.js
@@ -1312,6 +1312,11 @@ SnapSerializer.prototype.openProject = function (project, ide) {
var stage = ide.stage,
sprites = [],
sprite;
+
+ // recreate all Sprite markers (Snap-YOW)
+ window.map.removeLayer(window.spriteGroup);
+ window.spriteGroup = L.layerGroup().addTo(window.map);
+
if (!project || !project.stage) {
return;
}