added SplashScreen
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								android/assets/images/samlogo.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								android/assets/images/samlogo.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 38 KiB | 
							
								
								
									
										58
									
								
								core/src/de/samdev/clorrunner/screens/menu/MainMenu.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								core/src/de/samdev/clorrunner/screens/menu/MainMenu.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,58 @@ | ||||
| package de.samdev.clorrunner.screens.menu; | ||||
|  | ||||
| import com.badlogic.gdx.Gdx; | ||||
| import com.badlogic.gdx.Screen; | ||||
| import com.badlogic.gdx.graphics.GL20; | ||||
| import com.badlogic.gdx.scenes.scene2d.Stage; | ||||
|  | ||||
| public class MainMenu implements Screen { | ||||
|  | ||||
| 	private Stage stage = new Stage(); | ||||
| 	 | ||||
| 	@Override | ||||
| 	public void render(float delta) { | ||||
|         Gdx.gl.glClearColor(0, 0, 0, 1); | ||||
|         Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); | ||||
|         stage.act(); | ||||
|         stage.draw(); | ||||
|  | ||||
| 		 | ||||
| 	} | ||||
|  | ||||
| 	@Override | ||||
| 	public void resize(int width, int height) { | ||||
| 		// TODO Auto-generated method stub | ||||
| 		 | ||||
| 	} | ||||
|  | ||||
| 	@Override | ||||
| 	public void show() { | ||||
| 		// TODO Auto-generated method stub | ||||
| 		 | ||||
| 	} | ||||
|  | ||||
| 	@Override | ||||
| 	public void hide() { | ||||
| 		dispose(); | ||||
| 		 | ||||
| 	} | ||||
|  | ||||
| 	@Override | ||||
| 	public void pause() { | ||||
| 		// TODO Auto-generated method stub | ||||
| 		 | ||||
| 	} | ||||
|  | ||||
| 	@Override | ||||
| 	public void resume() { | ||||
| 		// TODO Auto-generated method stub | ||||
| 		 | ||||
| 	} | ||||
|  | ||||
| 	@Override | ||||
| 	public void dispose() { | ||||
| 		stage.dispose(); | ||||
| 		 | ||||
| 	} | ||||
|  | ||||
| } | ||||
							
								
								
									
										106
									
								
								core/src/de/samdev/clorrunner/screens/menu/SplashScreen.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										106
									
								
								core/src/de/samdev/clorrunner/screens/menu/SplashScreen.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,106 @@ | ||||
| package de.samdev.clorrunner.screens.menu; | ||||
|  | ||||
| import com.badlogic.gdx.Game; | ||||
| import com.badlogic.gdx.Gdx; | ||||
| import com.badlogic.gdx.Screen; | ||||
| import com.badlogic.gdx.graphics.GL20; | ||||
| import com.badlogic.gdx.graphics.OrthographicCamera; | ||||
| import com.badlogic.gdx.graphics.Texture; | ||||
| import com.badlogic.gdx.graphics.g2d.SpriteBatch; | ||||
| import com.badlogic.gdx.math.MathUtils; | ||||
|  | ||||
|  | ||||
| import de.samdev.colorrunner.screens.gameScreen.GameScreen; | ||||
|  | ||||
| public class SplashScreen implements Screen { | ||||
| 	 | ||||
| 	private float loadTime = 0; | ||||
| 	 | ||||
| 	private int random = MathUtils.random(5); | ||||
| 	private Texture logo = new Texture("images/samlogo.png"); | ||||
|      | ||||
|     private OrthographicCamera cam = new OrthographicCamera(); | ||||
| 	private SpriteBatch sB; | ||||
|  | ||||
|  | ||||
|  | ||||
| 	 | ||||
| 	@Override | ||||
| 	public void render(float delta) { | ||||
|  | ||||
| 		 | ||||
| 		if(random == 0){ | ||||
| 			Gdx.gl.glClearColor(0.4f, 0, 0, 1);					// Rot | ||||
| 			Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); | ||||
| 		}else if (random == 1){ | ||||
| 			Gdx.gl.glClearColor(0.8f, 0.8f, 0, 1);				//Gelb | ||||
| 			Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); | ||||
| 		}else if ((random == 2)){ | ||||
| 			Gdx.gl.glClearColor(1, 0.5f, 0.25f, 1);			//Orange | ||||
| 			Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); | ||||
| 		}else if (random == 3){ | ||||
| 			Gdx.gl.glClearColor(0.25f, 0.5f, 1, 1);			//Blau | ||||
| 			Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); | ||||
| 		}else if (random == 4){ | ||||
| 			Gdx.gl.glClearColor(0, 0.8f, 0.3f, 1);				//Gr<47>n | ||||
| 			Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); | ||||
| 		}else if (random == 5){ | ||||
| 			Gdx.gl.glClearColor(1, 1, 1, 1);				//Wei<65> | ||||
| 			Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); | ||||
| 		} | ||||
| 		 | ||||
|          | ||||
|     	sB.begin(); | ||||
| 		sB.draw(logo, -9, | ||||
| 				-8, 18, 16); | ||||
| 		sB.end(); | ||||
| 		 | ||||
| 		loadTime += delta; | ||||
| 		if (loadTime > 0.5) | ||||
| 			((Game) Gdx.app.getApplicationListener()).setScreen(new GameScreen()); | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	@Override | ||||
| 	public void resize(int width, int height) { | ||||
| 		// TODO Auto-generated method stub | ||||
| 		 | ||||
| 	} | ||||
|  | ||||
| 	@Override | ||||
| 	public void show() { | ||||
| 	 | ||||
| 		sB = new SpriteBatch(); | ||||
|  | ||||
| 		this.cam = new OrthographicCamera(20,40); | ||||
| 		this.cam.position.set(20 / 2, 40 / 2, 0); | ||||
| 		sB.setProjectionMatrix(cam.combined); | ||||
| 		cam.update(); | ||||
| 		 | ||||
| 	} | ||||
|  | ||||
| 	@Override | ||||
| 	public void hide() { | ||||
| 		dispose(); | ||||
| 		 | ||||
| 	} | ||||
|  | ||||
| 	@Override | ||||
| 	public void pause() { | ||||
| 		// TODO Auto-generated method stub | ||||
| 		 | ||||
| 	} | ||||
|  | ||||
| 	@Override | ||||
| 	public void resume() { | ||||
| 		// TODO Auto-generated method stub | ||||
| 		 | ||||
| 	} | ||||
|  | ||||
| 	@Override | ||||
| 	public void dispose() { | ||||
|         logo.dispose(); | ||||
| 		 | ||||
| 	} | ||||
|  | ||||
| } | ||||
| @@ -2,18 +2,19 @@ package de.samdev.colorrunner; | ||||
|  | ||||
| import com.badlogic.gdx.Game; | ||||
|  | ||||
| import de.samdev.clorrunner.screens.menu.SplashScreen; | ||||
| import de.samdev.colorrunner.screens.gameScreen.GameScreen; | ||||
|  | ||||
| public class CRGame extends Game { | ||||
| 	 | ||||
| 	private GameScreen gameScreen; | ||||
| 	private SplashScreen SplashScreen; | ||||
|  | ||||
| 	@Override | ||||
| 	public void create() { | ||||
| 		gameScreen = new GameScreen(); | ||||
| 		SplashScreen = new SplashScreen(); | ||||
| 		 | ||||
| 		//---------------------------------- | ||||
| 		 | ||||
| 		setScreen(gameScreen); | ||||
| 		setScreen(SplashScreen); | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Anastron
					Anastron