I have a project that contains a sprite the, in theory, should get slowly visible, but it doesn't. The sprite gets visible and the project works correctly only when I click the green flag TWICE (it works this way both online in the flash player and when downloded).
The project is the one at http://scratch.mit.edu/projects/s_federici/2901972.
Even if I could say "click twice the green flag to make it work" I would like to know why, clicking the green flag only once, the first "iceberg" script (the one at the top) starts working and then stops immediately. Instead, when I click the green flag twice, the top script keeps working, so that the sprite (whose initial ghost effect is 100) get slowly visible (the ghost effect is repeatedly changed by -2 by this very script).
Any clue is welcome!!!!
Offline
s_federici wrote:
I have a project that contains a sprite the, in theory, should get slowly visible, but it doesn't. The sprite gets visible and the project works correctly only when I click the green flag TWICE (it works this way both online in the flash player and when downloded).
The project is the one at http://scratch.mit.edu/projects/s_federici/2901972.
Even if I could say "click twice the green flag to make it work" I would like to know why, clicking the green flag only once, the first "iceberg" script (the one at the top) starts working and then stops immediately. Instead, when I click the green flag twice, the top script keeps working, so that the sprite (whose initial ghost effect is 100) get slowly visible (the ghost effect is repeatedly changed by -2 by this very script).
The reason is that at the point of initialisation, the waterline is at the bottom, so both "repeat until" loops fail, and the iceberg script finishes immediately. What you want is the waterline's init script to run first to put it in the right place, so when the iceberg then asks "distance to waterline < 180" it will return false.
Adding "wait (0) secs" to the top of the iceberg script seems to work — it should yield control flow to the other threads, ensuring they run first.
Offline
blob8108 wrote:
The reason is that at the point of initialisation, the waterline is at the bottom
Of course. I didn't take into account the order in which all the initialisations work. And, of course, when I doubleclick the waterline is already at its correct position (due to the first click )
Thanks a lot, excellent analisys
Offline