Animation 2

This commit is contained in:
9and3r
2015-07-14 12:53:31 +02:00
parent 194d6fa071
commit e388907cd0
6 changed files with 28 additions and 25 deletions

View File

@@ -17,7 +17,7 @@ class DynamicBackground:
self.update = True
self.screen_change_percent = 100
def draw_background(self):
def draw_background(self, rects=None):
if self.image_loaded:
if self.screen_change_percent < 255:
self.surface.fill((0, 0, 0))
@@ -26,7 +26,7 @@ class DynamicBackground:
self.surface_image.set_alpha(self.screen_change_percent)
self.surface.blit(self.surface_image_last, (0, 0))
self.surface.blit(self.surface_image, (0, 0))
self.screen_change_percent += 5
self.screen_change_percent += 50
self.update = True
return self.surface.copy()

View File

@@ -21,15 +21,15 @@ class ScreenObjectsManager:
def set_object(self, key, add_object):
self.text_objects[key] = add_object
def get_update_rects(self):
def get_update_rects(self, all):
update_rects = []
for key in self.text_objects:
object = self.text_objects[key]
if hasattr(object, "fit_horizontal") and not object.fit_horizontal:
if all or (hasattr(object, "fit_horizontal") and not object.fit_horizontal):
update_rects.append(object.rect_in_pos)
for key in self.touch_objects:
object = self.touch_objects[key]
if hasattr(object, "fit_horizontal") and not object.fit_horizontal:
if all or (hasattr(object, "fit_horizontal") and not object.fit_horizontal):
update_rects.append(object.rect_in_pos)
return update_rects

View File

@@ -31,13 +31,21 @@ class ViewPager:
self.update = True
def should_update(self):
if self.update:
return BaseScreen.update_all
if self.update or len(self.update_rects) > 0:
return BaseScreen.update_partial
else:
if len(self.update_rects)>0:
return BaseScreen.update_partial
else:
return BaseScreen.no_update
return BaseScreen.no_update
def set_update_rects(self, rects):
if self.update or self.direction != 0:
rects += self.objets_manager[0].get_update_rects(True)
rects += self.objets_manager[1].get_update_rects(True)
rects += self.objets_manager[2].get_update_rects(True)
self.shift()
rects += self.objets_manager[0].get_update_rects(True)
rects += self.objets_manager[1].get_update_rects(True)
rects += self.objets_manager[2].get_update_rects(True)
rects += self.update_rects
def shift(self):
if self.direction == 1:
@@ -77,8 +85,6 @@ class ViewPager:
self.objets_manager[0].render(screen)
else:
self.update = False
self.update_rects = self.objets_manager[1].get_update_rects()
#if update_type == BaseScreen.update_partial:
#rects += self.update_rects
self.update_rects = self.objets_manager[1].get_update_rects(False)
self.objets_manager[1].render(screen)