Hello.
I am fairly new to the world of pyglet but find it very interesting.
Although, I have now come across a problem which I cannot understand why it
does not work.
Some example code:
import pyglet
from random import randint
class GameWindow(pyglet.window.Window):
def __init__(self, *args, **kwargs):
super(GameWindow, self).__init__(*args, **kwargs)
self.batch = pyglet.graphics.Batch()
self.brick_images = ['brick1.png', 'brick2.png']
self.bricks = []
for i in range(len(self.brick_images)):
self.brick_type = randint(0, len(self.brick_images) - 1)
self.image = self.brick_images[self.brick_type]
x = i * 200 + 50
y = i * 100 + 70
self.bricks.append(pyglet.sprite.Sprite(self.image, x=x, y=y,
batch=self.batch))
def on_draw(self):
self.clear()
self.batch.draw()
def update(self, dt):
pass
if __name__ == '__main__':
window = GameWindow(800, 600, 'test', resizable=False)
pyglet.clock.schedule_interval(window.update, 1.0 / 60.0)
pyglet.app.run()
The traceback error is:
Traceback (most recent call last):
File "C:/Users/jyscal/PycharmProjects/simplesim1/testing.py", line 30, in
<module>
window = GameWindow(800, 600, 'test', resizable=False)
File "C:/Users/jyscal/PycharmProjects/simplesim1/testing.py", line 19, in
__init__
self.bricks.append(pyglet.sprite.Sprite(self.image, x=x, y=y,
batch=self.batch))
File "C:\Python27\lib\site-packages\pyglet\sprite.py", line 243, in
__init__
self._texture = img.get_texture()
AttributeError: 'str' object has no attribute 'get_texture'
I copied most of the code from pyglets documentation example using 1.3
Any help would be appreciated and I can provide further info if required.
Thank you!!
--
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 https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.