Skip to content

Commit fe22961

Browse files
committed
fixes #642 -- the stage scaling was not being updated properly so the coordinates passed to overTrash were wrong
1 parent bd97f3a commit fe22961

File tree

3 files changed

+120
-107
lines changed

3 files changed

+120
-107
lines changed

js/activity.js

Lines changed: 55 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ define(function (require) {
153153

154154
// Are we running off of a server?
155155
var server = true;
156-
var turlteBlocksScale = 1;
156+
var turtleBlocksScale = 1;
157157
var stage;
158158
var turtles;
159159
var palettes;
@@ -272,8 +272,8 @@ define(function (require) {
272272
palettes.initial_x = 55;
273273
palettes.initial_y = 55;
274274
palettes.updatePalettes();
275-
var x = 100 * turlteBlocksScale;
276-
var y = 100 * turlteBlocksScale;
275+
var x = 100 * turtleBlocksScale;
276+
var y = 100 * turtleBlocksScale;
277277
for (var blk in blocks.blockList) {
278278
if (!blocks.blockList[blk].trash) {
279279
var myBlock = blocks.blockList[blk];
@@ -290,10 +290,10 @@ define(function (require) {
290290
}
291291
}
292292
}
293-
x += 200 * turlteBlocksScale;
294-
if (x > (canvas.width - 100) / (turlteBlocksScale)) {
295-
x = 100 * turlteBlocksScale;
296-
y += 100 * turlteBlocksScale;
293+
x += 200 * turtleBlocksScale;
294+
if (x > (canvas.width - 100) / (turtleBlocksScale)) {
295+
x = 100 * turtleBlocksScale;
296+
y += 100 * turtleBlocksScale;
297297
}
298298
}
299299
}
@@ -512,7 +512,7 @@ define(function (require) {
512512

513513
function closeAnalytics(chartBitmap, ctx) {
514514
var button = this;
515-
button.x = (canvas.width / (2 * turlteBlocksScale)) + (300 / Math.sqrt(2));
515+
button.x = (canvas.width / (2 * turtleBlocksScale)) + (300 / Math.sqrt(2));
516516
button.y = 300.00 - (300.00 / Math.sqrt(2));
517517
this.closeButton = _makeButton('cancel-button', _('Close'), button.x, button.y, 55, 0);
518518
this.closeButton.on('click', function(event) {
@@ -554,7 +554,7 @@ define(function (require) {
554554
img.onload = function () {
555555
var chartBitmap = new createjs.Bitmap(img);
556556
stage.addChild(chartBitmap);
557-
chartBitmap.x = (canvas.width / (2 * turlteBlocksScale)) - (300);
557+
chartBitmap.x = (canvas.width / (2 * turtleBlocksScale)) - (300);
558558
chartBitmap.y = 0;
559559
chartBitmap.scaleX = chartBitmap.scaleY = chartBitmap.scale = 600 / chartBitmap.image.width;
560560
logo.hideBlocks();
@@ -948,23 +948,23 @@ define(function (require) {
948948
palettes.menuScrollEvent(delta, scrollSpeed);
949949
palettes.hidePaletteIconCircles();
950950
} else {
951-
palette = palettes.findPalette(event.clientX / turlteBlocksScale, event.clientY / turlteBlocksScale);
951+
palette = palettes.findPalette(event.clientX / turtleBlocksScale, event.clientY / turtleBlocksScale);
952952
if (palette) {
953953
palette.scrollEvent(delta, scrollSpeed);
954954
}
955955
}
956956
};
957957

958958
function getStageScale() {
959-
return turlteBlocksScale;
959+
return turtleBlocksScale;
960960
};
961961

962962
function getStageX() {
963-
return turtles.screenX2turtleX(stageX / turlteBlocksScale);
963+
return turtles.screenX2turtleX(stageX / turtleBlocksScale);
964964
};
965965

966966
function getStageY() {
967-
return turtles.screenY2turtleY(stageY / turlteBlocksScale);
967+
return turtles.screenY2turtleY(stageY / turtleBlocksScale);
968968
};
969969

970970
function getStageMouseDown() {
@@ -1254,45 +1254,45 @@ define(function (require) {
12541254
if (smallSide < cellSize * 11) {
12551255
var mobileSize = true;
12561256
if (w < cellSize * 10) {
1257-
turlteBlocksScale = smallSide / (cellSize * 11);
1257+
turtleBlocksScale = smallSide / (cellSize * 11);
12581258
} else {
1259-
turlteBlocksScale = Math.max(smallSide / (cellSize * 11), 0.75);
1259+
turtleBlocksScale = Math.max(smallSide / (cellSize * 11), 0.75);
12601260
}
12611261
} else {
12621262
var mobileSize = false;
12631263
if (w / 1200 > h / 900) {
1264-
turlteBlocksScale = w / 1200;
1264+
turtleBlocksScale = w / 1200;
12651265
} else {
1266-
turlteBlocksScale = h / 900;
1266+
turtleBlocksScale = h / 900;
12671267
}
12681268
}
12691269

1270-
stage.scaleX = turlteBlocksScale;
1271-
stage.scaleY = turlteBlocksScale;
1270+
stage.scaleX = turtleBlocksScale;
1271+
stage.scaleY = turtleBlocksScale;
12721272

12731273
stage.canvas.width = w;
12741274
stage.canvas.height = h;
12751275

1276-
console.log('Resize: scale ' + turlteBlocksScale +
1276+
console.log('Resize: scale ' + turtleBlocksScale +
12771277
', windowW ' + w + ', windowH ' + h +
12781278
', canvasW ' + canvas.width + ', canvasH ' + canvas.height +
12791279
', screenW ' + screen.width + ', screenH ' + screen.height);
12801280

1281-
turtles.setScale(turlteBlocksScale);
1282-
blocks.setScale(turlteBlocksScale);
1283-
boundary.setScale(w, h, turlteBlocksScale);
1284-
palettes.setScale(turlteBlocksScale);
1285-
trashcan.resizeEvent(turlteBlocksScale);
1281+
turtles.setScale(turtleBlocksScale);
1282+
blocks.setScale(turtleBlocksScale);
1283+
boundary.setScale(w, h, turtleBlocksScale);
1284+
palettes.setScale(turtleBlocksScale);
1285+
trashcan.resizeEvent(turtleBlocksScale);
12861286
_setupAndroidToolbar(mobileSize);
12871287

12881288
// Reposition coordinate grids.
1289-
cartesianBitmap.x = (canvas.width / (2 * turlteBlocksScale)) - (600);
1290-
cartesianBitmap.y = (canvas.height / (2 * turlteBlocksScale)) - (450);
1291-
polarBitmap.x = (canvas.width / (2 * turlteBlocksScale)) - (600);
1292-
polarBitmap.y = (canvas.height / (2 * turlteBlocksScale)) - (450);
1289+
cartesianBitmap.x = (canvas.width / (2 * turtleBlocksScale)) - (600);
1290+
cartesianBitmap.y = (canvas.height / (2 * turtleBlocksScale)) - (450);
1291+
polarBitmap.x = (canvas.width / (2 * turtleBlocksScale)) - (600);
1292+
polarBitmap.y = (canvas.height / (2 * turtleBlocksScale)) - (450);
12931293
update = true;
12941294

1295-
// Setup help now that we have calculated turlteBlocksScale.
1295+
// Setup help now that we have calculated turtleBlocksScale.
12961296
_showHelp(true);
12971297

12981298
// Hide palette icons on mobile
@@ -1418,7 +1418,8 @@ define(function (require) {
14181418

14191419
var actionName = actionArg.value;
14201420
if (actionName !== _('action')) {
1421-
blocks.checkPaletteEntries('action');
1421+
// blocks.checkPaletteEntries('action');
1422+
console.log('FIXME: Check for unique action name here');
14221423
}
14231424
}
14241425
}
@@ -1427,11 +1428,11 @@ define(function (require) {
14271428
};
14281429

14291430
function _deleteBlocksBox() {
1430-
clearBox.show(turlteBlocksScale);
1431+
clearBox.show(turtleBlocksScale);
14311432
};
14321433

14331434
function _doUtilityBox() {
1434-
utilityBox.init(turlteBlocksScale, utilityButton.x - 27, utilityButton.y, _makeButton);
1435+
utilityBox.init(turtleBlocksScale, utilityButton.x - 27, utilityButton.y, _makeButton);
14351436
};
14361437

14371438
function sendAllToTrash(addStartBlock, doNotSave) {
@@ -2202,7 +2203,7 @@ handleComplete);
22022203
}
22032204

22042205
headerContainer = new createjs.Shape();
2205-
headerContainer.graphics.f(platformColor.header).r(0, 0, screen.width / turlteBlocksScale, cellSize);
2206+
headerContainer.graphics.f(platformColor.header).r(0, 0, screen.width / turtleBlocksScale, cellSize);
22062207

22072208
if (platformColor.doHeaderShadow) {
22082209
headerContainer.shadow = new createjs.Shadow('#777', 0, 2, 2);
@@ -2277,10 +2278,10 @@ handleComplete);
22772278
y += dy;
22782279
}
22792280

2280-
_setupRightMenu(turlteBlocksScale);
2281+
_setupRightMenu(turtleBlocksScale);
22812282
};
22822283

2283-
function _setupRightMenu(turlteBlocksScale) {
2284+
function _setupRightMenu(turtleBlocksScale) {
22842285
if (menuContainer !== undefined) {
22852286
stage.removeChild(menuContainer);
22862287
for (var i in onscreenMenu) {
@@ -2308,7 +2309,7 @@ handleComplete);
23082309
});
23092310

23102311
var btnSize = cellSize;
2311-
var x = Math.floor(canvas.width / turlteBlocksScale) - btnSize / 2;
2312+
var x = Math.floor(canvas.width / turtleBlocksScale) - btnSize / 2;
23122313
var y = Math.floor(btnSize / 2);
23132314

23142315
var dx = 0;
@@ -2366,19 +2367,19 @@ handleComplete);
23662367
if (helpIdx >= HELPCONTENT.length) {
23672368
helpIdx = 0;
23682369
}
2369-
var imageScale = 55 * turlteBlocksScale;
2370+
var imageScale = 55 * turtleBlocksScale;
23702371
helpElem.innerHTML = '<img src ="' + HELPCONTENT[helpIdx][2] + '" style="height:' + imageScale + 'px; width: auto"></img> <h2>' + HELPCONTENT[helpIdx][0] + '</h2><p>' + HELPCONTENT[helpIdx][1] + '</p>';
23712372
}
23722373
update = true;
23732374
});
23742375

23752376
var img = new Image();
23762377
img.onload = function () {
2377-
console.log(turlteBlocksScale);
2378+
console.log(turtleBlocksScale);
23782379
var bitmap = new createjs.Bitmap(img);
23792380
/*
2380-
if (turlteBlocksScale > 1) {
2381-
bitmap.scaleX = bitmap.scaleY = bitmap.scale = turlteBlocksScale;
2381+
if (turtleBlocksScale > 1) {
2382+
bitmap.scaleX = bitmap.scaleY = bitmap.scale = turtleBlocksScale;
23822383
} else {
23832384
bitmap.scaleX = bitmap.scaleY = bitmap.scale = 1.125;
23842385
}
@@ -2409,23 +2410,23 @@ handleComplete);
24092410
var helpElem = docById('helpElem');
24102411
helpElem.style.position = 'absolute';
24112412
helpElem.style.display = 'block';
2412-
helpElem.style.paddingLeft = 20 * turlteBlocksScale + 'px';
2413-
helpElem.style.paddingRight = 20 * turlteBlocksScale + 'px';
2413+
helpElem.style.paddingLeft = 20 * turtleBlocksScale + 'px';
2414+
helpElem.style.paddingRight = 20 * turtleBlocksScale + 'px';
24142415
helpElem.style.paddingTop = '0px';
2415-
helpElem.style.paddingBottom = 20 * turlteBlocksScale + 'px';
2416-
helpElem.style.fontSize = 20 + 'px'; // * turlteBlocksScale + 'px';
2416+
helpElem.style.paddingBottom = 20 * turtleBlocksScale + 'px';
2417+
helpElem.style.fontSize = 20 + 'px'; // * turtleBlocksScale + 'px';
24172418
helpElem.style.color = '#000000'; // '#ffffff';
2418-
helpElem.style.left = 65 * turlteBlocksScale + 'px';
2419-
helpElem.style.top = 105 * turlteBlocksScale + 'px';
2420-
var w = Math.min(300, 300); // * turlteBlocksScale);
2421-
var h = Math.min(300, 300); // * turlteBlocksScale);
2419+
helpElem.style.left = 65 * turtleBlocksScale + 'px';
2420+
helpElem.style.top = 105 * turtleBlocksScale + 'px';
2421+
var w = Math.min(300, 300); // * turtleBlocksScale);
2422+
var h = Math.min(300, 300); // * turtleBlocksScale);
24222423
helpElem.style.width = w + 'px';
24232424
helpElem.style.height = h + 'px';
24242425

2425-
if (turlteBlocksScale > 1) {
2426+
if (turtleBlocksScale > 1) {
24262427
var bitmap = helpContainer.children[0];
24272428
if (bitmap != undefined) {
2428-
// bitmap.scaleX = bitmap.scaleY = bitmap.scale = turlteBlocksScale;
2429+
// bitmap.scaleX = bitmap.scaleY = bitmap.scale = turtleBlocksScale;
24292430
}
24302431
}
24312432

@@ -2609,8 +2610,8 @@ handleComplete);
26092610
container.on('mousedown', function (event) {
26102611
var moved = true;
26112612
var offset = {
2612-
x: container.x - Math.round(event.stageX / turlteBlocksScale),
2613-
y: container.y - Math.round(event.stageY / turlteBlocksScale)
2613+
x: container.x - Math.round(event.stageX / turtleBlocksScale),
2614+
y: container.y - Math.round(event.stageY / turtleBlocksScale)
26142615
};
26152616

26162617
pressTimer = setTimeout(function() {
@@ -2629,7 +2630,7 @@ handleComplete);
26292630
}
26302631
}, 1000);
26312632

2632-
var circles = showButtonHighlight(ox, oy, cellSize / 2, event, turlteBlocksScale, stage);
2633+
var circles = showButtonHighlight(ox, oy, cellSize / 2, event, turtleBlocksScale, stage);
26332634

26342635
container.on('pressup', function (event) {
26352636
hideButtonHighlight(circles, stage);

0 commit comments

Comments
 (0)