问题
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