scratchfoundation / scratchx

Scratch Extension Site
https://github.com/llk/scratchx
190 stars 120 forks source link

Wiki: clarify hat block description #67

Closed darren-a closed 1 year ago

darren-a commented 8 years ago

Would it be possible to add more detail in the wiki about how a hat block method is actually called?

I was expecting to see some kind of event listener registration but in the wiki and the example project I've looked at I don't see it. I can only assume that the hat method is constantly polled by the runtime and it does its own checking to see if it needs to be invoked. If its event condition (or conditions?) is (are) not satisfied it returns false (or just returns?) but if its event condition (or conditions?) is (are) satisfied it takes some action and returns true.

Do I have that right? Either way, may I respectfully suggest that we add some clarifying wording to the description?

Znapi commented 8 years ago

It seems like you have it right. A change to the polling method has been suggested a while ago, with the Scratch team showing some interest.

https://github.com/LLK/scratch-extension-docs/issues/10 https://github.com/LLK/scratchx/issues/22

darren-a commented 8 years ago

From playing around with the example code I can see in Js console that this is the case - the hat method is polled about every 20-60ms by the runtime. I guess that makes it very flexible but it seems quite a lot of overhead for an event that may not occur for quite a while.

darren-a commented 8 years ago

event registration and event listeners would seem worth investigating...