Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Joseph on Mon 31/08/2009 18:15:59

Title: Iconbar slides down smooth as ICE (SOLVED...TUTORIAL INCLUDED)
Post by: Joseph on Mon 31/08/2009 18:15:59
Hi fellow turtle-lovers,

Ive been searching like a madman for help on sliding the iconbar down smoothly when your mouse goes to the top of the screen. I could only find this one, and another one too but the poster's link is broken (he answered with a link that now I cant access).

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=21153.0

I will continue searching, however if someone directly knows where a thread treating this subject would be...well just fork it over babay!!

If not, well...any help on this would be f#@%in' great.
Title: Re: Iconbar slides down smooth as ICE
Post by: Matti on Mon 31/08/2009 18:18:59
You might want to check out the Tween module (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=38015.0).
Title: Re: Iconbar slides down smooth as ICE
Post by: Joseph on Mon 31/08/2009 21:15:30
Ok that could be promising. Thanks for the link, Ill see what I can do with it.
Title: Re: Iconbar slides down smooth as ICE
Post by: Joseph on Tue 01/09/2009 17:50:48
Ok, well I got exactly what I wanted! Thanks for this link...and thanks to  Edmundo Ruiz (edmundito, netmonkey) for this module!

Here is what I did for those who might want a step by step:

Put this in your GlobalScript.asc:


bool useFancyIconbar = false;
bool iconbarVisible = false;

function ShowIconbar()
{
 gIconbar.SetPosition(0, -gIconbar.Height);
 gIconbar.Transparency = 100;
 iconbarVisible = true;
 
 gIconbar.StopAllTweens();
 gIconbar.TweenPosition(0.2, 0, 20, eEaseInEaseOutTween);
 gIconbar.TweenTransparency(0.2, 0, eEaseInEaseOutTween);
}

function HideIconbar()
{
iconbarVisible = false;
gIconbar.StopAllTweens();
 gIconbar.TweenPosition(0.2, 0, -gIconbar.Height, eEaseOutTween);
gIconbar.TweenTransparency(0.2, 100, eEaseOutTween);
}

function repeatedly_execute() {
 
 // put anything you want to happen every game cycle, even when
 // the game is paused, here
 
 if (mouse.y > gIconbar.Height && iconbarVisible)
 {
   HideIconbar();
 }
   
 if (mouse.y <= 102 && !gIconbar.Visible && !IsGamePaused())
 {
   ShowIconbar();
 }  
 
 if (IsGamePaused() == 1) return;
 

 // put anything you want to happen every game cycle, but not
 // when the game is paused, here
}


Notes:

1) "  gIconbar.TweenPosition(0.2, 0, 20, eEaseInEaseOutTween);"
I set the 3rd value to 20 because my statusline is 20 pixels high...and I wanted my iconbar to slide from beneath the statusline.

2) "  if (mouse.y <= 102 && !gIconbar.Visible && !IsGamePaused())"
I set the value to 102 because that is the height of my iconbar.

3) If you want your iconbar to slide from under the statusline, just make sure in properties that your status line has its zorder set above your iconbar.

4) Make sure you set your gIconbar's visibility to "Pause game when shown" in its Appearance/Properties.

Thats it! Now you have your iconbar sliding SMOOTH AS ICE* from under your statusline when your mouse is at the top of the screen.



*(I get a shudder of shame whenever I say stuff like that, but its fun)