Created
September 22, 2018 21:02
-
-
Save implicit-invocation/505971ab0a66418a570c25ccb8008ba2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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.mygdx.game; | |
import com.badlogic.gdx.ApplicationAdapter; | |
import com.badlogic.gdx.Gdx; | |
import com.badlogic.gdx.graphics.Color; | |
import com.badlogic.gdx.graphics.GL20; | |
import com.badlogic.gdx.graphics.Texture; | |
import com.badlogic.gdx.graphics.g2d.Sprite; | |
import com.badlogic.gdx.graphics.g2d.SpriteBatch; | |
import com.badlogic.gdx.graphics.g2d.TextureAtlas; | |
import com.badlogic.gdx.utils.TimeUtils; | |
public class MyGdxGame extends ApplicationAdapter { | |
SpriteBatch batch; | |
private Sprite trimmedSprite; | |
private Sprite sprite; | |
@Override | |
public void create() { | |
batch = new SpriteBatch(); | |
TextureAtlas textureAtlas = new TextureAtlas("test.atlas"); | |
trimmedSprite = textureAtlas.createSprite("charge0001"); | |
sprite = new Sprite(new Texture("charge0001.png")); | |
sprite.setOriginCenter(); | |
trimmedSprite.setColor(Color.RED); | |
sprite.setColor(Color.BLUE); | |
} | |
int rotation = 0; | |
@Override | |
public void render() { | |
Gdx.gl.glClearColor(0, 0, 0, 1); | |
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); | |
rotation += 1; | |
batch.begin(); | |
sprite.setRotation(rotation); | |
trimmedSprite.setRotation(rotation); | |
trimmedSprite.draw(batch); | |
if ((TimeUtils.millis() / 1000) % 2 == 0) { | |
sprite.draw(batch); | |
} | |
batch.end(); | |
} | |
@Override | |
public void dispose() { | |
batch.dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment