[Request] A fading effect timer thing

Post here for help and support regarding LunaLua and SMBX2's libraries and features.

Moderator: Userbase Moderators

isaacjosue
Goomba
Goomba
Posts: 2
Joined: Fri Mar 13, 2020 2:24 pm
Flair: i am the yes

[Request] A fading effect timer thing

Postby isaacjosue » Sun Mar 22, 2020 1:15 pm

I'm not the best at explaining things so bear with me.
I want it to fade in for a set amount of time when event A happens and fade out when event B happens.
Example:
Timer is set to 30 seconds
If event A happens and I wait 15 seconds then the effect would be at 50% opacity (half faded in).
If event B happens then it would take 15 seconds for the effect to fully fade out.

yes i'm aware this description sucks i'm doing my best please help me

Chanceux2
Volcano Lotus
Volcano Lotus
Posts: 576
Joined: Mon Dec 16, 2019 3:39 pm
Flair: People don't care about my threads! :(
Contact:

Re: [Request] A fading effect timer thing

Postby Chanceux2 » Sun Mar 22, 2020 5:27 pm

This year i'm planning to learn how to code

I want to code these types
Codes: show
Lunalua (For SMBX 2.0)
Roblox Lua (For Roblox)
HTMI (For SMBX 2.0)
VRscript (For 38A)
C++ (for SMBX TheXtech)
Long story short: I can't help

Chipss
Monty Mole
Monty Mole
Posts: 107
Joined: Fri Jul 25, 2014 9:47 pm
Pronouns: he/him
Contact:

Re: [Request] A fading effect timer thing

Postby Chipss » Sun Mar 22, 2020 5:42 pm

Chanceux2 wrote:
Sun Mar 22, 2020 5:27 pm
This year i'm planning to learn how to code

I want to code these types
Codes: show
Lunalua (For SMBX 2.0)
Roblox Lua (For Roblox)
HTMI (For SMBX 2.0)
VRscript (For 38A)
C++ (for SMBX TheXtech)
Long story short: I can't help
You shouldn't reply if you're not going to contribute anything to the original topic.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: [Request] A fading effect timer thing

Postby Emral » Sun Mar 22, 2020 6:16 pm

A "fade" is simply a variable that changes over time and represents an opacity between 0 and 1. For example:
Graphics.drawImage(sprite, x, y, opacity)
https://wohlsoft.ru/pgewiki/LunaLua_glo ... _functions

Can't give more concrete info because the post is fairly vague.

isaacjosue
Goomba
Goomba
Posts: 2
Joined: Fri Mar 13, 2020 2:24 pm
Flair: i am the yes

Re: [Request] A fading effect timer thing

Postby isaacjosue » Sun Mar 22, 2020 8:46 pm

Enjl wrote:
Sun Mar 22, 2020 6:16 pm
A "fade" is simply a variable that changes over time and represents an opacity between 0 and 1. For example:
Graphics.drawImage(sprite, x, y, opacity)
https://wohlsoft.ru/pgewiki/LunaLua_glo ... _functions

Can't give more concrete info because the post is fairly vague.
Ok scratch the events thing and the fading out I'll figure those out.
I'm looking for a way to do a smooth and continuous fade effect in a set amount of seconds so that when x% percent of the time set has passed the opacity will be at x%.
If timer is set to 10 seconds and I wait 5, then the effect would be at 50% opacity.

My main problem is timing. I am simply unable to make the fading smooth and getting the timing right at the same time.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: [Request] A fading effect timer thing

Postby Emral » Mon Mar 23, 2020 1:46 am

isaacjosue wrote:
Sun Mar 22, 2020 8:46 pm
Enjl wrote:
Sun Mar 22, 2020 6:16 pm
A "fade" is simply a variable that changes over time and represents an opacity between 0 and 1. For example:
Graphics.drawImage(sprite, x, y, opacity)
https://wohlsoft.ru/pgewiki/LunaLua_glo ... _functions

Can't give more concrete info because the post is fairly vague.
Ok scratch the events thing and the fading out I'll figure those out.
I'm looking for a way to do a smooth and continuous fade effect in a set amount of seconds so that when x% percent of the time set has passed the opacity will be at x%.
If timer is set to 10 seconds and I wait 5, then the effect would be at 50% opacity.

My main problem is timing. I am simply unable to make the fading smooth and getting the timing right at the same time.
Interpolate a variable in onTick by 1/durationInFrames
1 second is roughly 64 frames.
So for 10 seconds:
opacity = opacity + 1/(64*10)

Turn the 10 into a variable and add a multiplier to interpolate backwards (subtract) and then you have a variable that moves between 0 and 1. Of course, ensuring that the variable never leaves the 0-1 range would be good, too, but that is easily done.


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 0 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari