lordmauve / wasabi2d

Cutting-edge 2D game framework for Python
https://wasabi2d.readthedocs.io/
GNU Lesser General Public License v3.0
154 stars 24 forks source link

Text primitive broken? #65

Closed stemvork closed 3 years ago

stemvork commented 3 years ago

The following code

import wasabi2d as w

s = w.Scene()
s.background = 0.5, 0.5, 0.5
b = s.layers[0]
b.add_label("test")

w.run()

does not draw text and yields the following warning:

/Users/jaspereenhoorn/Documents/gamedev/lib/python3.8/site-packages/wasabi2d/primitives/text.py:188:
VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences
(which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths
or shapes) is deprecated. If you meant to do this, you must specify
'dtype=object' when creating the ndarray
verts[glyph_slice] = glyph_verts + (x - align_offset, yoff - descent, 0)

Seeking help as to what is going on and how to fix it.

Kind regards, stemvork

Grimmys commented 3 years ago

Hello,

I don't think this warning is really important (I have it too in my perfectly functional project).

However, you should precise the position of your label, like that :

import wasabi2d as w

s = w.Scene()
s.background = 0.5, 0.5, 0.5
your_label = s.layers[0].add_label("test", pos=(s.width // 2, s.height // 2))

w.run()

Dunno what is the default position, probably off screen.

stemvork commented 3 years ago

Thank you for clarifying my error. I didn't realise the absence of position in my test.

It works in my project, next step is figuring out a decent way to position the text centered in a box.