How do I dynamically color sprites

Get help using Construct 2

Post » Sat Sep 20, 2014 12:31 am

Some time back I was tinkering with a custom character maker and needed to do the same thing as you when trying to dynamical change color. Here is my solution, One make a gray scale sprite that will be your base as starting with a colored sprite will make tuning the HSL difficult. Next make a variable called ColorTyp set to zero and also add the Adjust HSL Effect to your sprite.

In your events make a every tick block and place a number of sub branch's below that. Using the system compare pram set it for if ColorType=0, =1, =2 etc. the actions of each of those branch's you will use the "set effect "AdjustHSL" pram 0 to (Number)" repeat for pram 1 and 2.

Having done that and adjusted the 3 parameters for the sprites HSL effect all you have to then do is change that ColorTyp var to dynamically change the sprite.

But again you would have to do this on a sprite by sprite bases but have you looked into containers? if you put all the sprites into a container that should cut down of the cost of having all these sprites
<><><>example
Every Tick | ___________
ColorTyp=0 | Effect Adjust HSL param 0 to 50| Effect Adjust HSL param 1 to 50| Effect Adjust HSL param 2 to 50
ColorTyp=1 | Effect Adjust HSL param 0 to 10| Effect Adjust HSL param 1 to 75| Effect Adjust HSL param 2 to 50
ColorTyp=2 | Effect Adjust HSL param 0 to 100| Effect Adjust HSL param 1 to 25| Effect Adjust HSL param 2 to 80
"Were all mad here. I'm mad, your mad." "How do you know I'm mad?" Asked Alice. "You must be" Said the Cheshire Cat. "Or you wouldn't have come here"-Lewis Carroll: Adventures In Wonderland
B
7
S
2
Posts: 113
Reputation: 1,245

Post » Sat Sep 20, 2014 2:58 am

I disagree. the example that I used with the five frame coin is just that one example. What if somebody in here was writing the next World of Warcraft. When you start thinking of backpacks potions armor horses whatever it's a lot easier to render the sprite in parts and in grayscale and then apply a color filter then you have a smaller footprint but it also allows you to have a lot more possibilities visually.

this really should be a feature request. I'm actually kind of surprised considering how will the c2 engine is designed. it should be added to the image class. C2 is an awesome engine there's no reason to limit it.
[b]Andrew Donelson[b]
I2TM Labs
https://i2tmlabs.com/
[email protected]
B
15
S
3
Posts: 66
Reputation: 1,136

Post » Sat Sep 27, 2014 2:19 am

I achieved the desired effect using WebGL replaceColor. But no one has had any insight as to whether this is a practical for mobile devices or not. Namely because so many sprites would be using webGL, + it adds 5+ sprites per character which could be made up of one single sprite (just more of them)

@CrazyVulcan
Every character would be made up of about 5+ sprites, are you suggesting containers merge them together somehow into a single object to save space? Also I'm watching your random character generation post, I hope you figure it out as it also interests me.
B
10
S
2
Posts: 80
Reputation: 995

Previous

Return to How do I....?

Who is online

Users browsing this forum: Fradno, Shenkai the ssj and 27 guests