Java tutorial
/* * 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.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.gamemaker.ERhelpers.AssetLoader; /** * Created by robertcao on 8/09/2016. */ public class IntroScreen implements Screen { private Game game; private ShapeRenderer shapeRenderer; private OrthographicCamera cam; private SpriteBatch batcher;//this is for drawing pictures for u private TextureRegion introText, mapBg; public IntroScreen(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); introText = AssetLoader.introText; mapBg = AssetLoader.mapBg; } @Override public void show() { } public void update(float deltaTime) { int[] data = { 0, 0, 0, 0, 0 }; AssetLoader.story.play(); if (Gdx.input.justTouched()) { game.setScreen(new HowtoplayScreen(game)); AssetLoader.story.stop(); } } 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(mapBg, 0, 0, 1280, 720); batcher.draw(introText, 0, 0, 1280, 720); batcher.end(); } @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() { } }