BOX2D is explained very well! Thank you so much! I had tough time understanding PPM and how to apply it!
@FlorianEagox8 жыл бұрын
Watching Brent Aurelia's Tuts and then watching these really clears everything up! Great videos.
@spilot148 жыл бұрын
After lurking your channel for a couple of days and actually created a functional game with your help, I'm so eternally grateful for your concise descriptions of methods and concepts. 10/10. The speed that you go at is perfect. Since when have you been toying with gdx? It feels like its your second nature when it comes manipulating it.
@haxpor7 жыл бұрын
This is pretty much sums up the basic most people should know first in very short time, and very concise and very understandable! Thanks!
@hwudiwkbwhsysiwkmwbsoslkwaauyy10 жыл бұрын
Literally can't find one wrong thing about your tutorials, they're great! Thanks alot!
@soleypas8 жыл бұрын
Also separating Box2D camera from game camera was a very good idea. I was running into precision issue as I have already have some zoom and adding PPM was making extra spaces between tiles!
@Oakiee9 жыл бұрын
This tutorial is great so far! It is still relevant even though you made it over a year ago.
@АлександрБабанский9 жыл бұрын
I searched this information 1 day. Big thanks!
@eToxSuuri10 жыл бұрын
Awesome tutorial, buddy! Very easy to understand and are very entertaining to watch. Thank you for your efforts :)
@branisgreat10 жыл бұрын
Your tutorials are great! Keep it up
@Quaid2k10 жыл бұрын
Hi Mike, I'm using the latest libGdx. I have used GL20, GL10 isn't available. On each bounce the box get slightly higher and it's set to Earth's gravity. I will type it all out again to be sure. I was wondered if you'd encounter any issues with the latest Gdx library. Also, it's really choppy when running on my android device, screen flashes a little too?
@ForeignGuyMike10 жыл бұрын
The problem was with the render() loop I used. I decided to remove the accumulator in Game.java and just let it run update() and render() on each loop. ie: public void render() { gsm.update(Gdx.graphics.getDeltaTime()); gsm.render(); } But that means you need to fix your Box2D world timestep. world.step(1 / 60f, 1, 1);
@Quaid2k10 жыл бұрын
ForeignGuyMike Thanks for your time Mike, that's fixed it :)
@vinceemigh95239 жыл бұрын
In the render method of Play, you changed cam.combined to the new b2dCam.combine. Is there still a use for the previous camera? Or can it be deleted?
@ForeignGuyMike9 жыл бұрын
Vince Emigh cam is the regular cam. b2dCam is only for drawing Box2D debug outlines.
@danielmenesespt10 жыл бұрын
Hi Mike, why do really need to do a while loop on Game Class in render method? Seems to me that a while loop it's already implemented in this method by the libgdx framework! So shouldn't you change it to an if statement? Just trying and understand the need if you can explain it to me! thanks
@ForeignGuyMike10 жыл бұрын
I had this weird notion to try to sync up the render loop to the Box2D world step. The while loop I used made sure that the game loop only ran in exact intervals of 1/60f, which is what I used to run the Box2D step. Anyway, it doesn't really matter. You should get rid of the while loop and just let it run one update() and render() per loop. But that means you also need to fix the Box2D world step to 1/60f. world.step(1/60f, 1, 1);
@Htrom110 жыл бұрын
Question. Do you notice the small green pixel located between the Dynamic Body box and the Static box in the lower left hand corner of the Dynamic box? Do you know why that's there?
@ForeignGuyMike10 жыл бұрын
The dots are to show contact between two fixtures. In this case, it's the box and the floor.
@coversbvk10 жыл бұрын
I get an error here: BodyDef bdef = new BodyDef(); bdef.position.set(160,120); Syntax error on token(s), misplaced construct(s) Also when i type bdef. en then press ctrl+space it says 'no default proposals'. I imported everything and I used the gradle setup. Why does it not work?
@ForeignGuyMike10 жыл бұрын
Game programming is not for beginners. If you don't know how the code is structured in class files and methods, you should not be here.
@betterw.petter303410 жыл бұрын
ForeignGuyMike Could you elaborate? I am having the same issue, and from the docs the position is a Vector2D and that class has no method "set". Hence I am getting an error saying "Cannot resolve symbol set".. Ops! My bad, I accidently started writing outside of the constructor
@ForeignGuyMike10 жыл бұрын
Better w. Petter And that's why I told him about not starting with game programming. Since he doesn't know to put code inside methods.
@coversbvk10 жыл бұрын
Yeah sorry, I didn't see that before asking. I know how to program, just wasn't paying attention..
@dmitryantipov372610 жыл бұрын
Thank you! Excellent tutorial!
@jaycalli4010 жыл бұрын
ForeignGuyMike Excuse me, for some reason I can't get the world to display the Body stuff and the whole test thing to see if it can draw the "play state" text doesn't work either. Any thoughts? Greatly appreciated.
@ForeignGuyMike10 жыл бұрын
"body stuff" "test thing" You have to be more specific than that. The test thing is from the first video. This is the second video. In order to make things clear, if the problem isn't in this video, tell me which video it's in. The test string isn't drawing? Is the draw() method even running? Find out. If it is running, then that means the test string is being drawn, but you just can't see it. Most likely it's because you're drawing with the wrong camera. *Any time you draw anything, you must specify the camera to use. Drawing is useless without a camera.* What camera are you using to draw the string? Is it set to the correct dimensions? Are you setting the SpriteBatch to use that camera? By the way, if the String isn't even being drawn, you shouldn't be on this second video. Solve the String draw problem first. Don't even look at the Box2D.
@jaycalli4010 жыл бұрын
ForeignGuyMike Nvm, I found the issue. I forgot to add the code for update and render in GameStateManager. Sorry for being very unspecific, I am very new to libgdx and have to cram in a full game project within a month. A lil stressed. Thanks anyways
@aaron9169 жыл бұрын
its telling me that the box2d ant be imported, arent they supposed to be in the lirbaries we attached to the buildpath in the first vid?
@MuresanVladMihail10 жыл бұрын
Who do you think would win between box2d and nape in terms of performance?
@ForeignGuyMike10 жыл бұрын
I didn't even know what Nape was so I searched around for a bit. It seems Nape is made and optimized for AS3, and the Box2D port to AS3 isn't as good. So if you're going for flash games, better go with Nape.
@Icohedron10 жыл бұрын
I have exactly the same code but I kept "fdef.restitution = 1f;" is it normal for the box to now be gaining more height after every bounce? It's bouncing off the screen right now.
@ForeignGuyMike10 жыл бұрын
Yes. Someone else mentioned it and that's the way Box2D behaves apparently.
@thevioletmasquerade10 жыл бұрын
For some reason the com.badlogic.gdx.physics package is not included in the gdx.jar file of the latest nightly libgdx build I downloaded. I tried both nightly builds but it was still missing.
@Quaid2k10 жыл бұрын
Hi Mike, I'm still having problems with the bouncing box shape. If I set to world.step(1 / 60f,1,1) as you suggest, it quickly bounces off screen after about 4 / 5 contacts with the ground. public void update(float dt) { world.step(1 / 60f, 1, 1); }; And, dt isn't being used anymore? If I set to world.step(dt, 1, 1) it remains on screen when bouncing but not consistent. I've check through all my code, it looks fine.
@ForeignGuyMike10 жыл бұрын
Don't use dt. It's variable now and using a variable timestep will make Box2D behave inconsistently as you can see. dt is for all non-Box2D related things. Tell me exactly what is happening. The box starts off over the platform, and it falls, and when it bounces off the platform, it just rockets up out of the screen?
@Quaid2k10 жыл бұрын
ForeignGuyMike The box drops, hits the ground platform.. On each iteration the box gets a little higher and eventually goes off screen.
@ForeignGuyMike10 жыл бұрын
Quaid2k Try using higher accuracy in the simulation. I didn't realize I used that. world.step(1 / 60f, 6, 2);
@Quaid2k10 жыл бұрын
ForeignGuyMike same result.
@ForeignGuyMike10 жыл бұрын
Quaid2k Send me your project.
@Broockle7 жыл бұрын
So, what exactly are the advantage of making a game using LibGDX instead of using let's say Unity 2D which supplies a lot more visual aids and requires a lot less programming. Does unity require more performance than LibGDX?
@ForeignGuyMike7 жыл бұрын
Broockle I think you just answered your own question there. I can't really comment since I haven't used Unity, but I suppose you need a beefier pc for it
@Broockle7 жыл бұрын
I meant for mobile development actually. I only heard of LibGDX today I didn't know it does more than mobile. But ye makes sense. I found Godot today as well, it looks more user friendly and similar to Unity. I can only program as well as the forum posts I find, the skills you display in this video are truly legendary. I can't follow any of it, I would only copy paste it and alter it as far as I can understand lol Nice series, it gave me an idea of how the workflow looks like with this engine. thx for the reply m8 ^^
@ayushsingh6210 жыл бұрын
You should really do a 3d game programming tutorial
@stolensus95945 жыл бұрын
For anyone struggling with newer versions of libgdx (using com.badlogic.gdx.physics.box2d.World) you need to add the jars under "extensions/gdx-box2d". Hope this helped some people
@ForeignGuyMike5 жыл бұрын
I highly recommend NOT creating a LibGDX project manually and use their project setup with gradle instead. github.com/libgdx/libgdx/wiki/Project-Setup-Gradle
@stolensus95945 жыл бұрын
@@ForeignGuyMike thanks for the tip! Definitely saved a lot of hassle later on. Spoke too soon, I guess :)
@theGreatDpunisher9 жыл бұрын
I copied ur code but i have no idea whats going on. My box2d wont work, its not moving... im using libgdx 1.6.5 in intelij.
@thevioletmasquerade10 жыл бұрын
I also tried a separate .jar file which did include the package, enabling me to finish inputting the code, but then I got missing source path errors. Any help is greatly appreciated.
@ForeignGuyMike10 жыл бұрын
Box2D has been moved to an extension. You need to include both the box2d jar and the box2d native jar.
@xucaen9 жыл бұрын
I am doing something very similar to this. my box2d body is only 1 meter tall and my game world is 10m x 4m. Everything is being rendered perfectly. I implemented an input listener such that when I press the space bar I call body.applyForceToCenter(0, 600, true); I think 600 is a big number, but my box2d body only jumps about a centimeter and then floats very slowly down. my gravity is (0, -9.81f). I know I missed something but can't for the life of me see what it is. I am stumped.
@ForeignGuyMike9 жыл бұрын
I don't really know much about physics. I mean, you can try to calculate it yourself. 600 kg m/s² on a 1m² box with a mass of something and 9.81m/s² gravity.
@xucaen9 жыл бұрын
I don't know, I just set the upward force to 99999 and the density to 113 (about 250 lbs and it floats like a feather. somehow the scale must be off...
@ForeignGuyMike9 жыл бұрын
***** You mean it seems like it's moving in slow motion? You're using a scaled camera right? What are your camera dimensions
@xucaen9 жыл бұрын
OMG it was the stupidest thing but I just didn't see it. I had also added code to set the linear velocity when I press left and right arrow keys. However, when the keys are not pressed I was setting linear velocity to zero. That is messing up the upward (and downward) motion. as soon as I removed those lines of code, my jumping started working as expected. Feel free to chastise me as you will.
@xucaen9 жыл бұрын
***** so it turns out you can't use applyForceToCenter and setLinearVelocity at the same time. I'm going to forget about using box2d and just code my own movement routines. Thanks for your help.
@XrwXX10 жыл бұрын
Hey i have one question , so basically i did everything in your tutorial, but when i try to launch it for android emu or android device the collision not working , the falling box go throw the static box , maybe you know hot wo fix it ?
@XrwXX10 жыл бұрын
Btw i'm using libgdx to create project
@ForeignGuyMike10 жыл бұрын
The only way I see that happening is if: 1) The fixtures are in the same body 2) The fixtures are sensors 3) The fixtures are filtered out of collision
@AmPProductionzz10 жыл бұрын
Your videos are awesome entertaining and educational, you should definetly make a 3d game tutorial
@FaTalCubez10 жыл бұрын
It's not as easy as it sounds. Since all of his tutorials are in 2D, chances are he hasn't worked with 3D that much. BUT, since he is pretty smart, I'm sure he could figure it out. I just wouldn't expect him to make tutorials anytime soon unless I'm completely off about him not knowing 3D. I'm just making an educated guess :P
@ForeignGuyMike10 жыл бұрын
I did take an OpenGL course where we did 3D graphics. I wasn't really into it, and I forgot most of it already anyway.
@shawkenton524710 жыл бұрын
The code works perfectly fine. But I have a conceptual doubt. You create an instance of Game in GameStateManager and an instance of GameStateManager in Game. Isn't this supposed to cause a stack overflow error?
@ForeignGuyMike10 жыл бұрын
No... why would it?
@shawkenton524710 жыл бұрын
ForeignGuyMike I mean if u create objects of classes from within eachother won't there be recursion?
@ForeignGuyMike10 жыл бұрын
Shaw Kenton They are only created once, and given a reference to each other. This does *not* create new instances: private Game game; public GSM(Game game) { this.game = game; }
@shawkenton524710 жыл бұрын
ForeignGuyMike Oh thanks! Sorry I got confused. Great tuts btw :)
@solidive10 жыл бұрын
Wouldn't multiplying your world's gravity by PPM get you the same result visually ? (i'm new to Box2D so i'm not sure if that's acceptable : p)
@ForeignGuyMike10 жыл бұрын
With Box2D, it's best to keep things to scale. The Box2D manual recommends: *"Box2D has been tuned to work well with moving objects between 0.1 and 10 meters. So this means objects between soup cans and buses in size should work well. Static objects may be up to 50 meters big without too much trouble."* And multiplying gravity to almost 1000m/s/s is insane and would most likely cause calculation problems.
@solidive10 жыл бұрын
ForeignGuyMike Ow ok that makes sense, thanks :)
@Majskolvenz10 жыл бұрын
Wouldn't it be good for performance if you made the Box2D unit ratio a power of two? So instead of 100 you could use 128 and then use a bit operator to shift the bits 7 places when you need to scale up or down.
@ForeignGuyMike10 жыл бұрын
Sure you could do that. But is it necessary? I always find premature optimization pointless. If it's not lagging, then it ain't broke.
@CakeStak10 жыл бұрын
ForeignGuyMike This is such a good point. I always usually prematurely optimize, glad you said that.
@1ut4d3l1ll310 жыл бұрын
I have a problem, my libGDX doesn't contains "com.badlogic.gdx.physics.box2d.World", does not contains any "physics" at all. I just downloaded the latest one, libgdx-nightly-20140916.zip Anyone could help me? PD: The project contains all the necessary gdx files and the referenced libraries
@ForeignGuyMike10 жыл бұрын
Box2D has moved to extensions. You need to add those Box2D jars. But I recommend setting up your project with the Gradle setup.
@1ut4d3l1ll310 жыл бұрын
ForeignGuyMike Thank you very much Mike. It works fine. ;)
@chrislerlaid2429 жыл бұрын
Since libgdx doesn't support gl10 anymore. I used gl20, but this code Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT); is not recognized. The GL_COLOR_BUFFER_BIT is not included in the list.
@chrislerlaid2429 жыл бұрын
Chrisler Laid I figured out, I made the wrong import. import org.lwjgl.opengl.GL20 ; Instead of: import com.badlogic.gdx.graphics.GL20;
@odo4329 жыл бұрын
Given that 100 pixels = 1m couldn't you instead just type in metres and multiple by PPM instead of dividing? EG. Instead of 160 / PPM you could do 1.6f * PPM. That way you wouldn't need to create a new camera which I believe is resource intensive.
@ForeignGuyMike9 жыл бұрын
You mean replace 160/PPM with just 1.6f. I guess you could do that if you wanted, but if I needed to change my conversion rate, it would be a hassle to go through all the values individually when I can just change PPM. I haven't heard camera is resource intensive. The only thing I heard that you shouldn't have more than one of is the SpriteBatch.
@odo4329 жыл бұрын
No sorry. I meant 160 / PPM with the new camera you created to increase size (as it was tiny) is the same as 1.6f * PPM using the default 'cam' camera. 1.6f being 1.6m in the game which is multiplied by PPM which is the amount of pixels which represents the length of 1m in the game. Hope that makes sense. :)
@ForeignGuyMike9 жыл бұрын
Mat O Box2D is a physics simulation engine. It runs well within "normal" ranges, and behaves unpredicatbly with abnormal sizes. It uses meters as its unit. If I understand what you're saying correctly, what you're asking is putting Box2D outside of its comfort zone. Take the falling box Body for instance. It's 10/PPM x 10/PPM, or 0.1m x 0.1m. You're asking me to change the box size instead to 0.1*PPM x 0.1*PPM, or 10m x 10m just to fit in the normal camera. Unfortunately, a box that size might not behave very normally.
@odo4329 жыл бұрын
Yes. I noticed when I was testing it that my box did not fall as fast as yours. I also noticed that if you upped the gravity to insane levels (like 100+) and applied perfect bounce (1) it acted abnormally. Wonder if it's just a limitation of the physics engine? Either way, it's fun playing around with and performing trial and error runs.
@larssonk2210 жыл бұрын
I've been reading that it's not a good idea to use the pixel size for dimensions. I'm can't find the alternative method of creating your own unit size.
@ForeignGuyMike10 жыл бұрын
This is a pixel game, so I want it to look pixelated. If you want, I think LibGDX has a feature that allows to convert pixels.
@larssonk2210 жыл бұрын
ForeignGuyMike Hi thanks for replying, I have tiles 60px by 60px, so I'd like to use that as my unit ie. 60px by 60px= 1 unit, I just don't know how to set up the camera to do so :(
@ForeignGuyMike10 жыл бұрын
TheDonBarracuda Ohhhhh, I thought you meant independent screen density pixels. You're talking about Box2D right? Yeah, I convert pixels to meters.
@larssonk2210 жыл бұрын
ForeignGuyMike I'm not using box2d either. I'm making a simple tetris game using arrays, but things seem to be over complicated when using pixels for dimensions. And cause problems when porting to different devices.
@ForeignGuyMike10 жыл бұрын
TheDonBarracuda Hmm, not really sure :\
@meykilim9 жыл бұрын
I'm having trouble with: import com.badlogic.gdx.physics.Box2DDebugRenderer; import com.badlogic.gdx.physics.World; with the "com" any idea what it might be?
@ForeignGuyMike9 жыл бұрын
João Pedro Bastos Nope
@Nicolas37389 жыл бұрын
+João Pedro Bastos Im having the same problem and I don't know why
@HarmanjeetKhangura8 жыл бұрын
Edit: This explanation is wrong as pointed out by ForeignGuyMike in comment below.. +João Pedro Bastos +Nicolas3738 I don't know if you still need this answer but you are not supposed to add ; (Semicolon) at the end of import statements.. Instead of import com.badlogic.gdx.physics.Box2DDebugRenderer; import com.badlogic.gdx.physics.World; write import com.badlogic.gdx.physics.Box2DDebugRenderer import com.badlogic.gdx.physics.World
@ForeignGuyMike8 жыл бұрын
Harmanjeet Khangura This is 100% false.
@HarmanjeetKhangura8 жыл бұрын
Sorry mate.. My bad. I mixed Objective C and Java.. I have been doing self imports for so long, I lost track of it..
@din864010 жыл бұрын
Since the Box2D has become and extension, how can I import Box2D now on this existing project?
@ForeignGuyMike10 жыл бұрын
Use the LibGDX setup to create your projects.
@NahroGamer9 жыл бұрын
Kostas Kadoglou update the build.gradle dependancies
@KirtanShahU8 жыл бұрын
I did b2dCam = new OrthographicCamera(); b2dCam.setToOrtho(false, Game.V_WIDTH / PPM, Game.V_HEIGHT / PPM); but it still shows my fixtures as dots. (PPM is 100). Any suggestions?
@ForeignGuyMike8 жыл бұрын
+Kirtan Shah Are you rendering the Box2D debug lines with the b2dCam?
@KirtanShahU8 жыл бұрын
ForeignGuyMike yes, this is my render line: b2dr.render(world, b2dCam.combined);
@KirtanShahU8 жыл бұрын
+ForeignGuyMike Also, if the b2dCam still doesn't work, can I just multiply the gravity by PPM?
@ForeignGuyMike8 жыл бұрын
Kirtan Shah No. Small fixtures need small cameras. If the cameras are fine, your fixtures are messed up.
@KirtanShahU8 жыл бұрын
ForeignGuyMike Ok, but my fixtures are fine as well. I have fdef.shape = shape, where shape is a PolygonShape and I put the same values in the tutorial and divided them by PPM
@n0MC9 жыл бұрын
very nice video, well explained
@grassinog280310 жыл бұрын
Hey, great tutorial but I get an Error: BodyDef def = new BodyDef(); def.position.set(160, 120); Multiple markers at this line ; - Syntax error on tokens, delete these tokens; - Syntax error on token(s), misplaced construct(s) def.type = BodyType.StaticBody; Syntax error on token "type", VariableDeclaratorId expected after this token Thanks in advance :)
@ForeignGuyMike10 жыл бұрын
I don't know. You're probably using the wrong punctuation somewhere.
@Lumai010 жыл бұрын
After the setting new size ratio, nothing shows up :/ My code is nearly identical to yours. The V_WIDTH and V_HEIGHT are renamed to WIDTH and HEIGHT.
@ForeignGuyMike10 жыл бұрын
You have the b2dCam set up? Since the Box2D objects are PPM times smaller, the b2dCam also should be PPM times smaller. b2dCam = new OrthographicCamera(); b2dCam.setToOrtho(false, WIDTH / PPM, HEIGHT / PPM); Then use that camera for rendering. b2dr.render(world, b2dCam.combined);
@Lumai010 жыл бұрын
I made a stupid mistake inside B2DVars.java, I set PPM as an int instead of a float :/ It's fixed now, thanks for the help. Also, great tutorial series :)
@emredemirsatan489710 жыл бұрын
Lumaio Me too, thanks!!!
@bvisonl10 жыл бұрын
Lumaio Also here... thanks mate
@WurstschneideBrot4 жыл бұрын
Then WHY does box2d use these units when most people change these to like 100 PPM ??? Why can't be that impleneted as a 1-liner? Like SetPPM It looks horrible when u divide it everywhere with this constant...
@ForeignGuyMike4 жыл бұрын
You know what? thats actually an interesting question. I have one idea, not sure how well it will work though. One thing you can try is to make subclasses of some of the Box2D classes and like you said, have some kind of setPPM function. Then, override all those position, vector, etc methods to use the PPM. It's a lot of work I think, but itll make it easier in the long run.
@shivakudikala64609 жыл бұрын
How you kept a Package in a Package
@biswasl10 жыл бұрын
For some reason even after I have done clear screen, its still not rendering properly. Any specific reason for this?
@ForeignGuyMike10 жыл бұрын
What does "not rendering properly" mean?
@biswasl10 жыл бұрын
Thanks for replying Mike. It is still showing the trails of the moving box. Once it rests on he ground object, the application slows down and eventually hangs.
@ForeignGuyMike10 жыл бұрын
Biswas Lamichhane Show me your Play.java
@biswasl10 жыл бұрын
ForeignGuyMike Nevermind, I completely re - wrote Play.java and its working now. Couldn't find the issue though. Thanks for the amazing tutorials Mike.
@ShangDamaTsung3 жыл бұрын
Wow Great tutorial... !
@justinmcdonald25028 жыл бұрын
im getting null pointer errors when i try to render i cant figure out why
@ForeignGuyMike8 жыл бұрын
+Justin McDonald No joke. Null pointers are one of the easiest bugs to fix. Look at the exception that being thrown. It straight up tells you which class and which line of code is throwing the exception. In Eclipse, you can even click on the line in the exception message for convenience and it'll bring you to the exact line that has a null issue. Find out why it's null, and then how to make it not null.
@michaelalvarez893710 жыл бұрын
Where did you learn all this?
@ForeignGuyMike10 жыл бұрын
google and box2d manual.
@appukumar19087 жыл бұрын
how a body shoot from a fixed point and rotate through angle..this physics body collide with the wall. like bubble shooter game
@thevioletmasquerade10 жыл бұрын
Works now, thanks.
@zoltanacs9010 жыл бұрын
ForeignGuyMike Hi, for some reason I am not able to import the com.badlogic.gdx.physics.box2d.Box2DDebugRenderer class. Can you help me? Netbeans writes me, that package com.badlogic.gdx.physics.box2d does not exists. :S
@ForeignGuyMike10 жыл бұрын
Box2D moved to an extension. You can find it in the extensions directory. I suggest using Gradle to set up your projects.
@zoltanacs9010 жыл бұрын
ForeignGuyMike thx a lot!
@chuckita8 жыл бұрын
how do you download box2D?
@TheFatSmurfs9 жыл бұрын
ForeignGuyMike Hey man i've been doing research on javascript anyway this time i have a real error and its the fact that world can't be resolved to a type and i cant import i can only make a class called World.
@ForeignGuyMike9 жыл бұрын
You need to have the Box2D libraries.
@TheFatSmurfs9 жыл бұрын
ForeignGuyMike i do.... im positive i even checked
@ForeignGuyMike9 жыл бұрын
TheFatSmurfs The *can't be resolved to a type* error means the program cannot figure out what type of object it is. In this case, the game has no idea what the World object is. World is an object that's part of the Box2D libraries. You need those libraries on your build path, and you need to import those libraries. Then you can use it.
@TheFatSmurfs9 жыл бұрын
ForeignGuyMike yea i know, that's why i cant understand this error because in the 1st video i imported everything i needed to import... any specifics for a certain library? because i notice its in the box2d bad logic library and i've imported things from that library.... that's why i cant understand this error
@aaron9169 жыл бұрын
ForeignGuyMike are the box2d libraries contained within the ones in the build path from the first vid? or do you add them in after?
@SzahMatt9 жыл бұрын
All guys who have problem with World class. U have to download the source code under the movie, and replace yours glx.jar file with this downloaded. I dont know why, but in the newest libs from glx we not find .physics.*
@МарияПостникова-д5и6 жыл бұрын
thank you very much! I also couldn't find physics in the newest package
@OyemeLife10 жыл бұрын
Thank you!!!
@Htrom110 жыл бұрын
Aha that's kinda funny that's the first thing you say next video
@Schlimbinger5 жыл бұрын
stabil
@sombraeterna9910 жыл бұрын
World doesnt exist, i dont know whats wrong
@ForeignGuyMike10 жыл бұрын
... you didn't make it?
@sombraeterna9910 жыл бұрын
ForeignGuyMike the import physics.World doesn exist
@CoLinearProductions10 жыл бұрын
8:30
@UGCjezus10 жыл бұрын
First, thank you for the tutorial. Second I have run into the same problem as @Justin Mickelson. Here is the stack trace. Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.UnsatisfiedLinkError: org.jbox2d.common.Timer.now()D at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:120) Caused by: java.lang.UnsatisfiedLinkError: org.jbox2d.common.Timer.now()D at org.jbox2d.common.Timer.now(Native Method) at org.jbox2d.common.Timer.reset(Timer.java:35) at org.jbox2d.common.Timer.(Timer.java:31) at org.jbox2d.dynamics.World.(World.java:587) at org.jbox2d.dynamics.World.(World.java:158) at org.jbox2d.dynamics.World.(World.java:154) at org.jbox2d.dynamics.World.(World.java:145) at com.badlogic.gdx.physics.box2d.World.(World.java:61) at states.Play.(Play.java:17) at handlers.GameStateManager.getState(GameStateManager.java:34) at handlers.GameStateManager.pushState(GameStateManager.java:44) at handlers.GameStateManager.(GameStateManager.java:20) at main.Game.create(Game.java:34) at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:136) at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
@ForeignGuyMike10 жыл бұрын
Box2D is longer part of the standard gdx jar. If you're using the latest LibGDX, you can find the Box2D jars in the extensions folder. Also, I suggest you use Gradle to set up your project.
@UGCjezus10 жыл бұрын
Mike I have already added all three jars in the extensions folder prior to writing the message above. I did not use Gradle to set up the project. I will do that, however I did read all comments on this page before posting. I don't want to waste your time with stupid questions. I will use Gradle to resetup the project. Thank you for your assistance.
@LukTarPL10 жыл бұрын
ForeignGuyMike Gardle is so heavy. URL to box2d is libgdx.badlogicgames.com/nightlies/dist/extensions/.
@c4v210 жыл бұрын
too bad that box2d lack of Javadoc :(
@ForeignGuyMike10 жыл бұрын
Well, you don't really need it. There is already a manual. It's in c++ but the LibGDX Box2D JNI pretty much uses the same method and class names as the original c++. You should be able to easily take the c++ code from the manual and turn it into Java. For example, in section 2.3 of the manual, it shows you how to create a Body in c++: b2BodyDef bodyDef; bodyDef.type = b2_dynamicBody; bodyDef.position.Set(0.0f, 4.0f); b2Body* body = world.CreateBody(&bodyDef); The simple translation to LibGDX Box2D is: BodyDef bodyDef = new BodyDef(); bodyDef.type = BodyType.DynamicBody; bodyDef.position.set(0.0f, 4.0f); Body body = world.createBody(bodyDef); Yeah, it's not completely the same method and class names. Box2D classes have the b2 prefix to try to keep it from messing up namespaces, and the methods are camelcase, but you can always use Eclipse Intellisense (the little box that appears when you type in some code to help you finish. You can also activate it with ctrl + space). And you can ignore the pointer stuff (& and *). If it's a little hard to translate, you can use google or: github.com/libgdx/libgdx/wiki/Box2d
@c4v210 жыл бұрын
ForeignGuyMike You are right but this is more about the comfort of writing the code. I like it a lot when my IDE tells me exactly what the function doeas and what the argument stands for :)
@ForeignGuyMike10 жыл бұрын
c4v2 Yeah I don't really need that stuff. You can include the source code for jars in Eclipse project settings. Intellisense will give the API documentation for the classes and methods.
@แอนจัง-ฐ4ผ6 жыл бұрын
You ,give me source code
@hobbles4u10 жыл бұрын
For some reason I cant import box2D was it included with libGDX?
@ForeignGuyMike10 жыл бұрын
www.badlogicgames.com/wordpress/?p=3412 Specifically the 5th point
@hobbles4u10 жыл бұрын
Is adding it the same way I did the rest if libGDX correct I got to the part where you ran the box and I am getting an exception... Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.UnsatisfiedLinkError: org.jbox2d.common.Timer.now()D at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:120) Caused by: java.lang.UnsatisfiedLinkError: org.jbox2d.common.Timer.now()D at org.jbox2d.common.Timer.now(Native Method) at org.jbox2d.common.Timer.reset(Timer.java:35) at org.jbox2d.common.Timer.(Timer.java:31) at org.jbox2d.dynamics.World.(World.java:587) at org.jbox2d.dynamics.World.(World.java:158) at org.jbox2d.dynamics.World.(World.java:154) at org.jbox2d.dynamics.World.(World.java:145) at com.badlogic.gdx.physics.box2d.World.(World.java:61)
@hobbles4u10 жыл бұрын
Alright I just decided to get the older libGDX so its all good now.
@ForeignGuyMike10 жыл бұрын
Justin Mickelsen You should really avoid using older versions. LibGDX Box2D is a JNI for the native Box2D. You need to also add the Box2D natives jar.
@hobbles4u10 жыл бұрын
ForeignGuyMike Alright I gave it another shot and I got it working this time. I created a new project and just brought in everything from the old one and added all the libs again. Not to sure why but it is working this time. Thanks a lot man, now to continue forward with this. Great tut by the way.