Pyglet. How to set “z” axis value for Sprite when put it into Batch

喜欢而已 提交于 2019-12-24 11:42:14

问题


Environment:

Python: 3.6.6
pyglet version: 1.3.2

Code example:

Adding element into pyglet.graphics.Batch() where I understand how to set z axis

# e.g. z = -2
texture_group = pyglet.graphics.TextureGroup(
    pyglet.image.load(os.path.join(GROUND_DIR, "t1.png")).texture
)

self.vertices = self.batch.add(
    4, pyglet.gl.GL_QUADS,
    texture_group,
    ('v3f', (x, y, z,
             x_, y, z,
             x_, y_, z,
             x, y_, z)),
    ('t2f', (0, 0, 1, 0, 1, 1, 0, 1)))

But I can't find way to set z axis value during usage pyglet.sprite.Sprite()

image = pyglet.image.load(os.path.join(MOVEMENT_DIR, "t1_1.png"))
image2 = pyglet.image.load(os.path.join(MOVEMENT_DIR, "t1_2.png"))
self.sprite = pyglet.sprite.Sprite(
    img=pyglet.image.Animation(
        frames=[
            pyglet.image.AnimationFrame(image, 1),
            pyglet.image.AnimationFrame(image2, 1)
        ]
    ),
    x=x,
    y=y,
    batch=self.batch
)

Sprite is drawn on z=0. e.g. I need to move in on z=-1

What i was trying to do

I tried to set z directly to image texture

texture = image.texture
texture.z = -1

But anyway sprite was drawn on z=0 again.

Question

Is it possible to "say" pyglet.sprite.Sprite() where on z axis it should be drawn?

I would be very appreciated for any advice/link/etc, because I can't find this aspect on documentation and can't find examples with same situation.

来源:https://stackoverflow.com/questions/52804096/pyglet-how-to-set-z-axis-value-for-sprite-when-put-it-into-batch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!