libgdxpixmap

LibGDX pixmap methods does not exist


I am using LibGDX to create a game. I am using Pixmap and I want to use its method .setColor. But its not working. The IDE shows that no instance found of 'setColor()' whereas when I saw the official documentation of LibGDX, it shows that Pixmap has a method called setColor.


Solution

  • Depends what you mean by setColor. There is a setColor function, but it just sets a default color for future drawing operations to the pixmap, such as drawLine(). If you want to set a pixel to a specific color in the pixmap you can use drawPixel(int x, int y, int color)

    Your IDE should show the function though, just make sure you are trying to access it via a pixmap instance. ie.

    Pixmap mypixmap=new Pixmap(100, 100 , Format.RGB888);
    mypixmap.setColor(1,1,1,1); //r,g,b,a
    mypixmap.drawLine(0,0,100,100);
    

    Check out the Pixmap documentation