I'm currently developing a platformer game with Python arcade and Tiled Map Editor but I have an issue:
this is my tmx, I saved it as a json
file :
As you can see I'm in the "Tutorial" Layer which is an object layer, I am using Tiled Map Editor text tool to put the text but when I run my main.py
I get this:
As you can see, The text objects inside the tutorial layer are not rendered, I can't provide all my code because its 1000+ lines of code but this is my draw
method:
def on_draw(self):
self.clear()
self.camera.use()
self.scene.draw()
self.bullets.draw()
self.gui_camera.use()
score_text = f"Score: {self.player.score}"
arcade.draw_text(score_text, 10, 10, arcade.csscolor.BLACK, 18)
I load my scene object like this:
self.tile_map = arcade.load_tilemap(map_name, TILE_SCALING, layer_options)
self.scene = arcade.Scene.from_tilemap(self.tile_map)
No error is raised, but the text objects just don't render
I saw something: my Tutorial layer is rendered but my text objects are not
I'm Using python 3.12.2
, Tiled 1.10.1
And Arcade 2.6.17
However, My question is why is my text objects are not showing and how to make my text objects show
The issue was that Tiled Map Editor text tool is just for making notes in your map, it's not to add text in your game, this is my solution:
As you can see instead of using tiled map editor text tool i created objects with the attribute text, wich i render later with python arcade i did changes in my draw
method:
def on_draw(self):
self.clear()
self.camera.use()
self.scene.draw()
self.bullets.draw()
for ubject in self.scene["Tutorial"]:
arcade.draw_text(ubject.properties['text'], ubject.position[0], ubject.position[1], arcade.csscolor.BLACK, 18)
self.gui_camera.use()
score_text = f"Score: {self.player.score}"
arcade.draw_text(score_text, 10, 10, arcade.csscolor.BLACK, 18)
And you might be wondering why are the green arrows not showing in my level, well its because i hid The Tutorial
layer, so the green arrows would show.
solution from: Tiled map editor official docs