B4A Library libGDX - Game Engine

Discussion in 'Additional libraries, classes and official updates' started by Informatix, Sep 12, 2013.

  1. Informatix

    Informatix Expert Licensed User

    Thank you. You're my first buyer. Champaign ! :)
     
  2. LucaMs

    LucaMs Expert Licensed User

    I state that I never developed games but sometimes I took a look at these tools.

    Although I am inexperienced, this seems like a great job.

    I have a couple of questions optional, regarding your app "My Playground (Free)" (I hope that Erel not ask me to move them); it is really very pretty.

    When you published the app? I can read but not update the date of the publication date.

    The graphics: have you drawn everything? Use tools such as graphics tablets?

    Although I will not get answers, congratulations for your great job!
     
  3. Informatix

    Informatix Expert Licensed User

    There's a thread here for My Playground.
     
  4. sterlingy

    sterlingy Active Member Licensed User

    In playing with the Pacdroid code, I tried to replace the maze map with a map of my own, but since you have properties embedded in the map and tileset, things aren't working out so well. However, just to see what would happen, I loaded your map assets into Tiled, doubled the height of the map, and filed in the blank area with tiles. This resulted in the map being scaled down so that it could fit the entire map in the viewport.

    In other tests, I have been able to scale the tiled map, but I wasn't using Scn2D and Stage. If possible, how can I fill the width of the viewport with the width of the map, so I can move the viewport over the map to reveal different parts of the map?

    [​IMG]

    I wasn't sure where this post should go. In this thread or the Pacdroid Tutorial thread. Seems like it could go in either.
     
  5. Informatix

    Informatix Expert Licensed User

    I got so sick that I'm just barely able to write this. Sorry but you'll have to do without me for a few days.
     
  6. sterlingy

    sterlingy Active Member Licensed User

    Okay, feel better.
     
    Erel likes this.
  7. LucaMs

    LucaMs Expert Licensed User

    get well soon ... not for you, we need you :p
     
  8. sterlingy

    sterlingy Active Member Licensed User

    Informatix,

    I did ask on the libGDX forum, but no one had a clue, though one guy had experienced the same issue.

    I did resolve my problem, however. My TileSet had each tile paced by one pixel. The gaps between the tiles were filled with black. With the Tiled Editor compensating for this, everything looked fine in the editor. I made a new TileSet, without gaps, and the problem has gone away. The "rounding" issue may still be present, but no one would be the wiser.

    -Sterlingy
     
  9. sterlingy

    sterlingy Active Member Licensed User

    I'm making progress with this lib, but my code seems to want to crash periodically. Sometimes, it's when I exit. Sometimes when I try to run it after the install. In this case, it will almost always run fine when I launch it from my device's panel.

    I get an IndexOutOfBoundsException error

    Code:
    Sub Main_Draw(SpriteBatch As lgSpriteBatch, ParentAlpha As Float)
        
    'Draws the maze
        SpriteBatch.DisableBlending
        SpriteBatch.SetColorRGBA(
    1111)
        myMap.Draw(Stage.Camera)
        SpriteBatch.EnableBlending
    End Sub
    The error occurs on the EnableBlending line.

    What could cause this, as it doesn't happen all of the time?

    I should point out that I compile and run in debug mode, and I think I read somewhere that the debugger has issues with libGDX.

    Cheers,

    Sterling
     
  10. Informatix

    Informatix Expert Licensed User

    Don't look further. The IndexOutOfBounds is typical of an issue with the debugger. You have to use only the Release mode.
     
  11. Informatix

    Informatix Expert Licensed User

    Good news and good to know.
     
    sterlingy likes this.
  12. sterlingy

    sterlingy Active Member Licensed User

    I hope you've recovered. I've been battling something all day with two stages, and actors/sprites not rendering on the back stage.

    I have two stages. One has a tiled map and a bunch of 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. No one on the libGDX board has a clue

    The HUD is just some text in a table, so it is largely transparent as you will see below (guess whose tutorial I used as a base? ;))

    This code:
    Code:
    Sub Main_Draw(SpriteBatch As lgSpriteBatch, ParentAlpha As Float)
        
    'Draws the maze
        SpriteBatch.DisableBlending
        SpriteBatch.SetColorRGBA(
    1111)
        Maze.Draw(Stage.Camera)
        SpriteBatch.EnableBlending
        HUDStage.Draw
    End Sub
    Produced this image, when you can see the Map on the background stage. You can also see the Score and three remaining lives in the HUDStage
    [​IMG]


    This code, where I do not draw the HUD stage, reveals the sprites, which are in a group and actors of the Maze Stage, along with the Map
    Code:
    Sub Main_Draw(SpriteBatch As lgSpriteBatch, ParentAlpha As Float)
        
    'Draws the maze
        SpriteBatch.DisableBlending
        SpriteBatch.SetColorRGBA(
    1111)
        Maze.Draw(Stage.Camera)
        SpriteBatch.EnableBlending

    End Sub
    [​IMG]


    This code , where blending is on for everything, results in the HUD and nothing else

    Code:
    Sub Main_Draw(SpriteBatch As lgSpriteBatch, ParentAlpha As Float)
        
    'Draws the maze
        SpriteBatch.EnableBlending
        SpriteBatch.SetColorRGBA(
    1111)
        Maze.Draw(Stage.Camera)
        HUDStage.Draw
    End Sub
    [​IMG]
     
  13. Informatix

    Informatix Expert Licensed User

    I'm not sure to understand your question. If you want to move the camera over the map to reveal different parts, then the map has to be larger than the viewport. Example with PacDroid: in Tiled, I resize the map width to 56 tiles (twice the former value) and I put new tiles in the empty space. In the clsMaze class, I divide MapWidth by 2. So now my app displays only the half of my map. If I translate the camera to the right, I can reveal the invisible part.
     
  14. Informatix

    Informatix Expert Licensed User

    There's something that annoys me in your code. Each stage has its own Spritebatch, but in your code, you use the same for the maze and the HUD. If you want to share the same batcher, use Stage.Initialize3 to set yourself the SpriteBatch.
     
  15. sterlingy

    sterlingy Active Member Licensed User

    The tiledMap scrolls just fine, as I change the position of the camera:
    Code:
    Public Sub Draw(Camera As lgOrthographicCamera)
    Camera.Position.y = Camera.Position.y + ScrollSpeed
        MapRenderer.SetCameraView(
    Camera)
        MapRenderer.renderTileLayer(CurrentLayer)
    End Sub
    The tiledMap is in a group with the actors/sprites, and are on the bottom stage. the HUD is on the top stage. This has the score and the remaining lives. In the top picture, seen two posts up, you will see the content of the HUD stage, on top of the map, on the bottom stage, but the actors and sprites don't render.

    If I don't draw the HUD stage, then it renders all of the children of the bottom stage, not just the tiled map.

    Does that make more sense?

    -SterlingY
     
  16. sterlingy

    sterlingy Active Member Licensed User

    So you suggest that I create a different SpriteBatch for each Stage, as the best solution?

    I looked at stage.initialize3. I'm not sure what EvtPrefix is? If my SpriteBatch is called "GloriousBatchSprite", and the EvtPrefix is "notSo",
    then to render this stage would be notSoGloriousSpriteBatch.Draw?

    -SterlingY
     
  17. Informatix

    Informatix Expert Licensed User

    No, the contrary: use the same Spritebatch, but you have to share it explicitely because a call to Initialize will create a new one.
    The current situation is that you created two SpriteBatchs but you try to use the same in your Draw event.
    What I suggest is to create only one with Initialize and to pass the created SpriteBatch to the other stage with Initialize3.

    The event is Draw, so if the event prefix is "toto", the event handler should be named "toto_Draw".
    In PacDroid, Main_Draw is the draw event of grpMain (declared with grpMain.Initialize("Main")).
     
    sterlingy likes this.
  18. sterlingy

    sterlingy Active Member Licensed User

    So here's what I did

    Code:
    'Initializes the stage
        Stage.Initialize("")
        HUDStage.Initialize3(lGdx.Graphics.Width, lGdx.Graphics.Height, 
    True, Stage.SpriteBatch, "HUD")
    .
    .
    .
    Sub Main_Draw(SpriteBatch As lgSpriteBatch, ParentAlpha As Float)
        
    'Draws the maze
        SpriteBatch.DisableBlending
        SpriteBatch.SetColorRGBA(
    1111)
        Maze.Draw(Stage.Camera)
        SpriteBatch.EnableBlending
    '    HUDStage.Draw
    End Sub

    Sub HUD_Draw(SpriteBatch As lgSpriteBatch, ParentAlpha As Float)
        
    'Draws the HUD
        SpriteBatch.EnableBlending
        SpriteBatch.SetColorRGBA(
    1111)
        HUDStage.Draw
    End Sub
    All I get is the background stage with the map.

    Sorry I'm such a pain. Just a few more hurdles, and I can focus on the visually creative stuff, which I know well.
     
  19. Informatix

    Informatix Expert Licensed User

    Do you call Draw for your HUD in the Render event?

    And if you share the same SpriteBatch, what's the reason for two separate draw events?
     
  20. sterlingy

    sterlingy Active Member Licensed User

    I did not Draw the HUD in the Render Event. I was under the assumption I had to do it the same way I do it for Stage. Adding HUDStage.Draw to the Render event, and removing the HUD_Draw sub, gives me a blank screen.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice