Module | Rubygame::Sprites::UpdateGroup |
In: |
lib/rubygame/sprite.rb
lib/rubygame/sprite.rb |
UpdateGroup is a mix-in module that extends Group to allow it to "erase" (i.e. draw over with a background Surface) and re-draw each sprite in its new position. This eliminates the "trail" of images that sprites would otherwise leave as they move around.
UpdateGroup adds a new attribute, @dirty_rects, which is an Array storing all Rects which need to be updated, including the old positions of the sprites. This attribute is returned when UpdateGroup#draw is called, so that it can be used to update the parts of the Screen that have changed.
The general order of calls each frame should be:
This module can extend either a class or an already-existing Group instance (either empty or with members) without any special preparation.
dirty_rects | [RW] | |
dirty_rects | [RW] |
Draw every sprite on Surface dest. See Group#draw. Returns an Array of Rects representing the portions of dest which were affected by the last undraw and this draw.
Draw every sprite on Surface dest. See Group#draw. Returns an Array of Rects representing the portions of dest which were affected by the last undraw and this draw.
Draw over part of dest with image data from the corresponding part of background. For best results, background should be at least as big as dest (or, rather, the part of dest that will ever be drawn over).