Posted by : Unknown Kamis, 17 Januari 2019

import com.badlogic.gdx.*;
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.graphics.g2d.*;
import com.badlogic.gdx.scenes.scene2d.*;
import com.badlogic.gdx.scenes.scene2d.utils.*;
import com.badlogic.gdx.scenes.scene2d.ui.*;
import com.badlogic.gdx.utils.viewport.*;
import com.badlogic.gdx.audio.*;

public class MyGdxGame implements ApplicationListener{
Music m;
private Stage stage,stage2;
    private Texture myTexture,tex2;
    private TextureRegion myTextureRegion,reg2;
    private TextureRegionDrawable myTexRegionDrawable,draw2;
    private ImageButton button,button2;

    @Override
    public void create(){  
m =Gdx.audio.newMusic(Gdx.files.internal("ms.mp3"));
tombol1();
tombol2();
    Gdx.input.setInputProcessor(new InputMultiplexer(stage,stage2));}
   
@Override
    public void render(){
renderTombol1();
renderTombol2();}

///////////////////TOMBOL SATU////////////////////////////////
public void tombol1(){
myTexture = new Texture(Gdx.files.internal("android.jpg"));
        myTextureRegion = new TextureRegion(myTexture,0,0,100,100);
        myTexRegionDrawable = new TextureRegionDrawable(myTextureRegion);
        button = new ImageButton(myTexRegionDrawable); //Set the button up
        stage = new Stage(new ScreenViewport()); //Set up a stage for the ui
stage.addActor(button); }
public void renderTombol1(){
stage2.act(Gdx.graphics.getDeltaTime()); //Perform ui logic
        stage2.draw(); //Draw the ui
button2.addListener(new EventListener(){
@Override
public boolean handle(Event event){
m.stop();
return false;}});}
////////////////////TOMBOL DUA///////////////////////////////////////
public void tombol2(){
tex2 = new Texture(Gdx.files.internal("android.jpg"));
        reg2= new TextureRegion(tex2,50,0,100,100);
        draw2 = new TextureRegionDrawable(reg2);
        button2 = new ImageButton(draw2); //Set the button up
        button2.setPosition(300,0);
stage2 = new Stage(new ScreenViewport()); //Set up a stage for the ui
        stage2.addActor(button2); }
public void renderTombol2(){
stage.act(Gdx.graphics.getDeltaTime()); //Perform ui logic
stage.draw(); //Draw the ui
button.addListener(new EventListener(){
@Override
public boolean handle(Event even)
    {m.play(); return false;}});
}
//////////////////////////////////////////////////////////////////////
@Override
public void resize(int p1, int p2){}
@Override
public void pause(){}
@Override
public void resume(){}
@Override
public void dispose(){}
}

Leave a Reply

Subscribe to Posts | Subscribe to Comments

- Copyright © BLOG GUE WANGI - Blogger Templates - Powered by Blogger - Designed by Johanes Djogan -