Smooth scroll in inventory ?

Started by Kangourou pas sympa, Mon 23/03/2009 18:55:51

Previous topic - Next topic

Kangourou pas sympa

Hello, I searched on the forum but I found nothing.
I'm trying to make an horizontal inventory, and I want to know if it's possible to smooth the scroll ?
Maybe you know a module, or a script ?
I prefer to tell you I'm totally noob in scripting, I'm an "illustrator", and I try to make my GUI before to continue my drawings.
In advance, thank you.

Khris

This is possible, but only with semi-advanced scripting:
-create a screenshot, crop it to invwindow + additional row height
-draw additional item row
-use a second DynamicSprite to display a cropped version of the first one on an additional GUI, moving the section down
-in the background scroll the actual invwindow by one row, then change the GUI back to being not visible

Kangourou pas sympa

Hello,
I thank you for your answer,
But I'll be honest, I understood nothing.
Maybe it's because of my english wich sucks,
But most probably, I wanted to be faster than my knowledges allowed me.
So, I repeat, thank you, I'll keep this topic in my memory and in my bookmarks, and I'll come back later, when I'll be able to understand.

magintz

You can't have a smooth scrolling inventory. You have to work around it by having a smooth scrolling image of the inventory. Obviously the inventory will be changing every time a player takes or loses an item so to keep it up to date you take a screenshot, within the game using an AGS function (read the manual). This screenshot can then be edited and modified so it is just a screenshot covering the inventory window which you should now be able to make scroll smoothly using DynamicSprite (again, best place for this is to check the manual).
When I was a little kid we had a sand box. It was a quicksand box. I was an only child... eventually.

Kangourou pas sympa

Thanks for your answer,
So if I understand and please tell me if I'm wrong,
It wont be possible to stop the scroll in the middle of a column ?
Thanks for your help, I think I'm starting to understand the theory ;)

SSH

Another way to do it would be to have the invetory hidden behind another GUI (or GUI control) which sits over the edges of it. Then you can adjust the X/Y co-ordinates of the inv gui to do the scroll, then once in the new position you jump to the next inv position and move the gui back to its original co-ordinates.
12

Kangourou pas sympa

Hi,
Thank you for this another way, but if I have understood, it won't work in my project,
Because my inventory is transparent.
Here a picture:

So item will be superposed with the inventory icon, no ?

SSH

#7
Well, you can also use the GUI clipping to avoid that problem. Here's a quick bit of code:

Code: ags

function goInvUp_OnClick(GUIControl *control, MouseButton button)
{
    if (goInv.TopItem>0) {
      goInv.TopItem--;
      goInv.X= -goInv.ItemWidth;
      while (goInv.X<0) {
        goInv.X++;
        Wait(1);
      }
    }
}



function goInvDown_OnClick(GUIControl *control, MouseButton button)
{
    if (goInv.TopItem<(goInv.ItemCount-1)) {
      //goInv.ScrollUp();
      goInv.X=0;
      while (goInv.X> -goInv.ItemWidth) {
        goInv.X--;
        Wait(1);
      }
      goInv.TopItem++;
      goInv.X=0;
    }
}


You can download the example AGS project here. If you prefer a vertical scroll, it just means changing width/height and X/Y and making the inv window two inv items deep instead of two wide as in my example. I assume you're only showing one inv item at one time based on your picture. More than one may require some more effort, but the principle should be similar.

Oh, and its now a module
12

Kangourou pas sympa

Oh my,
Thank you a lot,
I'm trying to adapt this to my project (with no need to clic to scroll),
I'll show you if I get it. :)

SMF spam blocked by CleanTalk