O'Reilly logo

Learning MIT App Inventor: A Hands-On Guide to Building Your Own Android Apps by Mark Sherman, Derek Walter

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Edges and Collisions

Another way to affect movement with sprites is through the blocks that control edges and collisions.

In the Flick app, we used the whenEdgeReached block to tell the ball to bounce off the edges.

A similar effect is used for collisions. Given that many games have collisions, this kind of permission comes in handy. Event handlers in the ImageSprite and the ball report when sprites collide with each other on the canvas and let you handle that collision however you want. If you specify nothing, they will pass through each other. The “collision” still happens, but no behavior change occurs. You must specify any behavior change you want, and it can be whatever you like.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required