小矮人,雪碧批量投放时如何设置z轴值

wdebmtf2  于 2022-10-18  发布在  其他
关注(0)|答案(1)|浏览(119)

环境:

巨蟒:3.6.6
侏儒版本:1.3.2

代码示例:

将元素添加到pyglet.graphics.Batch()中,我知道如何设置z


# 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)))

但我在使用过程中找不到设置z轴值的方法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
)

雪碧绘制在z=0上。我需要搬到z=-1

我想做的是

我尝试将z直接设置为图像纹理

texture = image.texture
texture.z = -1

但无论如何,雪碧石又被画在了z=0便士上。

问题

有没有可能“说”pyglet.sprite.Sprite()在z轴上应该画在哪里?
我将非常感谢任何建议/链接/等,因为我在文档上找不到这一方面,也找不到有相同情况的例子。

bqf10yzr

bqf10yzr1#

也许您可以使用不同的批次:

batch_down.draw() # background
batch.draw()

但是我们不能在批次之间移动精灵。

相关问题