Hello Guest

Author Topic: Changing Sprite Color  (Read 5351 times)

Thyran

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Changing Sprite Color
« on: August 23, 2014, 05:45:08 pm »
Hey,

I know this is a painfully noob question, but I am not super graphically inclined. I created an image with a black circle and a transparent background, saved as .png, and imported into my Unity project. I created a tk2dsprite object. When I go to change the sprite's color, the circle stays black no matter what color I set. When I change the transparency, it does fade out/in properly, just the colors have no effect on the circle.

How do I make it so I can change the color of the circle when I change the color setting in the sprite editor? Not sure if I'm doing something wrong in Unity or when I created the image file.

Also, a less important question, but the mesh triangles fit perfectly around the circle. However, there is some excess transparent background in the image because the white box that surrounds the circle in the scene editor is much bigger than the triangles. Is there a way to trim the excess space?

Thanks!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Changing Sprite Color
« Reply #1 on: August 23, 2014, 07:22:01 pm »
The shader in tk2d is multiplicative, which means that tinting an object will make it darker and never brighter. If you start off with a white circle, you'll be able to tint it to any color you like, including black.

tk2d automatically trims excess space in the atlas, unless you've turned the feature off.

Thyran

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Changing Sprite Color
« Reply #2 on: August 24, 2014, 07:28:40 pm »
Thank you so much :) Awesome toolkit by the way, just downloaded it and love it!

Thyran

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Changing Sprite Color
« Reply #3 on: September 26, 2014, 04:03:52 pm »
I've noticed the tk2d automatically trimming the excess blank space like you indicated, but I'm running into a problem with some positioning due to that extra space.

My artist is giving me sprite sheets for each animation (each sheet containing all the frames in that animation). For the idle animation for this character, each sprite in the sheet is 151x178. For the attack animation, each sprite in the sheet is 328x246. The sprite character itself is the same size, but he is swinging a massive sword in the attack animation, so the entire box needs to be 328x246 to encapsulate everything. I know I could make the sword itself a separate animation, but still the characters arm movement would require a box bigger than 151x178.

So when I switch animations, the sprite jumps a bit on screen because of the sprite's position relative to its box. Is there any way to easily accomplish smoothing out those transitions other than adjusting the sprite's position each time the animation clip changes? Or should I just get a sprite sheet with each sprite in a box big enough for the biggest animation?

It seems like there would be a lot of "wasted space" by putting a sprite in a box 3x the size, but I can't really think of any other way. So just looking to see what the "best practice" is for this type of scenario.

Thanks!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Changing Sprite Color
« Reply #4 on: September 26, 2014, 09:31:04 pm »
Quote
Or should I just get a sprite sheet with each sprite in a box big enough for the biggest animation?
This is what we have done in the past. It all gets trimmed out anyway, so makes no difference to the end result.