okay so i made some progress and the problem seems to appear only when am rotating the group, but when am moving it in the X or Y then everything works fine, to give you more insight, here is a GIF that represent the issue
http://s4.postimg.org/bp4rmg159/group_Trble.gif
and here is how am doing it
this is method is to setup the stage, group and actor :
private void createThePaddle() {
// Create a stage
stage = new Stage(new StretchViewport(game.WIDTH, game.HEIGHT));
// Create a group and add it to the stage.
group = new Group();
stage.addActor(group);
Sprite sprite = new Sprite(circleImg);
// this is what the paddle class take (i'll post it below)
redPad = new Paddle(redCol, "red", sprite, new Vector2(0, 0), 1f);
// adding the actor
group.addActor(redPad);
// setting the position relative to the stage
redPad.setPosition(0, 0);
// setting the group position in the middle of the screen
group.setPosition(RgbX.WIDTH / 2, game.HEIGHT / 2);
}
this method is to update the group :
(if i enable the commented part and disable the rotation everything works fine)
private void groupUpdate() {
if (Gdx.input.isKeyPressed(Keys.LEFT)) {
group.rotateBy(rotSpeed);
//group.setX(group.getX() - 100 * Gdx.graphics.getDeltaTime());
}
if (Gdx.input.isKeyPressed(Keys.RIGHT)) {
group.rotateBy(-rotSpeed);
//group.setX(group.getX() + 100 * Gdx.graphics.getDeltaTime());
}
if (Gdx.input.isKeyPressed(Keys.UP)) {
//group.setY(group.getY() + 100 * Gdx.graphics.getDeltaTime());
}
if (Gdx.input.isKeyPressed(Keys.DOWN)) {
//group.setY(group.getY() - 100 * Gdx.graphics.getDeltaTime());
}
}
and this is the render method :
@Override
public void render(float delta) {
// TODO Auto-generated method stub
Gdx.gl.glClearColor(0, 0.0f, 0.0f, 0);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
groupUpdate();
stage.act(Gdx.graphics.getDeltaTime());
stage.draw();
Vector2 pos = redPad.localToStageCoordinates(new Vector2(0, 0));
float[] poly = rectangleToVertices(pos.x, pos.y,
redPad.sprite.getWidth(), redPad.sprite.getHeight());
shape.setProjectionMatrix(stage.getCamera().combined);// this doesn't make any difference
shape.begin(ShapeType.Line);
shape.polygon(poly);
shape.end();
}
and finally this is the Paddle class :
package com.aladine.rgbx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Actor;
public class Paddle extends Actor {
public Color color;
public String type;
public Vector2 position;
public Sprite sprite;
public float scale;
public Rectangle rectangle;
public Paddle(Color color, String type, Sprite sprite, Vector2 position,
float scale) {
this.color = color;
this.type = type;
this.position = position;
this.sprite = sprite;
sprite.setColor(color);
sprite.setSize(sprite.getWidth() * scale, sprite.getHeight() * scale);
sprite.setOriginCenter();
}
@Override
public void draw(Batch batch, float alpha) {
sprite.draw(batch);
}
public Rectangle getBound() {
return sprite.getBoundingRectangle();
}
public Color getColor() {
return color;
}
public void setColor(Color color) {
this.color = color;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Vector2 getPosition() {
return position;
}
public void setPosition(Vector2 position) {
this.position = position;
}
public Sprite getSprite() {
return sprite;
}
public void setSprite(Sprite sprite) {
this.sprite = sprite;
}
}
NOTE: i tried using polygon instead of rectangle but i always got the same result (someone told me rectangles doesn’t rotate {am not looking to rotate the rectangle anyway})
thank you