B4A Library Box2DLights

Discussion in 'Additional libraries, classes and official updates' started by Informatix, Mar 29, 2014.

  1. Informatix

    Informatix Expert Licensed User

    Box2DLights is a plugin for libGDX. It adds light sources to your Box2D scene. A light source can be attached to a body and move with it.
    For more information about this library, please read this wiki.

    v0.9:
    Initial release

    v1.0:
    - Bugfixes
    - New class: lgB2L_ChainLight
    - New functions
    - Better documentation
    - New demo

    v1.01:
    - Incompatibility with libGDX v1.10 fixed;
    - New function: lgB2L_RayHandler.ResizeFBO;
    - Default soft shadow length set to distance * 0.1.

    lights.jpg screenshot.jpg
     

    Attached Files:

    Last edited: Oct 23, 2015
    Ohanian, Daniel-White, ilan and 9 others like this.
  2. walterf25

    walterf25 Well-Known Member Licensed User

    Very Nice Frederic, i'm going to give it a try today!

    Thanks,
    Walter
     
  3. ilan

    ilan Expert Licensed User

    the examples are very good and easy to understand, thank you @Informatix :)
     
  4. andymc

    andymc Well-Known Member Licensed User

    Could this be used to give "glowing" effects to retro style games?
     
  5. ilan

    ilan Expert Licensed User

    do you mean like a frame on the character?
     
  6. andymc

    andymc Well-Known Member Licensed User

    yes, and maybe glowing around objects like laser bolts or gridlines, so you could write an asteroids game with glowing rocks and spaceship

    [​IMG]
     
    wonder and Tayfur like this.
  7. ilan

    ilan Expert Licensed User

    yes you can, like you can see in the first post (informatix glowing objects)
     
  8. Informatix

    Informatix Expert Licensed User

    You could do that with the lib BUT I recommend instead to pre-render the glowing effect and play it as an animation. You will save FPS this way.
     
  9. andymc

    andymc Well-Known Member Licensed User

    okay, I did something similar with my space invaders game, I just rendered a transparent blue behind the aliens to give them the look of glowing.
     
  10. andymc

    andymc Well-Known Member Licensed User

    I'm also interested if this could be used to add lighting effects to overhead games to give a night time theme with lightning flashes, and the players having torches to look around, all viewed from above.
     
  11. Informatix

    Informatix Expert Licensed User

    This is what is done for.
     
  12. wonder

    wonder Expert Licensed User

    In my current project I'm not using Box2D at all.
    Nevertheless I'd like to utilize this library in order to have some cool lighting effects.

    Would I have to replicate each game object as a Box2D object or could I just associate a Box2DLight object to a posX, posY of one of my current objects?

    Thanks in advance! :)
     
  13. Informatix

    Informatix Expert Licensed User

    No. You can either attach the light to a body (with AttachToBody) or set its position (with Position.Set). If objects entering the light radius are not Box2D objects, the rays cannot be stopped so there will be no shadow.
     
  14. wonder

    wonder Expert Licensed User

    Understood, thanks Fred! :)
    Are there any other lighting effects or ways to achieve a similar effect using just the "regular" LibGDX functions? Shaders, perhaps?
     
  15. ilan

    ilan Expert Licensed User


    Example: https://b4x.com/android/forum/threads/glowing-ball-status-approved.49833/

     
    Last edited: May 4, 2016
    wonder likes this.
  16. Informatix

    Informatix Expert Licensed User

    The lights of this library are made with shaders.
     
    wonder likes this.
  17. ilan

    ilan Expert Licensed User

    hi @Informatix in your ChainLight example it says that the polygons were created with Polygon Editor v0.2.1

    i could not find such an editor, i only am able to find the Physics Body Editor. Do you have maybe a link?

    thanx, ilan
     
  18. Informatix

    Informatix Expert Licensed User

    The link should be somewhere in the libGDX guide.
     
    Marko Druskovic likes this.
  19. Almora

    Almora Active Member Licensed User

    Nice..
     
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