this doesn’t work :
package com.aladine.rgbx;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.Stage;
public class RgbX extends ApplicationAdapter {
SpriteBatch batch;
Texture circleImg;
Sprite center, redPad, bluePad, greenPad, yellowPad;
Color whiteCol, redCol, greenCol, blueCol, yellowCol;
public static final int WIDTH = 800;
public static final int HEIGHT = 480;
public static Vector2 screenCenter;
private Group group;
private Stage stage;
@Override
public void create() {
batch = new SpriteBatch();
circleImg = new Texture("circle.png");
screenCenter = new Vector2(WIDTH / 2, HEIGHT / 2);
center = new Sprite(circleImg);
center.setPosition(screenCenter.x - center.getWidth() / 2,
screenCenter.y - center.getWidth() / 2);
// create the colors
setColors();
// change the sprite color to blue
center.setColor(blueCol);
}
@Override
public void render() {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(center, center.getX(), center.getY(), center.getOriginX(),
center.getOriginY(), center.getWidth(), center.getHeight(), 1,
1, center.getRotation());
batch.end();
}
private void setColors() {
redCol = new Color(0.9f, 0.42f, 0.42f, 1);
blueCol = new Color(0.42f, 0.42f, 0.9f, 1);
greenCol = new Color(0.42f, 0.9f, 0.9f, 1);
yellowCol = new Color(0.98f, 0.99f, 0.42f, 1);
whiteCol = new Color(1, 1, 1, 1);
}
}
this work :
package com.aladine.rgbx;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.Stage;
public class RgbX extends ApplicationAdapter {
SpriteBatch batch;
Texture circleImg;
Sprite center, redPad, bluePad, greenPad, yellowPad;
Color whiteCol, redCol, greenCol, blueCol, yellowCol;
public static final int WIDTH = 800;
public static final int HEIGHT = 480;
public static Vector2 screenCenter;
private Group group;
private Stage stage;
@Override
public void create() {
batch = new SpriteBatch();
circleImg = new Texture("circle.png");
screenCenter = new Vector2(WIDTH / 2, HEIGHT / 2);
center = new Sprite(circleImg);
center.setPosition(screenCenter.x - center.getWidth() / 2,
screenCenter.y - center.getWidth() / 2);
// create the colors
setColors();
}
@Override
public void render() {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.setColor(blueCol);
batch.draw(center, center.getX(), center.getY(), center.getOriginX(),
center.getOriginY(), center.getWidth(), center.getHeight(), 1,
1, center.getRotation());
batch.end();
}
private void setColors() {
redCol = new Color(0.9f, 0.42f, 0.42f, 1);
blueCol = new Color(0.42f, 0.42f, 0.9f, 1);
greenCol = new Color(0.42f, 0.9f, 0.9f, 1);
yellowCol = new Color(0.98f, 0.99f, 0.42f, 1);
whiteCol = new Color(1, 1, 1, 1);
}
}
thank you