Letting bubble bounce and stop

To make a complete shooting routine, bubble must bounce off game field sides and stop once it touches the upper side.

The idea: To make bubble bounce off game field sides, we have to check if the bubble is leaving the game field to the left or right side. In both cases, inverting the horizontal speed will make the bubble bounce off. When it's about to leave the game field to the upper side, we have to stop its movement.

The development: We only need to make some changes to onEFrame function, as it's the one and only one that handles bubble movement. The concept is very simple to the one developed to make enemy spaceships bounce off the game area during the making of Astro-Panic! so it does not need that much commenting: ...

Get Flash Game Development by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.