Wintermute Engine => Technical forum => Topic started by: Chaos on February 26, 2009, 06:41:59 AM
Title: Making a Fade-In of Inventory Bar
Post by: Chaos on February 26, 2009, 06:41:59 AM
Hi all,
When I played "Limbo of the Lost"(the worst case of Cut and Paste on the history of gaming ;) ) there was a feature I realized it could look good on my game.I'm talking about the Fade-In the Inventory(and items)does every time you opened it.I know I can make it using sprites,but I'd like to know any way to do it throughout the script.So it will need a function that sets the transparency of the Inventory,and also that simulates a fading.It is very important to note that in my game the Inventory Bar is completely transparent all the time,so it will have to deal only with the Items.
Many thanks to any helping hands.
Title: Re: Making a Fade-In of Inventory Bar
Post by: Akusa on February 26, 2009, 05:11:04 PM
in the script Game_Loop.script, create two new variables at the beginning:
Code: WME Script
var Inventory;
var TempAlpha = 0;
next step, search for the comment:
Code: WME Script
// display the inventory window
Replace the if condition below this comment with this modified condition:
Title: Re: Making a Fade-In of Inventory Bar
Post by: Chaos on March 02, 2009, 06:04:42 AM
Akusa,I've just installed this piece of code on the game and give it a try.And it certainly looks incredible! Great job!! ;D I thought that maybe I will need to adjust the speed of the fading somehow,but no,it runs as smooth as I wanted.Thank you very much!
Cheers
Title: Re: Making a Fade-In of Inventory Bar
Post by: Akusa on March 02, 2009, 03:03:40 PM
well, just for your information, the speed is regulated through the sleep command of your game loop (i would not change this for the sake of game speed) and the increase and decrease of the TempAlpha variable.
Code: WME Script
TempAlpha = TempAlpha + 15;
and
Code: WME Script
TempAlpha = TempAlpha - 15;
alpha has a value from 0-255 and the standart sleep command is 20ms. So in theory you should be able to calculate the speed of the fade-in and fade-out.
The only problem: Your TempAlpha variable must hit the value 255 exactly or you get strange window behavior. You can counter this in a second if condition that sets the value to 255 if its above this but i was to lazy in my game to implement this (not that it takes much time) and im aware of this behaviour. So if you want to change the speed, find a value that can divide 255, implement a bugfix or simply dont touch this.
Title: Re: Making a Fade-In of Inventory Bar
Post by: ranmyzer_ita on January 14, 2011, 04:16:27 PM
its bugged if you return quickly up the inventory with the cursor... any solution?