Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: Making a Fade-In of Inventory Bar  (Read 4395 times)

0 Members and 1 Guest are viewing this topic.

Chaos

  • supporter
  • Lurker
  • *
  • Karma: 1
  • Offline Offline
  • Gender: Male
  • Posts: 45
  • "WME rocks!"
    • View Profile
Making a Fade-In of Inventory Bar
« 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.   
« Last Edit: February 26, 2009, 07:25:02 AM by Chaos »
Logged

Akusa

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 46
    • View Profile
Re: Making a Fade-In of Inventory Bar
« Reply #1 on: February 26, 2009, 05:11:04 PM »

in the script Game_Loop.script,  create two new variables at the beginning:
Code: WME Script
  1. var Inventory;
  2. var TempAlpha = 0;

next step, search for the comment:
Code: WME Script
  1. // display the inventory window

Replace the if condition below this comment with this modified condition:

Code: WME Script
  1.   if(Game.Interactive && Game.MouseY < 45 && !Game.ResponsesVisible && !WinMenu.Visible)
  2.   {
  3.         Game.InventoryVisible = true;
  4.         Inventory = Game.GetInventoryWindow();
  5.         //temp.FadeColor = MakeRGBA(0,0,0,128);
  6.         if (TempAlpha < 255)
  7.         {
  8.                 TempAlpha = TempAlpha + 15;
  9.         }
  10.         Inventory.AlphaColor = MakeRGBA(255,255,255, TempAlpha);
  11.   }
  12.   else if(Game.MouseY > 100 || Game.ResponsesVisible || !Game.Interactive)
  13.   {
  14.         Inventory = Game.GetInventoryWindow();
  15.         if (TempAlpha > 0)
  16.         {
  17.                 TempAlpha = TempAlpha - 15;
  18.         }
  19.         else
  20.         {
  21.                 Game.InventoryVisible = false;
  22.         }
  23.         Inventory.AlphaColor = MakeRGBA(255,255,255, TempAlpha);
  24.   }

FINISHED
« Last Edit: April 10, 2009, 12:08:01 PM by Akusa »
Logged

Chaos

  • supporter
  • Lurker
  • *
  • Karma: 1
  • Offline Offline
  • Gender: Male
  • Posts: 45
  • "WME rocks!"
    • View Profile
Re: Making a Fade-In of Inventory Bar
« Reply #2 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
« Last Edit: March 02, 2009, 06:10:05 AM by Chaos »
Logged

Akusa

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 46
    • View Profile
Re: Making a Fade-In of Inventory Bar
« Reply #3 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
  1. TempAlpha = TempAlpha + 15;

and

Code: WME Script
  1. 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.
« Last Edit: April 10, 2009, 12:08:43 PM by Akusa »
Logged

ranmyzer_ita

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 1
    • View Profile
    • My Site
Re: Making a Fade-In of Inventory Bar
« Reply #4 on: January 14, 2011, 04:16:27 PM »

its bugged if you return quickly up the inventory with the cursor... any solution?
Logged
ah che belli i tempi della Magnavox Odyssey
 

Page created in 0.041 seconds with 21 queries.