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
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()
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
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