Named shapes in pyglet

前端 未结 1 1441
一整个雨季
一整个雨季 2021-01-23 08:49

Why do shapes and other objects in pyglet have to be named (as in assigned variables) ? The Rectangle below named "test" renders successfully, the one a line below doe

相关标签:
1条回答
  • 2021-01-23 09:26

    Here you are using pyglet.graphics.Batch() to render the shape objects together i.e. test(the first rectangle) + the second rectangle. A batch manages a set of objects that will be drawn at once, and hence to instantiate the objects that need to be drawn, they need to have a reference against which they can be mapped to that batch.

    To draw a rectangle as is, without assigning it to a varible can be done by using the pyglet.graphics.draw() function directly by passing in the primitive type, rectanggle coordinates and formatstring.

    0 讨论(0)
提交回复
热议问题