areas; toggle
This commit is contained in:
parent
fbc93f3aa6
commit
9c96820d88
|
@ -196,13 +196,14 @@ class Sprite(Animation):
|
|||
for frameset in self.framesets:
|
||||
frameset.reverse()
|
||||
|
||||
def update(self):
|
||||
def update(self, areas=None):
|
||||
Animation.update(self)
|
||||
self.draw()
|
||||
if self.get_current_frameset().length():
|
||||
self.draw(areas)
|
||||
|
||||
def draw(self):
|
||||
def draw(self, areas=None):
|
||||
for location in self.locations:
|
||||
location.fader.draw()
|
||||
location.fader.draw(areas)
|
||||
|
||||
|
||||
class Location(Rect):
|
||||
|
@ -238,6 +239,9 @@ class Location(Rect):
|
|||
def unhide(self):
|
||||
self.hidden = False
|
||||
|
||||
def toggle_hide_state(self):
|
||||
self.hidden = not self.hidden
|
||||
|
||||
def is_hidden(self):
|
||||
return self.hidden
|
||||
|
||||
|
@ -280,7 +284,7 @@ class Fader(Surface):
|
|||
self.start_time = self.time_filter.get_ticks()
|
||||
self.fading_out = out
|
||||
|
||||
def draw(self):
|
||||
def draw(self, areas=None):
|
||||
sprite = self.location.sprite
|
||||
if self.fade_remaining >= 0:
|
||||
self.update_alpha()
|
||||
|
@ -289,16 +293,24 @@ class Fader(Surface):
|
|||
frame.set_alpha(255)
|
||||
self.blit(frame, (0, 0))
|
||||
frame.set_alpha(sprite.alpha)
|
||||
if not self.location.hidden:
|
||||
self.blit_to_display(self)
|
||||
if not self.location.is_hidden():
|
||||
self.blit_to_display(self, areas)
|
||||
elif self.fade_remaining is None or self.get_alpha() >= sprite.alpha:
|
||||
if self.fade_remaining >= 0:
|
||||
self.update_alpha()
|
||||
if not self.location.hidden:
|
||||
self.blit_to_display(sprite.get_current_frame())
|
||||
if not self.location.is_hidden():
|
||||
self.blit_to_display(sprite.get_current_frame(), areas)
|
||||
|
||||
def blit_to_display(self, frame):
|
||||
self.location.sprite.display_surface.blit(frame, self.location)
|
||||
def blit_to_display(self, frame, areas=None):
|
||||
if not isinstance(areas, list):
|
||||
areas = [areas]
|
||||
for area in areas:
|
||||
if area:
|
||||
dest = area.left + self.location.left, \
|
||||
area.top + self.location.top
|
||||
else:
|
||||
dest = self.location
|
||||
self.location.sprite.display_surface.blit(frame, dest, area)
|
||||
|
||||
def update_alpha(self):
|
||||
remaining = self.fade_remaining = self.fade_length - \
|
||||
|
|
Loading…
Reference in New Issue