On 24/10/13 17:29, John Ladasky wrote: > Thank you Juan, you came through for me again! > > I am reading the rest > of http://pyglet-current.usebox.net/programming_guide/image.html. I can > see that wrapping a resource.image in a sprite.Sprite is a way to handle > the alpha channel issue automatically. So, is there ever a reason NOT > to wrap a 2D image into a Sprite? I understand that this step might > have been left out of the tutorial code for simplicity's sake, but I am > wondering whether there might be performance issues as well. >
You need to set alpha blending in OpenGL anyway, the Sprite class is just an image displayed on a window (and optimized to do so). Using the Sprite class and a Batch is a very efficient way of handling several images on the screen. Basically: (setup OpenGL first!) - create a batch - create the sprites passing the batch as argument (so they are added to the batch) - update sprite properties (x, y, subclass if you need more stuff) - draw the batch In that way all the sprites are drawn efficiently using the batch (just one draw call). I have a repo in GitHub with a pyglet template using OOP. My Window subclass is pretty similar to your code so you may want to take a look and get ideas: https://github.com/reidrac/pyglet-template/blob/master/game/__init__.py I'm just drawing a Label as example and there's room for improvement, but it may be useful :) Regards, Juan -- jjm's home: http://www.usebox.net/jjm/ blackshell: http://blackshell.usebox.net/ -- You received this message because you are subscribed to the Google Groups "pyglet-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/pyglet-users. For more options, visit https://groups.google.com/groups/opt_out.
