1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

Sprite Groups in Rubygame


Sprite groups are just a way of grouping related sprites into a single collection. For example, all the enemies can be in a group, all of the bullets can be in another group and so forth and so on. This makes managing your game objects much simpler as well as simplifying your main loop by allowing you to update and draw an entire group of sprites with a single call.

Sprite groups are implemented by extending the standard Ruby array class. So sprite groups are just arrays. You can use all the same methods as arrays for modifying and manipulating sprite groups, so there's no new classes to learn.

The sprite group class is called Sprites::Group. After creating an instance of this class, you can then add sprites to the collection by using methods such as push. The sprites in the group can then be updated and drawn as a single sprite, vastly simplifying your main loop.

  1. About.com
  2. Technology
  3. Ruby
  4. Tutorials
  5. Game Programming
  6. Sprite Groups

©2014 About.com. All rights reserved.