Example usage for com.badlogic.gdx.graphics.g2d SpriteBatch SpriteBatch

List of usage examples for com.badlogic.gdx.graphics.g2d SpriteBatch SpriteBatch

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics.g2d SpriteBatch SpriteBatch.

Prototype

public SpriteBatch() 

Source Link

Document

Constructs a new SpriteBatch with a size of 1000, one buffer, and the default shader.

Usage

From source file:Tabox2D.java

License:Open Source License

private Tabox2D(Vector2 gravity) {
    width = Gdx.graphics.getWidth();/*from  w ww  .  j  a v  a 2  s.c o  m*/
    height = Gdx.graphics.getHeight();
    meterSize = 100;// 1 metter = 100px, default.
    polyInfo = new HashMap<String, Float>();
    rawForces = false;

    // Sides by polygon:
    polyInfo.put("triangle", 3f);
    polyInfo.put("square", 4f);
    polyInfo.put("pentagon", 5f);
    polyInfo.put("hexagon", 6f);
    polyInfo.put("heptagon", 7f);
    polyInfo.put("octagon", 8f);

    // Angle of the sides:
    polyInfo.put("triangle_angle", 120f);
    polyInfo.put("square_angle", 90f);
    polyInfo.put("pentagon_angle", 72f);
    polyInfo.put("hexagon_angle", 60f);
    polyInfo.put("heptagon_angle", 51.428f);
    polyInfo.put("octagon_angle", 45f);

    filterMin = "linear";
    filterMag = "linear";

    renderer = new Box2DDebugRenderer();
    sr = new ShapeRenderer();
    spriteBath = new SpriteBatch();
    adjustCamera();
    tabodies = new ArrayList<Tabody>();
    world = new World(new Vector2(gravity.x, gravity.y), true);

    sr = new ShapeRenderer();
}

From source file:app.badlogicgames.superjumper.GameScreen.java

License:Apache License

public GameScreen(Game game) {
    this.game = game;

    state = GAME_READY;//  ww w  .j a v a  2s  .c o  m
    guiCam = new OrthographicCamera(320, 480);
    guiCam.position.set(320 / 2, 480 / 2, 0);
    touchPoint = new Vector3();
    batcher = new SpriteBatch();
    worldListener = new WorldListener() {
        @Override
        public void jump() {
            Assets.playSound(Assets.jumpSound);
        }

        @Override
        public void highJump() {
            Assets.playSound(Assets.highJumpSound);
        }

        @Override
        public void hit() {
            Assets.playSound(Assets.hitSound);
        }

        @Override
        public void coin() {
            Assets.playSound(Assets.coinSound);
        }
    };
    world = new World(worldListener);
    renderer = new WorldRenderer(batcher, world);
    pauseBounds = new Rectangle(320 - 64, 480 - 64, 64, 64);
    resumeBounds = new Rectangle(160 - 96, 240, 192, 36);
    quitBounds = new Rectangle(160 - 96, 240 - 36, 192, 36);
    lastScore = 0;
    scoreString = "SCORE: 0";
}

From source file:app.badlogicgames.superjumper.HelpScreen.java

License:Apache License

public HelpScreen(Game game) {
    this.game = game;

    guiCam = new OrthographicCamera(320, 480);
    guiCam.position.set(320 / 2, 480 / 2, 0);
    nextBounds = new Rectangle(320 - 64, 0, 64, 64);
    touchPoint = new Vector3();
    batcher = new SpriteBatch();
    helpImage = Assets.loadTexture("data/help1.png");
    helpRegion = new TextureRegion(helpImage, 0, 0, 320, 480);
}

From source file:app.badlogicgames.superjumper.HelpScreen2.java

License:Apache License

public HelpScreen2(Game game) {
    this.game = game;

    guiCam = new OrthographicCamera(320, 480);
    guiCam.position.set(320 / 2, 480 / 2, 0);
    nextBounds = new Rectangle(320 - 64, 0, 64, 64);
    touchPoint = new Vector3();
    batcher = new SpriteBatch();
    helpImage = Assets.loadTexture("data/help2.png");
    helpRegion = new TextureRegion(helpImage, 0, 0, 320, 480);
}

From source file:app.badlogicgames.superjumper.HelpScreen3.java

License:Apache License

