Created
November 10, 2015 13:44
-
-
Save picopicolab/2d91e5b71fa5ec354012 to your computer and use it in GitHub Desktop.
画面遷移サンプル実装
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.picopicolab.games.demo; | |
import com.badlogic.gdx.Game; | |
import com.badlogic.gdx.graphics.FPSLogger; | |
/** | |
* 画面遷移サンプル実装 | |
*/ | |
public class DemoGame extends Game { | |
private FPSLogger logger; | |
@Override | |
public void create() { | |
logger = new FPSLogger(); | |
setScreen(new Screen1(this)); // Screen1 クラスを指定 | |
} | |
@Override | |
public void render() { | |
super.render(); | |
// FPS 出力 | |
logger.log(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.picopicolab.games.demo; | |
import com.badlogic.gdx.Gdx; | |
import com.badlogic.gdx.Screen; | |
import com.badlogic.gdx.graphics.Color; | |
import com.badlogic.gdx.graphics.GL20; | |
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; | |
/** | |
* 画面遷移サンプル実装 | |
*/ | |
public class Screen1 implements Screen { | |
private DemoGame game; | |
private ShapeRenderer renderer; | |
public Screen1(DemoGame game) { | |
this.game = game; | |
} | |
@Override | |
public void show() { | |
renderer = new ShapeRenderer(); | |
renderer.setAutoShapeType(true); | |
} | |
@Override | |
public void render(float delta) { | |
if(Gdx.input.justTouched()) { | |
game.setScreen(new Screen2(game)); | |
} | |
Gdx.gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); | |
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); | |
// 画像描画 | |
renderer.begin(); | |
renderer.set(ShapeRenderer.ShapeType.Line); | |
renderer.setColor(Color.RED); | |
renderer.circle(Gdx.graphics.getWidth() / 2, Gdx.graphics.getWidth() / 2, 15.0f); | |
renderer.setColor(Color.CLEAR); | |
renderer.end(); | |
} | |
@Override | |
public void resize(int width, int height) { | |
} | |
@Override | |
public void pause() { | |
} | |
@Override | |
public void resume() { | |
} | |
@Override | |
public void hide() { | |
} | |
@Override | |
public void dispose() { | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.picopicolab.games.demo; | |
import com.badlogic.gdx.Gdx; | |
import com.badlogic.gdx.Screen; | |
import com.badlogic.gdx.graphics.Color; | |
import com.badlogic.gdx.graphics.GL20; | |
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; | |
/** | |
* 画面遷移サンプル実装 | |
*/ | |
public class Screen2 implements Screen { | |
private DemoGame game; | |
private ShapeRenderer renderer; | |
public Screen2(DemoGame game) { | |
this.game = game; | |
} | |
@Override | |
public void show() { | |
renderer = new ShapeRenderer(); | |
renderer.setAutoShapeType(true); | |
} | |
@Override | |
public void render(float delta) { | |
if (Gdx.input.justTouched()) { | |
game.setScreen(new Screen1(game)); | |
} | |
Gdx.gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); | |
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); | |
// 画像描画 | |
renderer.begin(); | |
renderer.set(ShapeRenderer.ShapeType.Filled); | |
renderer.setColor(Color.BLUE); | |
renderer.rect(Gdx.graphics.getWidth() / 2 - 20.0f, Gdx.graphics.getWidth() / 2 - 20.0f, 40.0f, 40.0f); | |
renderer.setColor(Color.CLEAR); | |
renderer.end(); | |
} | |
@Override | |
public void resize(int width, int height) { | |
} | |
@Override | |
public void pause() { | |
} | |
@Override | |
public void resume() { | |
} | |
@Override | |
public void hide() { | |
} | |
@Override | |
public void dispose() { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment