O'Reilly logo

Programming Wireless Devices with the Java™ 2 Platform, Micro Edition, Second Edition by Jim Holliday - Editor, Aleksi Uotila, Mark Patel, Jyri Huopaniemi, Jim Van Peursem, Antero Taivalsaari, Roger Riggs

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

12.6. Collision Detection

Collision detection is a key feature of the Game API, enabling the developers to quickly and easily determine whether two elements of a game have collided or not.

The collision detection methods are provided in the Sprite class, and they allow the developer to detect a collision between a Sprite and either a TiledLayer, an Image, or another Sprite.

12.6.1. Collision Rectangle

Sprites have a defined collision rectangle that indicates the region to be included for collision detection. By default, this region corresponds to the overall bounds of the Sprite. However, it can be redefined to cover any rectangular region as needed.

A special collision rectangle allows areas of a Sprite to be excluded from the collision detection ...

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