In slick2D,we had something like
g.rotate(px, pY, angle)
Stuff to draw
Stuff to draw
Stuff to draw
...
g.rotate(pX,pY, -angle)
So that everything between the “g.rotate” will be rotated, is there a Libgdx equivalent?
In slick2D,we had something like
g.rotate(px, pY, angle)
Stuff to draw
Stuff to draw
Stuff to draw
...
g.rotate(pX,pY, -angle)
So that everything between the “g.rotate” will be rotated, is there a Libgdx equivalent?
You can set a transformation-matrix in the SpriteBatch
This sets rotation, transformation and scale.
I can’t make it to work, here is my render methods for my screens
ScreenIngame.java
@Override
public void render(float delta)
{
super.render(delta);
game.batch.begin();
for(Entity entity : entityList)
{
entity.render(delta, game.batch);
}
for(PooledEffect effect : effects)
{
effect.draw(game.batch, delta);
if(effect.isComplete())
{
effects.removeValue(effect, true);
effect.free();
}
}
virtualJoystick.render(gamePort);
game.batch.end();
bombButton.draw(delta);
}
the overriden method
ScreenBasic.java
@Override
public void render(float delta)
{
Gdx.gl.glClearColor(0.4f, 0.9f, 1.0f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
update(delta);
this.camera.update();
game.batch.setProjectionMatrix(camera.combined);
}
And i’ll want that some entities can rotate
If you want to render all Entities rotated call this before your render-for-loop:
Matrix4 rotMatrix = new Matrix4(...);
game.batch.setTransformMatrix(rotMatrix);
And read the LibGDX Matrix4 and Quaternion docs!
If you want to render individual Entities rotated, then why don’t you show us your Entity class, so that we actually know what you are using inside (without asking the crystal ball) :
Most entities don’t need to rotate but the player for example needs to. I don’t think you’ll need the code for it, but the most important part is that he have a body texture, a hand texture, and a foot texture so all his limbs are drawed separatly. I need that his hands and feet rotate with the body.
This is a top-down game btw
That means I cannot help you with your problem :-*
Why don’t you just go figure it out yourself if you’re not willing to share some useful information. :cranky: