From 7f708e26c881455ddcdfc927153239cc25059acc Mon Sep 17 00:00:00 2001 From: John Croisant Date: Sun, 29 Jul 2007 20:10:00 +0000 Subject: [PATCH] =?UTF-8?q?[Patch=201758611]=20Daniel=20Neis=20Ara=C3=BAjo?= =?UTF-8?q?'s=20Sprite#undraw=20patch.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CREDITS | 7 ++++++- lib/rubygame/sprite.rb | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CREDITS b/CREDITS index 4d0c0248..fc3a4da1 100644 --- a/CREDITS +++ b/CREDITS @@ -35,6 +35,11 @@ Date:: received 2007-03-04; applied 2007-04-13 (r235). - Johan Berntsson - Email:: johan@microheaven.com + Email:: johan at microheaven.com Contribution:: Patch to add Mixer::Music class (music playback). Date:: 2007-04-27 (r304). + +- Daniel Neis Araujo / danielneis + Email:: danielneis at gmail.com + Contribution:: Patch to add Sprite#undraw (based on UpdateGroup#undraw). + Date:: 2007-07-29 (r460). diff --git a/lib/rubygame/sprite.rb b/lib/rubygame/sprite.rb index 24239a22..60946ba9 100644 --- a/lib/rubygame/sprite.rb +++ b/lib/rubygame/sprite.rb @@ -197,6 +197,19 @@ def remove(*groups) } end + + # call-seq: undraw(surface, background) -> Rect + # + # 'Erase' the sprite from +surface+ by drawing over it with part of + # +background+. For best results, +background+ should be the same size + # as +surface+. + # + # Returns a Rect representing the area of +surface+ which was affected. + # + def undraw(dest, background) + background.blit(dest, @rect, @rect) + end + # This method is meant to be overwritten by Sprite-based classes to # define meaningful behavior. It can take any number of arguments you # want, be called however often you want, and do whatever you want. @@ -369,8 +382,7 @@ def draw(dest) # over). def undraw(dest,background) self.each { |sprite| - background.blit(dest,sprite.rect,sprite.rect) - @dirty_rects.push(sprite.rect.dup) + @dirty_rects.push( sprite.undraw(dest, background) ) } end end # module UpdateGroup