I want to implement the ability for people to change the way players characters look, and by that I mean that I want to give the players the ability to change the colors of their given hero. Which is an png. The only problem is that I need the image as a sprite to make use of LibGDX's flip and scale functions to the nearest pixel, so I retain that awesome pixel-y look. No methods, not even Pixmap, are giving me what I need. I thought about taking a BufferedImage, saving the data, writing the data as a new player png (Which I may have to do so I dont keep loading in the same stupid thing and messing up) and then just assigning that to the player. But what if the player makes 10's or hundreds of characters? I would have 10's of hundreds of .pngs of different heroes my player would probably not use. I also noticed that when Notch made Minicraft for LD22 a long time ago, he performed exactly what I would like to do!

My question is, with LibGDX's given library, is there a way I could copy Notch's Minicraft attempt at saving the images as grayscale, and just applying colors at runtime?

My question is, with LibGDX's given library, is there a way I could copy Notch's Minicraft attempt at saving the images as grayscale, and just applying colors at runtime?

Are you using a SpriteBatch to render your characters? If you simply to batch.setColor(color) the texture you render after that will be tinted in the color you specify. Thats what I use for these kinds of customizations, works like a charm.

One trick (that I never used, but it should work) is to render your characters to the screen (without swapping the buffers so nothing is shown) and then copying the rendered character to a Texture e.g. using the ScreenUtils methods.

Could you do something along the lines of:• Load an image as a BufferedImage (RGBA)• Loop through its pixel data• Each Integer value that has an RGBA can be replaced with an RGBA of the custom colour.• Store this image as the player sprite.

Its in Java2D, and its also 100% officially silly to try to do this in OpenGL and LibGDX. It is extremely slow, error-prone, terribly overcomplicated and pretty much worst practice (unless you enjoy making life difficult for yourself). Much better do someting like:

Thanks Grunnt, but I wasnt saying I wanted to use Java2D with my current LibGDX setup, I was simply asking if there was a possible way to get it going. I would use a tint, but the tint does not give me the same look I was going for. Tint gives me some crazy dark colors, and I can only go so far with some things.

I'll take a look at it again, and If I run into more trouble, I'll post my code after work.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org