code-dot-org/blockly — pull request #534 by cpirich (2014-04-30 18:33:09+00:00)
Title: [finishes #70375064] add stop block

The stop block is mostly straightforward. It cancels any "in progress" move operations on a specific sprite. It currently has no impact on the "immediate move" block.

However, there are two things that make this change a little more complex based on an anticipated use case: With the stop block, you can use collision events to cancel "in progress" moves to make it impossible for sprites to overlap or stay in a collided state.

Change 1: we need to detect collisions on the expected positions of the sprites before actually moving the sprites. This way, you can essentially cancel a move that would result in overlapping/collided sprites.
Change 2: we need to reset the collision mask on the sprite when stop() executes so that in the next frame we will re-check and potentially fire another collision event. Otherwise, once you overlap, you can't detect that you are still overlapping and movement will resume normally.

Adjusted collision distance slightly based on the sprite artwork. The bounding box is now 90% of the 100x100 size of the sprite image.