fix error of last commit ;)

dev-2.0-svg
Michael Aschauer 2017-01-21 12:29:20 +01:00
rodzic 0143440926
commit 29b44758dc
3 zmienionych plików z 35 dodań i 7 usunięć

Wyświetl plik

@ -42,8 +42,7 @@
world = new WorldMorph(document.getElementById('world')); world = new WorldMorph(document.getElementById('world'));
world.worldCanvas.focus(); world.worldCanvas.focus();
new IDE_Morph().openIn(world); new IDE_Morph().openIn(world);
turtleShepherd = new TurtleShepherd(world);
DEBUG = true;
if (DEBUG) turtleShepherd.debug_msg("this world is " + this.world ); if (DEBUG) turtleShepherd.debug_msg("this world is " + this.world );
if (DEBUG) turtleShepherd.debug_msg("this world has " + if (DEBUG) turtleShepherd.debug_msg("this world has " +
this.world.children.length + " child(ren)"); this.world.children.length + " child(ren)");

Wyświetl plik

@ -7,9 +7,7 @@ IDE_Morph.prototype.originalInit = IDE_Morph.prototype.init;
IDE_Morph.prototype.init = function(isAutoFill) { IDE_Morph.prototype.init = function(isAutoFill) {
this.originalInit(); this.originalInit();
this.padding = 1; this.padding = 1;
//this.backgroundColor = new Color(255,255,255); turtleShepherd.setWorld(this.world);
//this.setColor(this.backgroundColor);
//this.frameColor = new Color(220,220,220);
}; };
IDE_Morph.prototype.resourceURLOrig = IDE_Morph.prototype.resourceURL; IDE_Morph.prototype.resourceURLOrig = IDE_Morph.prototype.resourceURL;
@ -79,16 +77,35 @@ IDE_Morph.prototype.newProject = function () {
this.origNewProject(); this.origNewProject();
turtleShepherd.clear(); turtleShepherd.clear();
this.stage.reRender(); this.stage.reRender();
this.createStatusDisplay();
}; };
IDE_Morph.prototype.origRawOpenProjectString = IDE_Morph.prototype.rawOpenProjectString; IDE_Morph.prototype.origRawOpenProjectString = IDE_Morph.prototype.rawOpenProjectString;
IDE_Morph.prototype.rawOpenProjectString = function (str) { IDE_Morph.prototype.rawOpenProjectString = function (str) {
this.origRawOpenProjectString(str); this.origRawOpenProjectString(str);
turtleShepherd.clear(); turtleShepherd.clear();
// hide sprite
this.stage.children[0].hide(); this.stage.children[0].hide();
this.createStatusDisplay();
this.stage.reRender(); this.stage.reRender();
}; };
/*
TODO: remove sprite instead of hideing it?
IDE_Morph.prototype.originalRemoveSprite = IDE_Morph.prototype.removeSprite;
IDE_Morph.prototype.removeSprite = function (sprite) {
var stage = sprite.parentThatIsA(StageMorph);
stage.scene.remove(sprite.beetle);
stage.reRender();
this.originalRemoveSprite(sprite);
};
*/
// Create contol bar - (and add custom buttons) // Create contol bar - (and add custom buttons)
IDE_Morph.prototype.createControlBar = function () { IDE_Morph.prototype.createControlBar = function () {
// assumes the logo has already been created // assumes the logo has already been created

Wyświetl plik

@ -5,7 +5,16 @@
*/ */
function TurtleShepherd() {
this.init();
}
function TurtleShepherd(world) { function TurtleShepherd(world) {
this.init();
this.setWorld(world);
}
TurtleShepherd.prototype.init = function() {
this.w = 480; this.w = 480;
this.h = 360; this.h = 360;
this.clear(); this.clear();
@ -14,8 +23,7 @@ function TurtleShepherd(world) {
this.showStitches = true; this.showStitches = true;
this.showGrid = true; this.showGrid = true;
this.showTurtle = true; this.showTurtle = true;
this.world = world; };
}
TurtleShepherd.prototype.clear = function() { TurtleShepherd.prototype.clear = function() {
this.cache = []; this.cache = [];
@ -29,6 +37,10 @@ TurtleShepherd.prototype.clear = function() {
this.scale = 1; this.scale = 1;
}; };
TurtleShepherd.prototype.setWorld = function(world) {
this.world = world;
};
TurtleShepherd.prototype.hasSteps = function() { TurtleShepherd.prototype.hasSteps = function() {
return this.steps > 0; return this.steps > 0;
}; };