Okay guys, another noob question coming...I've decided to implement different screens into my brickbreaker game, so I moved all of my game.java code into GameScreen.java and changed the necessary things (created the show method and moved all of create() to it) and i've created a splash screen. (splash.java)
I've got it working, it loads the splash screen which just changes the screen to white right now and when you click on it, it loads the game from GameScreen. As soon as I click on the screen, it changes but flickers from black to white over and over again like it's still calling the splash screen...Also, there is a trace of images from the ball that are behind it and none of the bricks are disappearing. I've taken a picture which really doesn't show the screen flashing.

Below is my Splash.java code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| package com.psillicoder.brickbreaker; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Screen; import com.badlogic.gdx.Game; import com.badlogic.gdx.graphics.GL10; import com.badlogic.gdx.graphics.g2d.SpriteBatch; public class Splash implements Screen {
private Game MyGame; private SpriteBatch batch; public boolean isActive; public Splash(Game g) { MyGame = g; } public void render(float delta) { if (isActive) { Gdx.gl.glClearColor(1, 1, 1, 1); Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); if(Gdx.input.justTouched()) { MyGame.setScreen(new GameScreen(MyGame)); System.out.println("TESTING"); } } } @Override public void resize(int width, int height) { }
@Override public void show() { isActive = true; }
@Override public void hide() { isActive = false; }
@Override public void pause() { }
@Override public void resume() { }
@Override public void dispose() { }
} |
Below is the show() part of my GameScreen:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| @Override public void show() { isActive = true; float w = Gdx.graphics.getWidth(); float h = Gdx.graphics.getHeight(); Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); ball = new Ball(); paddle = new Paddle(); level = new Level(); camera = new OrthographicCamera(1, h/w); batch = new SpriteBatch(); font = new BitmapFont(); textWidth = font.getBounds(strBricks).width; textHeight = font.getBounds(strBricks).height; level.LoadBricks(); } |