Doing the script:
(distance to (mouse x))always gives the result "10000" regardless of how far it is away. Tested on Scratch 1.4 with OS X Lion. The bug also occurs with other reporters such as "costume #" and "loudness", all with the result "10000".
Offline
This is because mouse x is a number not a co-ordinate. Therefore it assumes the co-ordinate is x: every possible number at the same time, y: every possible number at the same time. It then gets confused and sets itself to the highest it can go.
Offline
the distance block only works with sprites. To find out the actual distance from the mouse, use this script instead:
( [sqrt v] of (((mouse x) * (mouse x)) + ((mouse y) * (mouse y))))
Offline
LS97 wrote:
the distance block only works with sprites. To find out the actual distance from the mouse, use this script instead:
(distance to( [sqrt v] of (((mouse x) * (mouse x)) + ((mouse y) * (mouse y)))))
Fixed.... I think
Offline
mmww wrote:
LS97 wrote:
the distance block only works with sprites. To find out the actual distance from the mouse, use this script instead:
(distance to( [sqrt v] of (((mouse x) * (mouse x)) + ((mouse y) * (mouse y)))))Fixed.... I think
no. it was right the first time. that IS the distance formula already, what you wrote is the distance formula of a distance formula
Offline
LS97 wrote:
the distance block only works with sprites. To find out the actual distance from the mouse, use this script instead:
( [sqrt v] of (((mouse x) * (mouse x)) + ((mouse y) * (mouse y))))
That's the distance from the mouse to the centre. Do ((mouse x) - (x position)) and ((mouse y) - (y position)) instead.
Offline
jontmy00 wrote:
The reporter shouldn't even fit in in the first place.





Offline
jontmy00 wrote:
The reporter shouldn't even fit in in the first place.
Bingo.
LS's script is the mathematical equation of figuring out a distance, so yeah, use that.
This would figure out the distance in total, but if you only want the X distance, use
((mouse x) - (x position))Put an ABS on that if you want the absolute distance, regardless of direction.
Offline
jontmy00 wrote:
Okay, topic not so resolved. I want the ST's confirmation because it still fits in in 2.0 but reports "0", which is different from 1.4.
In reality, there is no answer to the function you gave as it'd be like saying
(distance to (9000))The only reason (I think) it returns 0 or 10000 is because there is some sort of coding that makes that the default value; after all, if it returned null or an error, it could screw up some projects
Offline
SJRCS_011 wrote:
jontmy00 wrote:
Okay, topic not so resolved. I want the ST's confirmation because it still fits in in 2.0 but reports "0", which is different from 1.4.
In reality, there is no answer to the function you gave as it'd be like saying
(distance to (9000))
I know that.
SJRCS_011 wrote:
The only reason (I think) it returns 0 or 10000 is because there is some sort of coding that makes that the default value; after all, if it returned null or an error, it could screw up some projects
But it is different between the 2 versions, so why?
Offline
Flash isn't Squeak. Their null returns different values.
Offline