Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
lightweight way to use same TNTanimation applying different color transformations? — Gideros Forum

lightweight way to use same TNTanimation applying different color transformations?

piepie Member
edited September 2014 in General questions
Hi,
I have different enemies on my map, they are instances of a sprite containing a TNTAnimation object based on the same texturepack, and as a consequence, they all wear the same t-shirt.. ;)

I'd like to randomly choose a color for the t-shirts when they're added to stage:

I did it "the beast way", adding a second layer of animation (synchronized via eventlistener to the "main animation") so that in every instance of my enemy I have 2 layers containing:

1) TNTanimation object based on texturepack1 with enemy bodies/frames = main animation
2) TNTanimation object based on texturepack2 (overlapped with previous layer) with just the t-shirt = additional animation on which I apply random color transformation.

Either if I kept my additional animation layer local, I have doubled the texturepack and doubled the animation (not to mention 1 more event listener) for every instance of enemy , and this have a cost in performance (I thought worse, but it adds up to all my other not optimized code :-$ and affects performance on slower devices).

Do you think there is a "smarter"/lighter way to achieve the same result?
(I am still working on my other code optimization though)

Thank you in advance,

P.

Comments

  • @pie sure this should be a viable solution. You would need to make your TShirt white and then provide setColorTransform to the Sprite with values from 0 to 1, where 1 is a full channel.

    But..
    Since you are using TNT Animation, you would need to see the source, how you can get the Sprite object, which is displaying the TShirt (most probably it is Mesh object to speed up animation), I think the method was called :getSpriteHandle()
  • Unfortunately I don't have such knowledge, I achieved that inserting the t-shirt animation inside a sprite, on which I apply the color transformation . :)

    I am looking for a smarter way to do that because every cTNTAnimator object comes with its own texturepack and cTNTstuff, and I fear that doubling animator calls is not the best option.

    I was wondering if I could set some "chromakey-color" on my textures, and then switch it on the run with a different color. Could this be possible?

    thank you
  • @pie I don't really know your project, but do you animate Tshirt also?
  • piepie Member
    edited September 2014
    of course I do, on a separate ctntanimator object (the t-shirt is different in every frame since the guy is moving, spawning, ecc) :)
  • ar2rsawseenar2rsawseen Maintainer
    Accepted Answer
    hmm, then no, unfortunately I don't see a better way for now.
    It is same as skeleton animation. Each part is animated separately, so I don't think it is so bad.
    And it is much better then using separate graphic for each tshirt :)
Sign In or Register to comment.