CERCA
PER MODELLO
FullScreen Chatbox! :)

Utente del giorno: con ben Thanks ricevuti nelle ultime 24 ore
Utente della settimana: megthebest con ben 6 Thanks ricevuti negli ultimi sette giorni
Utente del mese: megthebest con ben 17 Thanks ricevuti nell'ultimo mese

Visualizzazione dei risultati da 1 a 1 su 1
Discussione:

collegamento in un altra activity con libgdx

Se questa discussione ti è stata utile, ti preghiamo di lasciare un messaggio di feedback in modo che possa essere preziosa in futuro anche per altri utenti come te!
  1. #1
    Androidiano


    Registrato dal
    Dec 2014
    Messaggi
    56

    Ringraziamenti
    5
    Ringraziato 1 volta in 1 Post
    Predefinito

    collegamento in un altra activity con libgdx

    ho problemi a collegarmi all'altra activity ecco il codice... l'altra activity si chiama play
     
    1
    2
    import com.badlogic.gdx.ApplicationAdapter;
    3
    import com.badlogic.gdx.Game;
    4
    import com.badlogic.gdx.Gdx;
    5
    import com.badlogic.gdx.graphics.GL20;
    6
    import com.badlogic.gdx.graphics.OrthographicCamera;
    7
    import com.badlogic.gdx.graphics.g2d.BitmapFont;
    8
    import com.badlogic.gdx.graphics.g2d.SpriteBatch;
    9
    import com.badlogic.gdx.graphics.g2d.TextureAtlas;
    10
    import com.badlogic.gdx.scenes.scene2d.InputEvent;
    11
    import com.badlogic.gdx.scenes.scene2d.InputListener;
    12
    import com.badlogic.gdx.scenes.scene2d.Stage;
    13
    import com.badlogic.gdx.scenes.scene2d.ui.Skin;
    14
    import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
    15
    import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle;
    16
    17
    18
    public class button extends ApplicationAdapter{
    19
        
    20
        
    21
            private OrthographicCamera camera;
    22
            private SpriteBatch batch;
    23
            private Stage stage; //** stage holds the Button **//
    24
            private BitmapFont font; //** same as that used in Tut 7 **//
    25
            private TextureAtlas buttonsAtlas; //** image of buttons **//
    26
            private Skin buttonSkin; //** images are used as skins of the button **//
    27
            private TextButton button; //** the button - the only actor in program **//
    28
            
    29
            
    30
            
    31
         @<a rel="nofollow" href="https://www.androidiani.com/forum/members/override.html" target="_blank">Override</a>
    32
            public void create() {
    33
                
    34
            camera = new OrthographicCamera();
    35
            camera.setToOrtho(false, 800, 480); //** w/h ratio = 1.66 **//
    36
            batch = new SpriteBatch();
    37
            buttonsAtlas = new TextureAtlas("ui/button.pack"); //** button atlas image **//
    38
            buttonSkin = new Skin();
    39
            buttonSkin.addRegions(buttonsAtlas); //** skins for on and off **//
    40
            font = new BitmapFont(Gdx.files.internal("font/white32.fnt"),false); 
    41
            stage = new Stage(); //** window is stage **//
    42
            stage.clear();
    43
            Gdx.input.setInputProcessor(stage); //** stage is responsive **//
    44
            TextButtonStyle style = new TextButtonStyle(); //** Button properties **//
    45
            style.up = buttonSkin.getDrawable("button.down.9.png");
    46
            style.down = buttonSkin.getDrawable("button.up.9.png");
    47
            style.font = font;
    48
            button = new TextButton("", style); //** Button text and style **//
    49
            button.setPosition(200, 100); //** Button location **//
    50
            button.setHeight(100); //** Button Height **//
    51
            button.setWidth(200); //** Button Width **//
    52
            
    53
            button.addListener(new InputListener() {
    54
                public boolean touchDown (InputEvent event, float x, float y, int pointer, int button)
    55
                {
    56
                Gdx.app.log("my app", "Coin Pressed");
    57
                
    58
                return true;
    59
                }
    60
                public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
    61
                Gdx.app.log("my app", "Coin Released");
    62
                ((Game) Gdx.app.getApplicationListener()).setScreen(new play());
    63
                }
    64
                });
    65
            
    66
        stage.addActor(button);
    67
            
    68
            }
    69
            
    70
         @<a rel="nofollow" href="https://www.androidiani.com/forum/members/override.html" target="_blank">Override</a>
    71
            public void dispose() {
    72
            batch.dispose();
    73
            buttonSkin.dispose();
    74
            buttonsAtlas.dispose();
    75
            font.dispose();
    76
            stage.dispose();
    77
            
    78
            
    79
            
    80
            }
    81
            
    82
         @<a rel="nofollow" href="https://www.androidiani.com/forum/members/override.html" target="_blank">Override</a>
    83
            public void render() {
    84
                Gdx.gl.glClearColor(1, 1, 1, 1);
    85
                Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    86
                stage.act();
    87
                batch.setProjectionMatrix(camera.combined);
    88
                batch.begin();
    89
                stage.draw();
    90
                batch.end();
    91
                
    92
            }
    93
            
    94
            
    95
         @<a rel="nofollow" href="https://www.androidiani.com/forum/members/override.html" target="_blank">Override</a>
    96
            public void resize(int width, int height) {
    97
                }
    98
         @<a rel="nofollow" href="https://www.androidiani.com/forum/members/override.html" target="_blank">Override</a>
    99
            public void pause() {
    100
            }
    101
         @<a rel="nofollow" href="https://www.androidiani.com/forum/members/override.html" target="_blank">Override</a>
    102
            public void resume() {
    103
                
    104
            }
    105
            
    106
            
    107
            }
    108
    109


    aiutatemi VI PREGO RISPONDETE IN TANTI AL Più PRESTO!!!!!!! grazie a tutti

  2.  

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire risposte
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Torna su
Privacy Policy