Animating a GUI to Pop up from the bottom of the screen HELP!

Started by SinSin, Wed 10/02/2010 22:08:59

Previous topic - Next topic

SinSin

AGS version 3.1.0

I've been trying this for ages but I cannot do it
Basically I want my GUI to pop up when my mouse cursor is at the bottom of the screen, I tried a method that BEN wrote down ages ago but obviously AGS has come along way since then and now this method wont work
here is what I have
Code: ags
#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() 
  {
if((mouse.y > 194) && (gui_ypos > 0)){
  gTask.SetPosition(gTask , 0 , gui_ypos - 200); //where GUI# is the name or number of the GUI you're moving
  gui_ypos ++;
  }


also I have this in my Glabal script.ash

Code: ags
  int gui_ypos = 1; 


Debugger claims Type Mismatch: cannot convert GUI* to 'Int'            ???
Currently working on a project!

Matti

It seems you want the GUI to scroll up from the bottom, not to pop up? In any case, this has been a question a few weeks ago:

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

The conclusion was: The Tween module is your friend:

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

Dualnames

Quote from: Sinsin on Wed 10/02/2010 22:08:59
AGS version 3.1.0

I've been trying this for ages but I cannot do it
Basically I want my GUI to pop up when my mouse cursor is at the bottom of the screen, I tried a method that BEN wrote down ages ago but obviously AGS has come along way since then and now this method wont work
here is what I have
Code: ags
#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() 
  {
if((mouse.y > 194) && (gui_ypos > 0)){
  gTask.SetPosition(gTask , 0 , gui_ypos - 200); //where GUI# is the name or number of the GUI you're moving
  gui_ypos ++;
  }


also I have this in my Glabal script.ash

Code: ags
  int gui_ypos = 1; 


Debugger claims Type Mismatch: cannot convert GUI* to 'Int'            ???

Quote from: Dualnames on Sat 23/01/2010 18:57:34
Magma42, use the awesome Tween Module by Edmundo Ruiz!
You can tweak size,position, and all! And very easy, and also very good looking. I recommend it!

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

I'm not like selling anything, but it's a darn easy, darn impressive module to handle trans, position, scale, size.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SinSin

Currently working on a project!

SinSin

Quote from: Sinsin on Wed 10/02/2010 22:42:19
cheers guys  you have been most helpful  ;D
Actually Ive just seen this mod and downloaded it   but I'll be damned if I know how to use it, It just is'nt clear on where I should write anything.


Can anyone help ?

Currently working on a project!

monkey0506

The function you're looking for is GUI.TweenPosition. I don't know the full parameter list off-hand, but it should show up in the calltip when you put the function in. Something like:

Code: ags
gIconbar.SetPosition(0, System.ViewportHeight);
gIconbar.TweenPosition(0, System.ViewportHeight - gIconbar.Height, eEaseIn);


Like I said, I don't know the full parameter list so that code won't work as-is, but that's the basic gist of it. You would call that from repeatedly_execute depending on the mouse position. You would use the same TweenPosition function to slide it back out.

Although really for one single GUI it's not that hard to just do:

Code: ags
function repeatedly_execute() {
  int ypos = (System.ViewportHeight - gIconbar.Height);
  if (mouse.y >= ypos) {
    if (gIconbar.Y > ypos) gIconbar.Y--;
  }
  else if (gIconbar.Y < System.ViewportHeight) gIconbar.Y++;
}

SinSin

So Iv set the GUI
Code: ags

gTask

What I can gather is that Iv also set its tween to point ???
This wont work either
says

GlobalScript.asc(14): Error (line 14): Type mismatch: cannot convert 'int' to 'float'  ???  

Im really sorry ifI'm coming across as stupid but this module is proper doin ma head in . :(


Code: ags
function repeatedly_execute() 
 {
 gTask.SetPosition(0, System.ViewportHeight);
gTask.TweenPosition(1.0, System.ViewportHeight - gTask.Height, eEaseInTween);   //This is line 14

 int ypos = (System.ViewportHeight - gTask.Height);
  if (mouse.y >= ypos) {
    if (gTask.Y > ypos) gTask.Y--;
    
     }
  else if (gTask.Y < System.ViewportHeight) gTask.Y++;
}
   
Currently working on a project!

hedgefield

A float always has a decimal point in it, so you need to put 125.0 in the TweenPosition function instead of just 125.

Actually I'd recommend starting with a value like 1.0.
125.0 is reeeaaaallllyyyy really slow.

SinSin

Sigh I made the ammendment and I'm still nowhere near   

Code: ags

#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() 
 {
 gTask.SetPosition(0, System.ViewportHeight);                            \\ <----- THIS IS THE CULPRIT 
gTask.TweenPosition(1.0, System.ViewportHeight - gTask.Height, eEaseInTween);

 int ypos = (System.ViewportHeight - gTask.Height);
  if (mouse.y >= ypos) {
    if (gTask.Y > ypos) gTask.Y--;
    
     }
  else if (gTask.Y < System.ViewportHeight) gTask.Y++;
}
   
 
#sectionend repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE


ERROR  GUI.Y Co-ordinates specified are out of range
Currently working on a project!

Khris

Try
Code: ags
  gTask.SetPosition(0, System.ViewportHeight - 1);

SinSin

EDIT:  Thanks for all the help so far
So I've been doing some tinkering and this is the closest I've got
Currently this code lets the game load up and the GUI in question (gTask) appears but is blurred out and blinking, Also it follows my mouse upward Hahhah
Im so close    any ideas ?

Code: ags

function repeatedly_execute() 
{
  gTask.SetPosition(0, 153);
  gTask.TweenPosition(1.0, 0, 0, eEaseInTween, eBlockTween);
  
  int ypos = (System.ViewportHeight - gTask.Height);
  if (mouse.y >= ypos) {
    if (gTask.Y > ypos) gTask.Y--; 
     }
  else if (gTask.Y < System.ViewportHeight) gTask.Y++;  
}  
Currently working on a project!

monkey0506

I never meant for you to script it yourself and use the Tween module. Use one or the other. Not both.

So, use:

Code: ags
  gTask.SetPosition(0, 153);
  gTask.TweenPosition(1.0, 0, 0, eEaseInTween, eBlockTween);


OR:

Code: ags
  int ypos = (System.ViewportHeight - gTask.Height);
  if (mouse.y >= ypos) {
    if (gTask.Y > ypos) gTask.Y--;
  }
  else if (gTask.Y < (System.ViewportHeight - 1)) gTask.Y++;


Though I don't know why it would be telling you max tweens exceeded (if you went for the Tween route).

And this code wasn't strictly intended for use as-is (as I said). You'll need to customize it to fit your own needs.

tzachs

With the TweenPosition line you made the gui will go to (0,0) on every repeatedly execute (and then go down because of the other code), and that would explain gui "blinking".

You can do something like this:
Code: ags

function repeatedly_execute() 
{
    int ypos = (System.ViewportHeight - gIconbar.Height);
    if (mouse.y >= ypos) {
          //GUI scrolls up
          gIconbar.TweenPosition(1.0, gIconbar.x, ypos, eEaseInTween, eBlockTween);
    }
    else if (gIconbar.Y < System.ViewportHeight - 1) {
         //GUI scrolls down
         gIconbar.TweenPosition(1.0, gIconbar.x, System.ViewportHeight - 1, eEaseInTween,  eBlockTween);
    }
}

SinSin

edited the phrase Iconbar.x to suit script
All i need now is to be able to use it (currently its constantly greyed out)

Should it be paused when scrolled up?

Sorry but I'm hopeless with code
Currently working on a project!

tzachs

Yes, my bad, change this line:
Code: ags

if (mouse.y >= ypos) {


to this:
Code: ags

if (mouse.y >= ypos && gIconBar.Y != ypos) {


That should do it...

SinSin

Quote from: tzachs on Fri 12/02/2010 16:49:49
Yes, my bad, change this line:
Code: ags

if (mouse.y >= ypos) {


to this:
Code: ags

if (mouse.y >= ypos && gIconBar.Y != ypos) {


That should do it...


This just makes the bar go in then out again and again
Currently working on a project!

monkey0506

That's the reason I had them in a nested condition so you don't have to recheck the same condition needlessly:

Code: ags
if (mouse.y >= ypos) {
  if (gTask.Y != ypos) gTask.TweenPosition(1.0, gTask.X, ypos, eEaseInTween, eBlockTween);
}
else if (gTask.Y < (System.ViewportHeight - 1)) gTask.TweenPosition(1.0, gTask.X, System.ViewportHeight - 1, eEaseInTween,  eBlockTween);

SinSin

I dont get it   What should I be doin now  Im confused.. Is tzachs right or not  ???
Currently working on a project!

monkey0506

tzachs was correct (as I had already said previously) that you will want to check both conditions. Again, as I already said, my original code snippets weren't intended for use as-is. However, seeing as you have made it apparent that you are not very well oriented with scripting, the code snippet I posted above should be suited to your task.

tzachs was incorrect however as to the logical grouping. The logic of the outer if statement and the else clause should only consider the mouse's y co-ordinate. The inner if statement is required to check the GUI's y co-ordinate as well.

So tzachs was both correct and incorrect.

tzachs

Yes, I was half correct, monkey is completely correct...

SMF spam blocked by CleanTalk