0

I am trying to use the UIScrollingContainer element in a project to overscan what i am drawing to a larger surface, then creaing a UIImage with that surface and making it be contained by the UIScrollingContainer. This works for a few seconds but then boggs down and freezes and then eventually the whole game just quits and the terminal says Killed.

so my code after the imports and setting screen with width and height:

grid_surface = pygame.Surface((2000,2000))

manager = pygame_gui.UIManager((width, height))

scroll_space = pygame_gui.elements.UIScrollingContainer(relative_rect = pygame.Rect((0,0),(width,height)), manager=manager)

scroll_space.set_scrollable_area_dimensions((2000,2000))

then you draw and blit stuff to grid_surface. then the while loop contains:

grid_image = pygame_gui.elements.UIImage(relative_rect=pygame.Rect((0,0),(2000,2000)), image_surface=grid_surface, manager=manager, container=scroll_space)

manager.draw_ui(screen)

pygame.display.update()

as i said this works up to the point of trying to use the scrollbars and anyway even after a few slow draws it crashes

I don't see any events for scrollbars. How are you supposed to know the offset currently created by the scrollbars. this breaks mouse pointer interaction.

update: I moved the declaration of grid_image outside of the while loop and then in the while loop i used grid_image.set_image(grid_surface)

this sped things up a bit and scrolling now kinda works but it is still significantly slower than before.

bobombolo
  • 1
  • 1

0 Answers0