- package com.mouse.game;
- import com.badlogic.gdx.Gdx;
- import com.badlogic.gdx.Input;
- import com.badlogic.gdx.Screen;
- import com.badlogic.gdx.graphics.GL20;
- import com.badlogic.gdx.graphics.OrthographicCamera;
- import com.badlogic.gdx.maps.tiled.TiledMap;
- import com.badlogic.gdx.maps.tiled.TiledMapRenderer;
- import com.badlogic.gdx.maps.tiled.TmxMapLoader;
- import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
- import com.badlogic.gdx.math.Vector2;
- import com.badlogic.gdx.physics.box2d.*;
- import com.badlogic.gdx.utils.viewport.FitViewport;
- import com.badlogic.gdx.utils.viewport.ScreenViewport;
- import com.badlogic.gdx.utils.viewport.StretchViewport;
- import com.badlogic.gdx.utils.viewport.Viewport;
- public class PlayScreen implements Screen {
- private MouseGame game;
- private OrthographicCamera cam;
- private Viewport gameView;
- private TiledMap map;
- private OrthogonalTiledMapRenderer mapRenderer;
- public World world;
- public Box2DDebugRenderer debug;
- public PlayScreen(MouseGame game){
- this.game = game;
- cam = new OrthographicCamera();
- gameView = new FitViewport(game.V_WIDTH, game.V_HEIGHT, cam);
- // world = new World(new Vector2(0, 0), true);
- map = new TmxMapLoader().load("TestMap2.tmx");
- mapRenderer = new OrthogonalTiledMapRenderer(map);
- cam.position.set(gameView.getWorldWidth() / 2, gameView.getWorldHeight() / 2, 0);
- debug = new Box2DDebugRenderer();
- //BodyDef bdef = new BodyDef();
- // PolygonShape shape = new PolygonShape();
- //Fixture fdef = new FixtureDef();
- }
- public void handleInput(float dt){
- if (Gdx.input.isKeyPressed(Input.Keys.D)) cam.position.x += 150;
- }
- public void update(float dt){
- handleInput(dt);
- cam.update();
- mapRenderer.setView(cam);
- }
- @Override
- public void show() {
- }
- @Override
- public void render(float delta) {
- Gdx.gl.glClearColor(0, 0 ,0 ,1);
- Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
- mapRenderer.render();
- game.batch.setProjectionMatrix(cam.combined);
- }
- @Override
- public void resize(int width, int height) {
- gameView.update(width, height);
- }
- @Override
- public void pause() {
- }
- @Override
- public void resume() {
- }
- @Override
- public void hide() {
- }
- @Override
- public void dispose() {
- map.dispose();
- mapRenderer.dispose();
- }
- }
SHARE
TWEET
Untitled
a guest
Oct 24th, 2015
76
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

