Couldn't find this anywhere on the forum...

For questions about using Classic.

Post » Thu Feb 17, 2011 7:53 am

First off, I'd like to apologize if I'm just plain missing this somewhere else on the forum, but I've been looking for an hour and have had no luck.

I've got a very basic day/night cycle in a project of mine, as well as a random chance of "rain" at the start of each day. I'm portraying the changes in time by using the "set color filter" on all of my tiles, but here's the thing, I want to be able to tell construct to fade between the filters...how do I do this?

I want to be able to pick a point in my day/night cycle, and have construct change the color filter gradually over time so that it hits the final filter setting at the time in the cycle that I want it to.

Thank you in advance...
B
64
S
8
G
9
Posts: 290
Reputation: 8,590

Post » Thu Feb 17, 2011 8:07 am

If you right click on the part that lets you set the color you will get a context menu asking "use expression.
You can click that, and in the in the box put the expression rgb(r,g,b) with the r,g,and b in parenthesis set to your color.
After that you'll need a counter something like:
rgb(r+variable,g+variable,b+variable)
>add 1 to variable
You'll want to add to the values as rgb(255,255,255) equals white, and rgb(0,0,0) equals black.
Image Image
B
161
S
48
G
90
Posts: 7,351
Reputation: 66,757

Post » Thu Feb 17, 2011 8:12 am

what about if its not a straight fade with gray, right now I'm using slightly tinted filters, over cast is a straight gray and night is a blue gray, and is there anyway to set it up using timedelta maybe? I know ABOUT timedelta, but I really have no idea how to use it
B
64
S
8
G
9
Posts: 290
Reputation: 8,590

Post » Thu Feb 17, 2011 8:16 am

Filter on all tiles ? Isn't it better to just fill the viewable area with a tiledbackground (you can paint a 1-2px width gradient as texture)? Then you just have to change it's opacity with a function, like :
[code:2kt3afzb]+ Function: On function "FadeOut"
+ System: Repeat 100 times
+ System: Is global variable 'Opac' Less than 100
-> Wait: Delay 10 ms
-> System: Add 1 to global variable 'Opac'
-> TiledBackground: Set opacity to global('Opac')[/code:2kt3afzb]

Well, something like that anyway, i guess. :roll:
B
4
S
1
G
2
Posts: 91
Reputation: 1,057

Post » Thu Feb 17, 2011 8:18 am

I'm using the filters because it allows me more control over the colors as well as it seems to appear to maintain more of the detail in the tiles than an overlay does, might just be my eyes playing tricks on me, it just seems that way.
B
64
S
8
G
9
Posts: 290
Reputation: 8,590

Post » Thu Feb 17, 2011 8:22 am

Well you dont have to set all colors at the same time, but to set them separately you'll need multiple variables.
rgb(lerp(r+variablea,255,1-0.5^timedelta),lerp(g+variableb,255,1-0.05^timedelta),lerp(b+variablec,255,1-0.5^timedelta)
add to variablea 0.5
add to variableb 1.5
add to variablec 0.05
And you can also vary the timing on the timedelta multiplier.
Image Image
B
161
S
48
G
90
Posts: 7,351
Reputation: 66,757

Post » Thu Feb 17, 2011 8:24 am

ok, the specific numbers I'm dealing with are...

Day = rgb(255,255,255) - white
*if it rains (which is a random chance) day then fades quickly to
Overcast = rgb(127,127,127) - mid/dark gray
either Day or Overcast then needs to fade to
Night = rgb(45,57,60)

so I need a function that can recalculate itself based on whether or not the rain is active, so I need two events, one that goes from Day to Night over a set amount of time (which I need to be able to change easily to fine tune the feel of the change), and one that goes from Day to Overcast to Night over a set amount of time.

I guess what I really need to know is how to get construct to do the math from rgb(a,b,c) to rgb(x,y,z) over t milliseconds
and have a become x, b become y, and c become z all at the same time regardless of the distance between each pair
B
64
S
8
G
9
Posts: 290
Reputation: 8,590

Post » Thu Feb 17, 2011 8:25 am

yeah, lerp and timedelta just wooshed right over my head haha

edit: I really appreciate all the help so far though lol, at the very least you guys are getting me to think through the problem a bit, my shortcomings are definitely in programming calculations as I've never been a coder (I couldn't even learn VB :$)
B
64
S
8
G
9
Posts: 290
Reputation: 8,590

Post » Thu Feb 17, 2011 8:38 am

Newt did all the work :)
I'm not a coder either... actually i don't even know how to use lerp hahaha... haha. :?
B
4
S
1
G
2
Posts: 91
Reputation: 1,057

Post » Thu Feb 17, 2011 8:42 am

If I could understand the meaning behind the syntax and the specifics of what the syntax is referring to then I could understand what I'm doing lol, but yeah, I realize it must not be that hard a problem to solve. What I'm trying to do seems pretty straight forward, I'm just not sure what commands/syntax to use to get construct to do it. I friggin love construct by the way lol. I'm in University going for a BA in Digital Media and they're trying to find an alternative to Flash to use for teaching basic game production and interactive motion media. I think I may have one of the instructors sold on Construct 2 once it gets proper functionality lol
B
64
S
8
G
9
Posts: 290
Reputation: 8,590

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests