This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-11-11 17:11:49

s_federici
Scratcher
Registered: 2007-12-18
Posts: 500+

Project not working... maybe...

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

 

#2 2012-11-11 17:32:01

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Project not working... maybe...

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.  smile


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#3 2012-11-12 03:00:37

s_federici
Scratcher
Registered: 2007-12-18
Posts: 500+

Re: Project not working... maybe...

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  smile  )

Thanks a lot, excellent analisys  smile

Offline

 

Board footer