更改一批 sprite pyglet

change batch of sprite pyglet

如何在pyglet中更改精灵的批处理对象?

def createSprite(obj, batch, layer):
    img = pyglet.resource.image(obj.path)
    img.width = obj.w
    img.height = obj.h
    return pyglet.sprite.Sprite(img, x=obj.x, y=obj.y, batch=batch, group=layer)

非常模棱两可的问题...但是,主题不错。

在 pyglet 中,sprite 对象有一个名为 batch 的 属性,可以在弹出时更改。很简单,假设x是Sprite的对象class,那么:

x.batch = pyglet.graphics.Batch()