简体   繁体   中英

Multiple stages in libGDX hides actors on back stage

Using libGDX, I have two stages. One has a tiled map and a bunch of actors/sprites moving around. On top of that, I have a HUD stage, which has the score and other things.

I can see the tiled map, but the sprites aren't visible. If I don't draw the HUD stage, then I can see the sprites

The HUD is just some text in a table, so it is largely transparent.

This code:

Sub Main_Draw(SpriteBatch As lgSpriteBatch, ParentAlpha As Float)
    Draws the maze
    SpriteBatch.DisableBlending
    SpriteBatch.SetColorRGBA(1, 1, 1, 1)
    Maze.Draw(Stage.Camera)
    SpriteBatch.EnableBlending
    HUDStage.Draw
End Sub

I went so far as to remove any reference to the HUD stage, except the initialization of the stage itself, with the same result.

This is probably because libgdx recently had an API change. Now,

void draw(Batch batch, float parentAlpha)

is called by stage's root group instead of

void draw(SpriteBatch batch, float parentAlpha)

Since your method does not override parent's method, it is not being called.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM