toggle hidden; substitute frame

This commit is contained in:
Frank DeMarco 2015-01-13 23:22:02 -05:00
parent 9c96820d88
commit f021118be8
1 changed files with 15 additions and 8 deletions

View File

@ -180,6 +180,10 @@ class Sprite(Animation):
for location in self.locations:
location.unhide()
def toggle_hidden(self):
for location in self.locations:
location.toggle_hidden()
def is_hidden(self):
return all(location.is_hidden() for location in self.locations)
@ -196,14 +200,14 @@ class Sprite(Animation):
for frameset in self.framesets:
frameset.reverse()
def update(self, areas=None):
def update(self, areas=None, substitute=None):
Animation.update(self)
if self.get_current_frameset().length():
self.draw(areas)
self.draw(areas, substitute)
def draw(self, areas=None):
def draw(self, areas=None, substitute=None):
for location in self.locations:
location.fader.draw(areas)
location.fader.draw(areas, substitute)
class Location(Rect):
@ -239,7 +243,7 @@ class Location(Rect):
def unhide(self):
self.hidden = False
def toggle_hide_state(self):
def toggle_hidden(self):
self.hidden = not self.hidden
def is_hidden(self):
@ -284,12 +288,15 @@ class Fader(Surface):
self.start_time = self.time_filter.get_ticks()
self.fading_out = out
def draw(self, areas=None):
def draw(self, areas=None, substitute=None):
sprite = self.location.sprite
if substitute is None:
frame = sprite.get_current_frame()
else:
frame = substitute
if self.fade_remaining >= 0:
self.update_alpha()
self.clear()
frame = sprite.get_current_frame()
frame.set_alpha(255)
self.blit(frame, (0, 0))
frame.set_alpha(sprite.alpha)
@ -299,7 +306,7 @@ class Fader(Surface):
if self.fade_remaining >= 0:
self.update_alpha()
if not self.location.is_hidden():
self.blit_to_display(sprite.get_current_frame(), areas)
self.blit_to_display(frame, areas)
def blit_to_display(self, frame, areas=None):
if not isinstance(areas, list):