Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (604)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (653)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Libgdx 2D lights  (Read 5311 times)
0 Members and 1 Guest are viewing this topic.
Offline cubemaster21
« Posted 2013-05-14 14:31:37 »

I'm attempting to figure out how I can add lights to my current game, it's top down 2d and there need to be multiple instances of the lights that are moving. I'll focus on making them dynamic at another date. But, I have no idea how i would do this with libgdx. Any further details can be provided at request. Any help or suggestions is greatly appreciated.

Check out my game, Viking Supermarket Smash
Offline 65K
« Reply #1 - Posted 2013-05-14 15:27:11 »

Box2dLights, for instance.

Offline pitbuller
« Reply #2 - Posted 2013-05-14 17:12:21 »

Box2dLights, for instance.

Also notice that only need box2d for shadows. So adding light library work fine even without box2d.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline cubemaster21
« Reply #3 - Posted 2013-05-14 20:37:25 »

Well, I guess I'm not so much looking for lighting as I am for creating an alpha mask. That seems like a more reasonable approach to what I'm doing.

Check out my game, Viking Supermarket Smash
Offline heisenbergman

JGO Coder

Medals: 14

L___ o_ G___ a__ P___

« Reply #4 - Posted 2013-05-15 00:59:23 »

Box2dLights, for instance.

Whoa, this looks awesome, thanks! Grin

Offline 65K
« Reply #5 - Posted 2013-05-15 04:55:48 »

And each flying bullet gets it own moving light as well Smiley
Kudos to Pitbuller for this little library which allows to enlighten your game without having the slightest clue about the low level details inside.

Well, I guess I'm not so much looking for lighting as I am for creating an alpha mask. That seems like a more reasonable approach to what I'm doing.
I think you need to be more specific about your requirements. You have the alpha channel in color objects for instance.

Offline pitbuller
« Reply #6 - Posted 2013-05-15 08:11:53 »

If you just want black where there are no light and completely white neutral light that does not distort you game colors that library can do that too. But you need be more specific what you want.
Offline heisenbergman

JGO Coder

Medals: 14

L___ o_ G___ a__ P___

« Reply #7 - Posted 2013-05-15 08:26:36 »

Slightly off-topic, but still about lighting and visibility, this is a great read with some nice interactive apps embedded on the page:

2d Visibility from Red Blob Games


Offline cubemaster21
« Reply #8 - Posted 2013-05-15 19:30:30 »

As I said that I was really only looking for a method to make an alpha mask, I've finally found something suitable. However, it seems as though it is not efficient at all. This is what I've got.
      Pixmap lightMesh = new Pixmap(width, height, Pixmap.Format.RGBA8888);
      Blending blending = Pixmap.getBlending();
      lightMesh.setColor(0f, 0f, 0f, 0f);

      int newX = Math.round(x);
      int newY = Math.round(y);

      lightMesh.fillCircle(newX, newY, radius);

Check out my game, Viking Supermarket Smash
Offline davedes
« Reply #9 - Posted 2013-05-16 01:08:04 »

Pixmaps are performed on CPU. Before rendering something to the screen, you need to upload the Pixmap RGBA data to the GPU onto a Texture. This is explained here:

Maybe you could explain your situation in more detail, with screenshots of what you're trying to do. If you just want masks, see here:

If you just want feathered circles for point lights, you could use a simple PNG sprite or shaders:

Ultimately box2dlights is really the best choice for 2D lights. It uses a disc geometry to reduce fill rate which means that multiple lights will perform better on Android. And it should be easy to make it dynamic later on in your game, via box2d.

Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

SHC (28 views)
2015-08-01 03:58:20

Jesse (20 views)
2015-07-29 04:35:27

Riven (40 views)
2015-07-27 16:38:00

Riven (21 views)
2015-07-27 15:35:20

Riven (24 views)
2015-07-27 12:26:13

Riven (14 views)
2015-07-27 12:23:39

BurntPizza (36 views)
2015-07-25 00:14:37

BurntPizza (46 views)
2015-07-24 22:06:39

BurntPizza (31 views)
2015-07-24 06:06:53

NoxInc (37 views)
2015-07-22 22:16:53
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!