Okay so this is probably a pretty trivial question. I’ve been playing around with Box2d and libgdx for a little while now and i’m making a breakout type game. I’ve got my world setup, i’m using Tiled for the brick placement and all that seems to work…
The problem i’m having is with the paddle. I originally had set the paddle type to a Kinematic body as it doesn’t need to be affected by gravity or anything like that. Everything seemed to be good. I think I had an issue with getting it to move at first if I recall correctly, but was able to figure that out. The bricks, of course, are Dynamic bodies. I also have unbreakable bricks on the sides to keep the ball and paddle in bounds…The only problem is, the paddle goes straight through the border bricks and does not collide or stop it…I could check for bounds and keep the paddle in bounds that way…But that wouldn’t really solve my problems.
I tried setting the paddle to dynamic and the bricks stopped the paddle from moving when they touched…The problem here, is that when the ball hits the paddle, it moves it down from the force of the ball. So when the left or right keys are pressed, I set the paddle to dynamic and then directly back to kinematic…This solved the problem with the paddle falling when the ball hit it, but it still goes through the border bricks…I’ve searched and searched but can’t seem to figure out the best way to do this.
I’ve been playing around with libgdx off and on for a while now. I should be a pro by now but I still have a lot to learn as I haven’t stuck with it. I’ve been focusing more on it lately and trying to learn everything I can. I still have a lot of stuff to learn…I’m a bit overwhelmed by this already with the Box2d stuff. I’m also having a bit of trouble setting it up so that the ball behaves correctly…Right now, it just bounces a couple times on the paddle but doesn’t have enough velocity to hit the bricks. Not to mention issues with getting collision detection set up…Lol. I have found many tutorials and documentation as far as box2d collision so i’m not worried about that issue as much. I do, however, need to structure my project a little better. I’m working on setting up the project now on Github and i’ll show you the embarrassing code haha.
Any help is greatly appreciated guys. I enjoy coding very much and am desperately trying to stick with it this time, i’m just a little frustrated.
Git:
EDIT
Edited to add Git url. The code is extremely messy. I’m learning as i’m going and trying to refactor and clean it up a bit. Thanks again guys! Any information or feedback is appreciated!