[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] display.update



Hi Luke.

The rule of thumb is to do all the calls in this order: clear, update,
draw.  Here's a snippet of some of my code.

-----------------------------------
self.charGroup.clear( screen )
self.enemyGroup.clear( screen )
self.effectGroup.clear( screen )

#KEEP IN MIND when thinking about the updates that some
#sprites can change which group they're in due to a call to
#group.update().  Thus, they can have their update() method
#called twice

self.charGroup.update( timeChange=timeChange )
self.enemyGroup.update( timeChange=timeChange )
self.effectGroup.update( )

changedRects =  self.charGroup.draw(screen)
changedRects += self.enemyGroup.draw(screen)
changedRects += self.effectGroup.draw(screen)
display.update( changedRects )
-----------------------------------

This is all I can suggest now, unless you want to paste in your actual
code.

-sjbrown

On Thu, 8 Sep 2005, Luke Miller wrote:

> Hello everyone,
>
> Strange problem that is probably something to do with RenderUpdates or
> something.
>
> My game has game sprites and then, overlayed on the screen, some menu
> sprites (buttons, etc). Except I find that when I add a large game
> sprite, the menu sprites are underneath the game sprite.
>
> This is the code (simplified):
>
> RectsToUpdate = []
> gameSprites.update()
> RectsToUpdate.extend(gameSprites.draw(.screen))
>
> menuSprites.update()
> RectsToUpdate.extend(menuSprites.draw(.screen))
>
> pygame.display.update(RectsToUpdate)
> clock.tick(framerate)
> gameSprites.clear(screen, background)
> menuSprites.clear(screen, background)
>
>
> As far as I can tell, since menuSprites.update() occurs after the
> gameSprite.update(), the menu sprites should be "on top". Any
> suggestions?
>
> Thanks,
> Luke
>