Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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  
  box2dlight + libgdx -> cant get it to work (SOLVED)  (Read 6053 times)
0 Members and 1 Guest are viewing this topic.
Offline Nesopharus

Senior Newbie

« Posted 2013-08-22 10:43:52 »

Hello peeps, I started to create a 2D topdown Tilebased Game and i wanted to add some lightning.

I found this tut:
but i could not get it to work.

at this place:
light_world = new com.badlogic.gdx.physics.box2d.World(new Vector2(), true);
rayHandler = new RayHandler(light_world); // <----- this one

i get an Exception and that was it then :/

here is what my eclipse says :

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.IllegalArgumentException: color attribute must have 4 components
   at com.badlogic.gdx.backends.lwjgl.LwjglApplication$
Caused by: java.lang.IllegalArgumentException: color attribute must have 4 components
   at box2dLight.RayHandler.<init>(
   at box2dLight.RayHandler.<init>(
   at de.vdb.tiledmapgametest.LightRenderer.<init>(
   at de.vdb.tiledmapgametest.WorldRenderer.drawLight(
   at de.vdb.tiledmapgametest.WorldRenderer.render(
   at de.vdb.tiledmapgametest.Gamescreen.render(
   at com.badlogic.gdx.Game.render(
   at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(
   at com.badlogic.gdx.backends.lwjgl.LwjglApplication$

i am using the stable libgdx 0.9.8

maybe somebody around here may have an idea Cheesy

btw. the light_world is filled somewhere else after that piece of code but as far as i can see that is nothing i have to care about at this place right?  Roll Eyes

edit: got the line of code where it all goes to valhalla x.x  its in libgdx  :  Line 104
if (attribute.usage == Usage.Color || attribute.usage == Usage.ColorPacked) {
            if (attribute.numComponents != 4) throw new IllegalArgumentException("color attribute must have 4 components"); // <--- this one :D

            if (cols) throw new IllegalArgumentException("two color attributes were specified");
            cols = true;

while debugging i found out that i have got 2 attributes    vertex positions and color     color got 4 args  thats ok but here the color attribute got the usage code 4  and the positions 1   libgdx is asking for code 1 as color code and then it runs into 2 components  not 4  after that ->  crash x.x

edit 2 :

Okay now i can see that box2dlights uses the Usage class of libgdx  and takes Usage.Position for the position attributes and Usage.ColorPacked for the Color   so far its okay    but now at Runtime i got the code 1 for the pos attribute and it is recognized as a color, but for the position the code 0 is used in my libgdx o.O    seems like in my libgdx there are other codes used then in box2dlight  ill try to change from stable to nightly if that fixes my bug   ill report back soon Tongue

edit 3:

after a break and updating my libs to the nightly build its working now Cheesy

sorry for spamming your forum xD but i did not know that i can fix it on my own Tongue just started my apprenticeship this month as a programmer ^^

Hi! Cheesy
Offline namrog84

JGO Ninja

Medals: 46
Projects: 4

Keep programming!

« Reply #1 - Posted 2013-08-22 12:48:39 »

but i did not know that i can fix it on my own Tongue

I feel like I spend many hours on problems myself,  post to this forum and solve it on my own within a few minutes later. I usually have several edits of my progress too. (happens all of the time) Its totally fine  Grin  And it can be good too, because sometimes others might have similiar ideas/issues and can see this post while searching for solutions

The only thing I would suggest is editing your title to include (SOLVED) at the end of it.

"Experience is what you get when you did not get what you wanted"
Offline jeffberhow

Junior Newbie

« Reply #2 - Posted 2013-08-22 14:59:52 »

I agree. Documenting your mistakes and fixes can be hugely beneficial to other users, especially when they get snatched up by the Google indexer. They are also great to turn into blog posts if you are into that sort of thing!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Nesopharus

Senior Newbie

« Reply #3 - Posted 2013-08-23 07:00:26 »

i dont even know how a blog post would look like o.O
im not really into such things Tongue but ill try to document my problems and stuff like that

for now ill just try to complete my tasks so i can keep working on my game Cheesy

Hi! Cheesy
Pages: [1]
  ignore  |  Print  

EgonOlsen (73 views)
2018-06-10 19:43:48

EgonOlsen (54 views)
2018-06-10 19:43:44

EgonOlsen (73 views)
2018-06-10 19:43:20

DesertCoockie (253 views)
2018-05-13 18:23:11

nelsongames (154 views)
2018-04-24 18:15:36

nelsongames (153 views)
2018-04-24 18:14:32

ivj94 (895 views)
2018-03-24 14:47:39

ivj94 (156 views)
2018-03-24 14:46:31

ivj94 (807 views)
2018-03-24 14:43:53

Solater (171 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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!