On 15 July 2011 02:32, Zombie Mariachis <[email protected]> wrote:
> Changing the super to "super(Level_1, self).__init__(img, x=x, y=y, > batch=batch)" cleared up the wrong type issue. Thank you! > > However the sprite's specific def draw(self): instructions aren't > being followed. > > -- > You received this message because you are subscribed to the Google Groups > "pyglet-users" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/pyglet-users?hl=en. > > More likely they are being followed, but not having the expected output. What exactly are you trying to have it do? Because right now, you're blitting an image to the texture at gx, gy. However keep in mind that when you're running __init__, the first thing you do is set x, y = x, y, add the image, then x, y = 0, window_height/2, then gx, gy = x, y. This is because when you're doing the super function, you're calling it with x, y and img. This means that it'll do what it always does. That is, set Sprite._x and Sprite._y to the original x and y, rather than 0 and Window_Height/2. And when you want to move it to 0, Window_Height/2, you should be calling self.set_position(0, Window_Height/2). More importantly, is there really no other way for you to draw this? Because updating the Sprite's texture like this isn't horribly efficient compared to simply drawing the sprite in a different place (I assume the use case will be more complicated than this though). I'm not that good with on-the-fly OpenGL code, so I can only tell you to trial-and-error the numbers in glTranslatef to see if that might be doing it. Try 0, 1, 100, -10, 10, instead of -100. Besides that, right now you're not really, uh, actually updating a texture, come to think of it. The code in sprite.py is convoluted, but I think the fact that you overwrote its draw(self) routine, then actually blitted an image, rather than letting it draw and texture itself, means that you're doing a transform in the texture matrix, but that isn't actually doing anything to any texture, because there are none. This means you should be calling: super(Level_1, self).draw() either after all your code, instead of (or coupled with) the blitting line, or before it. However it MUST be there in order for you to actually draw the sprite/texture. My suggestion, however, would be to either use Sprites as intended, or simply do the OpenGL bits yourself completely, subclass Window and do this in its on_draw() function. It'll work this way (a bit fiddly), but it's not the most clear code, and any slight change in how Sprites draw might affect this. -- You received this message because you are subscribed to the Google Groups "pyglet-users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en.
