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

    The error that I get with this code is "pad.pack missing" because this file (and others) are missing. The error with the particle effect is in juego.bas.
     
  2. fanfalveto

    fanfalveto Active Member Licensed User

    Ok,this two files are into Files folder.
    And yes the problem is in juego when return only from puzzle2
     

    Attached Files:

  3. fanfalveto

    fanfalveto Active Member Licensed User

    the problem is into "juego","Sub LG_Render","Effect.Draw2(Batch, lGdx.Graphics.DeltaTime)".With "Batch",i quit the effect and this "batch" but crash anyway later in other "Batch".
     
  4. walterf25

    walterf25 Well-Known Member Licensed User

    This is how i render my particles in my wallpapers

    Code:
    particletexture.Initialize("particle-star.png")
    particlesprite.InitializeWithTexture(particletexture)
      particleflip.Initialize
        particleflip.Load(LW.Files.internal(
    "data/butterfly_tail.p"))
        particleflip.sprite = particlesprite
        particleflip.SetPosition(width1/
    2, height1/2)
        particleflip.Start
    then on the Sub LG_Render sub i do this

    Code:
    particleflip.Draw(batch)
    don't forget to update the particle in the render sub like this

    Code:
    particleflip.Update(LW.Graphics.DeltaTime/1.6)
    Hope this helps.
    Cheers,
    Walter
     
  5. fanfalveto

    fanfalveto Active Member Licensed User

    I've solved it by making a small trap, ending the activity and opening it again. I do not like, but it is what it is.
    Thank very much you to all.
     
  6. Informatix

    Informatix Expert Licensed User

    In Juego.bas, why "Batch.Dispose" is commented out? And where's the call to Dispose() for all the particle effects (bomb, bomb2, effect) and music (soni)? Since the "soni" objects are in fact sounds and not music, you should use lgSound, not lgMusic.

    I don't understand the usefulness of the Timer in your code. Use the render event instead.
     
  7. fanfalveto

    fanfalveto Active Member Licensed User

    ok,thank you.i will revise all.
     
  8. tboy

    tboy Member Licensed User

    Informatix,

    Thank you for your amazing work, this is a great addition to B4A.

    :)
     
  9. strat

    strat Active Member Licensed User

    Informatix,
    Great job, thank you for this lib, it increases the power of B4a.

    What is the best way to scroll background by using LibGdx ? I checked the all examples but there is no such code about scrolling background.
     
  10. Informatix

    Informatix Expert Licensed User

    There's no background in libGDX as you may have in the B4A views. A background image is an image as any other image and to scroll it, you have to move it. For an endless scrolling, there are many possibilities. One of them is to use a repeated texture. Here's an example. I just added the xBkgd variable to the Perf_Skaters example and modified the drawing of the texture.
     

    Attached Files:

    Last edited: Dec 1, 2013
  11. strat

    strat Active Member Licensed User


    Thank you informatix it's a good example. After first run, I quickly made some changes.
    I've tried to change background.jpg first. 256X256 .jpg worked but scroll speed was not perfect. Speed was unstable, faster than the original. I've changed original background.jpg as transparent .png, but this time program didn't worked. It looks like there are some restrictions about image resolutions and formats.
     
  12. Informatix

    Informatix Expert Licensed User

    You probably removed the line "Config.useGL20 = True" or skipped it or your hardware does not support OpenGL 2 and in this case you have to set texBackground.EnforcePowerOfTwoImages to False.
    You should really try to understand what I did because a picture with a different size will need different settings. For example, the width to draw will be texBackground.Width and not lGdx.Graphics.Width if the image is wider than the screen. And if your computation for NbOfRepetitionsX returns 0, then it cannot work.
     
  13. strat

    strat Active Member Licensed User

    I added texBackground.EnforcePowerOfTwoImages= False in my code. Now it works good. Only one restriction remained. An error like "Resolution must be power of 2" appear if background dimensions different than power of 2. I used a 1024x512 picture and it worked perfetcly. Thanks again.
     
  14. sterlingy

    sterlingy Active Member Licensed User

    Informatix,

    This lib is amazing. I'm just getting my feet wet, but in just a few hours, I made some headway.

    I took your Map_tIDE Example and played around with it, but I am getting some strange artifacts when it renders. My tiles are the same size as the tiles in your demo, but I'm getting strange lines between some of the tiles, and they aren't fixed, as I pan around, the lines come and go.

    I have a feeling the problem is in this bit of code:

    Code:
    'Initializes the renderer
        Renderer.Initialize3(TiledMap, 1/32)
    End Sub

    Sub LG_Resize(Width As Int, Height As Int)
        
    'Sets the camera viewport
        Camera.Initialize
        
    Camera.SetToOrtho2(False, (Width / Height) * 3232)
    I've put the full source here: https://drive.google.com/file/d/0B-zGIsrNkJF1cUZrTUpKY0FGSFE/edit?usp=sharing (figured I'd make a simple game to explore everything libGDX has to offer) I was shocked I could do what I did in just a few hours. It's far from finished.

    BTW, if you compile and run the code, you'll see a gray bar on the right side of the map, because the map isn't filling the entire screen. The only way I can see to do that is change the numbers in this line.

    Code:
    Camera.SetToOrtho2(False, (Width / Height) * 3232)
    Again, you knocked the ball out of the park with this lib.

    Congrats,

    SterlingY
     
  15. Informatix

    Informatix Expert Licensed User

    Yes, I had the same visual glitches sometimes while playing with the maps. I think it's due to roundings and I have no workaround for now (I didn't really investigate). Maybe it's worth to search through the libGDX forum. We're probably not the first to notice that.

    Two comments: libGDX has a media player (lgMusic) so the MediaPlayer lib is not necessary. And you should use the same unit scale for everything (currently you have a different unit scale for the tiles and for the car) because it's easier to position and size the objects when they share the same unit scale.
     
  16. sterlingy

    sterlingy Active Member Licensed User

    Informatix, Thanks for your response. I see where I've set the unit scale for the map, but I don't see where it's set for the car. Any thoughts on why there is a grey bar on the right side of the screen?
     
  17. Informatix

    Informatix Expert Licensed User

    When I tried your demo, I saw no grey bar.
    For the unit scale, read the chapter about the camera. It's explained there.
     
    Last edited: Dec 7, 2013
  18. ananaiasa

    ananaiasa New Member Licensed User

    Hi Informatix,
    I've compiled the livewallpaper example via bridge to my nexus4.
    It installs but when I add the wallpaper it force closes it also does the same thing with my GS3.
    In the log:
    LogCat connected to: B4A-Bridge: LGE Nexus 4
    --------- beginning of /dev/log/main
    Ignoring event: lg_render. Raised from the wrong thread.
    Ignoring event: lg_render. Raised from the wrong thread.
    Ignoring event: lg_render. Raised from the wrong thread.
    Ignoring event: lg_render. Raised from the wrong thread.
    Ignoring event: lg_render. Raised from the wrong thread.
    ** Service (wallpaperservice) Destroy **
    Ignoring event: lg_render. Raised from the wrong thread.
    Ignoring event: lg_render. Raised from the wrong thread.
    Streams_terminated
    Connected to B4A-Bridge (Wifi)
    sending message to waiting queue (CallSubDelayed - UpdateStatus)
    sending message to waiting queue (CallSubDelayed - UpdateStatus)
    (Intent) Intent { act=android.intent.action.MAIN flg=0x20000000 cmp=flm.b4a.lgdxlivewallpaper/.main }
    no extras
    ** Activity (main) Create, isFirst = true **
    ** Activity (main) Resume **
    Streams_terminated
    Connected to B4A-Bridge (Wifi)
    sending message to waiting queue (CallSubDelayed - UpdateStatus)
    sending message to waiting queue (CallSubDelayed - UpdateStatus)
    Streams_terminated
    Connected to B4A-Bridge (Wifi)
    sending message to waiting queue (CallSubDelayed - UpdateStatus)
    sending message to waiting queue (CallSubDelayed - UpdateStatus)
    Streams_terminated
    Connected to B4A-Bridge (Wifi)
    sending message to waiting queue (CallSubDelayed - UpdateStatus)
    sending message to waiting queue (CallSubDelayed - UpdateStatus)
    (Intent) Intent { act=android.intent.action.MAIN flg=0x20000000 cmp=flm.b4a.lgdxlivewallpaper/.main }
    no extras
    ** Activity (main) Create, isFirst = true **
    ** Activity (main) Resume **
    ** Activity (main) Pause, UserClosed = true **
    ** Activity (main) Create, isFirst = false **
    running waiting messages (17)
    ** Activity (main) Resume **
    ** Service (service1) Destroy **
    Ignoring event as service was destroyed.
    ** Activity (main) Pause, UserClosed = false **
    ** Activity (main) Create, isFirst = true **
    ** Activity (main) Resume **
    ** Service (service1) Create **
    ** Service (service1) Start **
    Connected to B4A-Bridge (Wifi)
    ** Activity (main) Pause, UserClosed = true **
    Streams_terminated
    Connected to B4A-Bridge (Wifi)
    sending message to waiting queue (CallSubDelayed - UpdateStatus)
    sending message to waiting queue (CallSubDelayed - UpdateStatus)
    Installing file.
    PackageAdded: package:flm.b4a.lgdxlivewallpaper
    libcore.io.ErrnoException: sendto failed: EPIPE (Broken pipe)
    libcore.io.ErrnoException: sendto failed: EPIPE (Broken pipe)
    sending message to waiting queue (CallSubDelayed - UpdateStatus)
    sending message to waiting queue (CallSubDelayed - UpdateStatus)
    ** Activity (main) Create, isFirst = false **
    running waiting messages (4)
    ** Activity (main) Resume **
    ** Service (service1) Destroy **
    ** Service (service1) Create **
    ** Service (service1) Start **
    Connected to B4A-Bridge (Wifi)
    ** Activity (main) Pause, UserClosed = false **
    Installing file.
    PackageAdded: package:flm.b4a.lgdxlivewallpaper
    Streams_terminated
    Connected to B4A-Bridge (Wifi)
    sending message to waiting queue (CallSubDelayed - UpdateStatus)
    sending message to waiting queue (CallSubDelayed - UpdateStatus)
    Installing file.
    PackageAdded: package:flm.b4a.lgdxlivewallpaper

    Just a bit confused...Any help would be appreciated
    Cheers :)
     
  19. Informatix

    Informatix Expert Licensed User

    Are you sure that you compiled your program in Release mode?
     
  20. ananaiasa

    ananaiasa New Member Licensed User

    Thank-You. :)
    Just bought My Playground...
    Very smooth
     
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