Java LibGDX Series 2 / Draw

Discussion in 'Java' started by dag702, Mar 22, 2018.

  1. dag702

    dag702 New Member


    [​IMG]


    Introduction We have seen what LibGDX is in the

    first location,
    how it is set up, how to include it in the project, and some class, override functions.
    In this position, we will see the word draw, which is draw, which is the opposite of turkish. What do we draw on the screen? We will display text and images on the screen. In fact, let's not say to draw imageleri, say put. Let's put the images on the first screen.

    Code:
    SpriteBatch spbt;
    Texture txt;
    
    // Create
    spbt = new SpriteBatch ();
    txt = new Texture ("C: /Users/unknown/Desktop//ar-ge.jpg"); // Another new thing. What I need to create the image is the path to the Image file.
    
    
    public v0id render () {
        Gdx.gl.glClearColor (1, 1, 0, 1); // He asks us what color to clean the screen. More precisely, which color we want to paint. By the way, as RGB colors. It's a sarıyı that I wrote in the Constructor section.
        gdx.gl.glcle is (GL20.GL_COLOR_BUFFER_BIT);
    
        spbt.beg the (); // I Start.
        
        spbt.draw (txt, 70.80); // I drew Imagei 70 to 80.
    
        spbt.end (); // I terminated.
    
    }
    Do not forget to put the classes we created with this new in the create function. In the previous lesson we saw override functions. The render function had to do operations on each frame instantly. There was also a SpriteBatch,
    allowing us to create 2D batches. Now I draw the text on the screen. We need BitmapFont. New things ...

    Code:
    BitmapFont btmpfnt;
    SpriteBatch spbt;
    
    // Create
    btmpfnt = new BitmapFont ();
    spbt = new SpriteBatch ();
    
    // Render
    
        Gdx.gl.glClearColor (1, 1, 0, 1);
        gdx.gl.glcle is (GL20.GL_COLOR_BUFFER_BIT);
    
        spbt.beg the ();
    
        spbt.draw (btmpfnt, "R & D", 50,50); // We brought a 50-by-50 R & D article.
    
        spbt.end ();
    Dilerseniz create anine btmpfnt.setColor (Color.Rename); You can change the color by typing, for example Color.BLACK
    . Good forums ...
     

Share This Page