libgdx + rub + noob questions ... :P
Posted: Tue Jul 16, 2013 11:23 am
Hey
So I’m kind of new to box2d in general... and I’m trying to make a pong game
when I have made my bodies and textures in rub and exported in to my libgdx project I use this lines off code
my first problem is that i in some why need to identify my ball body... but i don't find a why to due this with out user data but in i figure out how to set user data in rube
is there a better why to due this ???
second question
this problem have i been struggling with for a while now when the ball hits a paddle i need it to bounce off with an angel relative to where it hit the paddle ... but i can't figure out how to change the travel angel off my ball body
how cut i solve this ???
i Goth a working pong game but it aint using box2d ... in this program the return angel is calculated like this
i think i shut be able to use the same function in my box2d based pong game
but i need a function to change the movement angel...
sorry for my bad english
So I’m kind of new to box2d in general... and I’m trying to make a pong game

Code: Select all
private RubeSceneLoader loader;
private RubeScene scene;
World world;
loader = new RubeSceneLoader();
scene = loader.loadScene(Gdx.files.internal("data/test.json"));
world = scene.getWorld();
world.setContactListener(new contactlistenerHandler());

second question

this problem have i been struggling with for a while now when the ball hits a paddle i need it to bounce off with an angel relative to where it hit the paddle ... but i can't figure out how to change the travel angel off my ball body

i Goth a working pong game but it aint using box2d ... in this program the return angel is calculated like this
Code: Select all
private float getReflectionAngle(Paddle paddle) {
float ballCenterY = ball.getY() + (ball.getHeight() / 2f);
float paddleCenterY = paddle.getY() + (paddle.getHeight() / 2f);
float difference = ballCenterY - paddleCenterY;
float position = difference / paddle.getHeight();
return BALL_REFLECT_ANGLE * position;
}

but i need a function to change the movement angel...
sorry for my bad english
