I have tried to make a ellipse object in libgdx. Sorry if i can't describe properly but im a newbie in java.
My code looks like:
public class GameScreen implements Screen{ MyGame game; OrthographicCamera camera; SpriteBatch batch; ... Ellipse playBounds; public GameScreen(MyGame game) { this.game = game; camera = new OrthographicCamera(); camera.setToOrtho(false, 1080, 1920); batch = new SpriteBatch(); state = GAME_READY; touchPoint = new Vector3(); pauseBounds = new com.badlogic.gdx.math.Rectangle(1080-128,1920-128,128,128); playBounds= new Ellipse() } ...
public void render(float delta) { Gdx.gl.glClearColor(1F, 1F, 1F, 1F); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); camera.update(); generalupdate(); batch.setProjectionMatrix(camera.combined); batch.begin(); batch.draw(Assets.sprite_bg, 0, 0); switch (state){ case GAME_READY:{ batch.draw(Assets.sprite_startScreen, 0, 0); batch.draw(Assets.sprite_playButton,218,800,644,225); break; } Basically it draws background, a welcome screen and a button(with "play" on it) So here i made a touch detection.
if (Gdx.input.justTouched()) { camera.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0)); if (state==GAME_READY); if (playBounds.contains(touchPoint.x, touchPoint.y)) { state=GAME_RUNNING; Drawing works fine but the problem is when i touch the button it doesnt work instead if i touch near it game starts as it should