public HelpScreen3(Game game) {
    this.game = game;

    guiCam = new OrthographicCamera(320, 480);
    guiCam.position.set(320 / 2, 480 / 2, 0);
    nextBounds = new Rectangle(320 - 64, 0, 64, 64);
    touchPoint = new Vector3();
    batcher = new SpriteBatch();
    helpImage = Assets.loadTexture("data/help3.png");
    helpRegion = new TextureRegion(helpImage, 0, 0, 320, 480);
}

From source file:app.badlogicgames.superjumper.HelpScreen4.java

License:Apache License

public HelpScreen4(Game game) {
    this.game = game;

    guiCam = new OrthographicCamera(320, 480);
    guiCam.position.set(320 / 2, 480 / 2, 0);
    nextBounds = new Rectangle(320 - 64, 0, 64, 64);
    touchPoint = new Vector3();
    batcher = new SpriteBatch();
    helpImage = Assets.loadTexture("data/help4.png");
    helpRegion = new TextureRegion(helpImage, 0, 0, 320, 480);
}

From source file:app.badlogicgames.superjumper.HelpScreen5.java

License:Apache License

public HelpScreen5(Game game) {
    this.game = game;

    guiCam = new OrthographicCamera(320, 480);
    guiCam.position.set(320 / 2, 480 / 2, 0);
    nextBounds = new Rectangle(320 - 64, 0, 64, 64);
    touchPoint = new Vector3();
    batcher = new SpriteBatch();
    helpImage = Assets.loadTexture("data/help5.png");
    helpRegion = new TextureRegion(helpImage, 0, 0, 320, 480);
}

From source file:app.badlogicgames.superjumper.HighscoresScreen.java

License:Apache License

public HighscoresScreen(Game game) {
    this.game = game;

    guiCam = new OrthographicCamera(320, 480);
    guiCam.position.set(320 / 2, 480 / 2, 0);
    backBounds = new Rectangle(0, 0, 64, 64);
    touchPoint = new Vector3();
    batcher = new SpriteBatch();
    highScores = new String[5];
    for (int i = 0; i < 5; i++) {
        highScores[i] = i + 1 + ". " + Settings.highscores[i];
        xOffset = Math.max(Assets.font.getBounds(highScores[i]).width, xOffset);
    }/*from  w  ww . j  a  v a 2 s .  c o m*/
    xOffset = 160 - xOffset / 2 + Assets.font.getSpaceWidth() / 2;
}

From source file:app.badlogicgames.superjumper.MainMenuScreen.java

License:Apache License

public MainMenuScreen(Game game) {
    this.game = game;

    guiCam = new OrthographicCamera(320, 480);
    guiCam.position.set(320 / 2, 480 / 2, 0);
    batcher = new SpriteBatch();
    soundBounds = new Rectangle(0, 0, 64, 64);
    playBounds = new Rectangle(160 - 150, 200 + 18, 300, 36);
    highscoresBounds = new Rectangle(160 - 150, 200 - 18, 300, 36);
    helpBounds = new Rectangle(160 - 150, 200 - 18 - 36, 300, 36);
    multiplayerBounds = new Rectangle(160 - 64, 100, 128, 32);
    touchPoint = new Vector3();
}

From source file:app.badlogicgames.superjumper.multiplayer.MultiplayerGameScreen.java

License:Apache License

public MultiplayerGameScreen(Game game, StartMultiplayerScreen prevScreen) {
    this.game = game;
    this.prevScreen = prevScreen;
    state = GAME_RUNNING;/*  ww w . jav  a 2 s.  c o  m*/
    guiCam = new OrthographicCamera(320, 480);
    guiCam.position.set(320 / 2, 480 / 2, 0);
    touchPoint = new Vector3();
    batcher = new SpriteBatch();
    worldListener = new WorldListener() {
        @Override
        public void jump() {
            Assets.playSound(Assets.jumpSound);
        }

        @Override
        public void highJump() {
            Assets.playSound(Assets.highJumpSound);
        }

        @Override
        public void hit() {
            Assets.playSound(Assets.hitSound);
        }

        @Override
        public void coin() {
            Assets.playSound(Assets.coinSound);
        }
    };
    world = new World(worldListener);
    renderer = new WorldRenderer(batcher, world);
    pauseBounds = new Rectangle(320 - 64, 480 - 64, 64, 64);
    resumeBounds = new Rectangle(160 - 96, 240, 192, 36);
    quitBounds = new Rectangle(160 - 96, 240 - 36, 192, 36);
    lastScore = 0;
    scoreString = "SCORE: 0";
    WarpController.getInstance().setListener(this);
}