kopia lustrzana https://github.com/backface/turtlestitch
rodzic
f48460fc25
commit
21a29e3706
45
objects.js
45
objects.js
|
@ -124,7 +124,7 @@ PrototypeHatBlockMorph*/
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.objects = '2013-December-12';
|
modules.objects = '2013-December-18';
|
||||||
|
|
||||||
var SpriteMorph;
|
var SpriteMorph;
|
||||||
var StageMorph;
|
var StageMorph;
|
||||||
|
@ -1680,7 +1680,9 @@ SpriteMorph.prototype.blockTemplates = function (category) {
|
||||||
blocks.push(watcherToggle('getLastAnswer'));
|
blocks.push(watcherToggle('getLastAnswer'));
|
||||||
blocks.push(block('getLastAnswer'));
|
blocks.push(block('getLastAnswer'));
|
||||||
blocks.push('-');
|
blocks.push('-');
|
||||||
|
blocks.push(watcherToggle('reportMouseX'));
|
||||||
blocks.push(block('reportMouseX'));
|
blocks.push(block('reportMouseX'));
|
||||||
|
blocks.push(watcherToggle('reportMouseY'));
|
||||||
blocks.push(block('reportMouseY'));
|
blocks.push(block('reportMouseY'));
|
||||||
blocks.push(block('reportMouseDown'));
|
blocks.push(block('reportMouseDown'));
|
||||||
blocks.push('-');
|
blocks.push('-');
|
||||||
|
@ -3046,6 +3048,24 @@ SpriteMorph.prototype.getLastAnswer = function () {
|
||||||
return this.parentThatIsA(StageMorph).lastAnswer;
|
return this.parentThatIsA(StageMorph).lastAnswer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// SpriteMorph mouse coordinates
|
||||||
|
|
||||||
|
SpriteMorph.prototype.reportMouseX = function () {
|
||||||
|
var stage = this.parentThatIsA(StageMorph);
|
||||||
|
if (stage) {
|
||||||
|
return stage.reportMouseX();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
SpriteMorph.prototype.reportMouseY = function () {
|
||||||
|
var stage = this.parentThatIsA(StageMorph);
|
||||||
|
if (stage) {
|
||||||
|
return stage.reportMouseY();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
// SpriteMorph variable watchers (for palette checkbox toggling)
|
// SpriteMorph variable watchers (for palette checkbox toggling)
|
||||||
|
|
||||||
SpriteMorph.prototype.findVariableWatcher = function (varName) {
|
SpriteMorph.prototype.findVariableWatcher = function (varName) {
|
||||||
|
@ -3949,6 +3969,24 @@ StageMorph.prototype.getLastMessage = function () {
|
||||||
return this.lastMessage || '';
|
return this.lastMessage || '';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// StageMorph Mouse Corridnates
|
||||||
|
|
||||||
|
StageMorph.prototype.reportMouseX = function () {
|
||||||
|
var world = this.world();
|
||||||
|
if (world) {
|
||||||
|
return (world.hand.position().x - this.center().x) / this.scale;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
StageMorph.prototype.reportMouseY = function () {
|
||||||
|
var world = this.world();
|
||||||
|
if (world) {
|
||||||
|
return (this.center().y - world.hand.position().y) / this.scale;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
// StageMorph drag & drop
|
// StageMorph drag & drop
|
||||||
|
|
||||||
StageMorph.prototype.wantsDropOf = function (aMorph) {
|
StageMorph.prototype.wantsDropOf = function (aMorph) {
|
||||||
|
@ -4342,7 +4380,9 @@ StageMorph.prototype.blockTemplates = function (category) {
|
||||||
blocks.push(watcherToggle('getLastAnswer'));
|
blocks.push(watcherToggle('getLastAnswer'));
|
||||||
blocks.push(block('getLastAnswer'));
|
blocks.push(block('getLastAnswer'));
|
||||||
blocks.push('-');
|
blocks.push('-');
|
||||||
|
blocks.push(watcherToggle('reportMouseX'));
|
||||||
blocks.push(block('reportMouseX'));
|
blocks.push(block('reportMouseX'));
|
||||||
|
blocks.push(watcherToggle('reportMouseY'));
|
||||||
blocks.push(block('reportMouseY'));
|
blocks.push(block('reportMouseY'));
|
||||||
blocks.push(block('reportMouseDown'));
|
blocks.push(block('reportMouseDown'));
|
||||||
blocks.push('-');
|
blocks.push('-');
|
||||||
|
@ -6004,7 +6044,8 @@ WatcherMorph.prototype.object = function () {
|
||||||
|
|
||||||
WatcherMorph.prototype.isGlobal = function (selector) {
|
WatcherMorph.prototype.isGlobal = function (selector) {
|
||||||
return contains(
|
return contains(
|
||||||
['getTimer', 'getLastAnswer', 'getTempo', 'getLastMessage'],
|
['getLastAnswer', 'getLastMessage', 'getTempo', 'getTimer',
|
||||||
|
'reportMouseX', 'reportMouseY'],
|
||||||
selector
|
selector
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Ładowanie…
Reference in New Issue