Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.badlogic.gdx.ApplicationAdapter;
- import com.badlogic.gdx.Gdx;
- import com.badlogic.gdx.audio.Music;
- import com.badlogic.gdx.graphics.Texture;
- import com.badlogic.gdx.graphics.g2d.Sprite;
- import com.badlogic.gdx.graphics.g2d.SpriteBatch;
- import android.app.Activity;
- import android.os.Bundle;
- import android.os.Handler;
- import android.os.SystemClock;
- public class Sound extends ApplicationAdapter {
- private Texture img;
- private Texture backgroundTexture;
- private Sprite imgSprite;
- private SpriteBatch spriteBatch;
- Music music;
- private float rotationAngle=0;
- private int timecheck=0;
- @Override
- public void create () {
- img = new Texture("Slipknot_Psychosocial_vinyl.png");
- backgroundTexture = new Texture("image.jpg");
- spriteBatch=new SpriteBatch(Gdx.graphics.getWidth());
- imgSprite=new Sprite(img);
- music=Gdx.audio.newMusic(Gdx.files.internal("Slipknot - Left Behind OFFICIAL VIDEO.mp3"));
- imgSprite.setSize(360,360);
- }
- @Override
- public void render () {
- spriteBatch.begin();
- spriteBatch.draw(backgroundTexture,0,0,Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
- imgSprite.setPosition(Gdx.graphics.getWidth()/2 - img.getWidth()/2,Gdx.graphics.getHeight()/2 - img.getHeight()/2);
- if(getTouch()){
- imgSprite.rotate(5);
- rotationAngle+=5;
- music.play();
- if(rotationAngle>360) {rotationAngle=0;}
- SystemClock.sleep(1);
- }
- imgSprite.draw(spriteBatch);
- System.out.println(rotationAngle);
- SystemClock.sleep(5);
- System.out.println(img.getWidth()+" "+img.getHeight());
- timecheck+=5;
- if(timecheck>300){
- music.pause();
- timecheck=0;
- }
- spriteBatch.end();
- }
- @Override
- public void dispose () {
- spriteBatch.dispose();
- img.dispose();
- backgroundTexture.dispose();
- music.dispose();
- }
- private boolean getTouch() {
- return Gdx.input.isTouched();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement