com.gamemaker.screens.AboutScreen.java Source code

Java tutorial

Introduction

Here is the source code for com.gamemaker.screens.AboutScreen.java

Source

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package com.gamemaker.screens;

import com.badlogic.gdx.Screen;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Rectangle;
import com.gamemaker.ERhelpers.AssetLoader;
import com.gamemaker.ERhelpers.Button;

/**
 * Created by wqc on 16/7/25.
 */
public class AboutScreen implements Screen {
    private Game game;
    protected BitmapFont font3;
    private ShapeRenderer shapeRenderer;
    private OrthographicCamera cam;
    private SpriteBatch batcher;//this is for drawing pictures for u
    private TextureRegion aboutText, backBtn_on, backBtn_off, menuBG;
    public Button backBtn;
    public float x, y, width, height;
    public Rectangle bounds;
    GlyphLayout layout = new GlyphLayout();

    public TextureRegion buttonUp;
    public TextureRegion buttonDown;

    public AboutScreen(Game game) {
        this.game = game;
        cam = new OrthographicCamera();
        cam.setToOrtho(true, 1280, 720);
        batcher = new SpriteBatch();
        batcher.setProjectionMatrix(cam.combined);
        shapeRenderer = new ShapeRenderer();
        shapeRenderer.setProjectionMatrix(cam.combined);
        backBtn_on = AssetLoader.backBtn_on;
        backBtn_off = AssetLoader.backBtn_off;
        menuBG = AssetLoader.mapBg;
        // aboutText = AssetLoader.aboutText;
        font3 = new BitmapFont(Gdx.files.internal("font/numFont.fnt"));
        font3.getData().setScale(1f, -1f);

        backBtn = new Button(100, 100, 190, 190, backBtn_on, backBtn_off);
    }

    @Override
    public void show() {

    }

    public void update(float deltaTime) {
        //        if (Gdx.input.justTouched()){
        //            game.setScreen(new IntroScreen(game));
        //        }
    }

    public void draw(float deltaTime) {
        Gdx.gl.glClearColor(0, 0, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
        batcher.begin();
        //batcher.disableBlending()
        batcher.draw(menuBG, 0, 0, 1280, 720);
        layout.setText(font3, "COPYRIGHT   2016 EndlessRunner Tjinari ");
        font3.draw(batcher, layout, 300, 120);
        layout.setText(font3, "All rights reserved ");
        font3.draw(batcher, layout, 300, 220);
        layout.setText(font3, "Programming team: Jixuan Cao; Qiancheng Wang; Shuaichen Song; Jaimou Sun ");
        font3.draw(batcher, layout, 150, 320);
        layout.setText(font3, "Artist: Conor Tow");
        font3.draw(batcher, layout, 300, 420);
        layout.setText(font3, "Bands:  ");
        font3.draw(batcher, layout, 300, 520);
        //batcher.draw(menuTitle1,295,100,650,150);
        //batcher.draw(menuStart,520,340,200,200);
        //batcher.draw(menuTitle2,500,400,230,75);//half size of original image

        drawButton();
        batcher.end();
    }

    public void drawButton() {
        backBtn.isTouchDown(Gdx.input.getX(), Gdx.input.getY());

        if (backBtn.getIsPressed()) {
            batcher.draw(backBtn.buttonDown, backBtn.x, backBtn.y, backBtn.width, backBtn.height);
            if (Gdx.input.justTouched()) {
                game.setScreen(new MenuScreen(game));
            }
        } else {
            batcher.draw(backBtn.buttonUp, backBtn.x, backBtn.y, backBtn.width, backBtn.height);
        }

        backBtn.isTouchUp(Gdx.input.getX(), Gdx.input.getY());

    }

    @Override
    public void render(float delta) {
        update(delta);
        draw(delta);
    }

    @Override
    public void resize(int width, int height) {

    }

    @Override
    public void pause() {

    }

    @Override
    public void resume() {

    }

    @Override
    public void hide() {

    }

    @Override
    public void dispose() {

    }

}