Shortly show item just picked up on a gui

Started by Mel_O_Die, Thu 19/10/2006 23:34:41

Previous topic - Next topic

Mel_O_Die

Hi!

I here again with a new little question :)

I can't found how to say it simply, but i will explain it as i can :d

I have a little icon in the corner of my game used to acess inventory window, the thing i want to do, is to make appear over it the item just picked up (at the moment of the player picks it) make it blink 3 times and desapears.

i've no idea how to do it

hope you understand what i mean :)

thanks!
----( )----
Click to see "In Production" Topic!
[/color][/b][/url]

SSH

Add some code to  your on_event fucntion for when the player gets an inventory item added. Make another GUI with a higher z than your icon, put a button int he GUI, set the button normal graphic to the graphic of your inv item and then turn the gui on and off with wait statements in between. Easy!
12

Mel_O_Die

so i had to make a button for each inventory item?

there are no way to make that automatically ?
----( )----
Click to see "In Production" Topic!
[/color][/b][/url]

Theeph

#3
Quote from: Mel_O_Die on Fri 20/10/2006 13:18:42
so i had to make a button for each inventory item?

there are no way to make that automatically ?

SSH is saying to do it automatically...

Say the button is called button1.

All you do is something like:

Code: ags

button1.NormalGraphic = x


where x is the sprite slot for whatever item you want.


EDIT: Also if you want the item to blink but not the inventory icon, then you do what SSH said but instead of turing the gui on and off you just do:

Code: ags

button1.NormalGraphic = 0;
Wait(1);
button1.NormalGraphic = x;
Wait(1);

SSH

Well, I said to put it on a separate GUI so it wouldn't effect the inv icon... that also makes it easier to position and means you don't get the button text appearing when you turn the graphic off...  :P
12

Mel_O_Die

#5
okay, i see, but i'm still locked  ::)

here is my actual on_event code:

Code: ags

function on_event(EventType event, int data) {

if (event == eEventAddInventory) {
player.ActiveInventory=inventory[3];
gPopinv.Visible=true;
wait(40);
gPopinv.Visible=false;
player.ActiveInventory=null;
}
}


I used a button with (INV) text for displaying in it my active inventory (it's the only way i found to do that :s)

my problems are the followings:

- i don't want that to pause the game, but runs in background (in repeatedly_execute_always ?) (because of items given during dialogs)
- don't want to set manually the number of the item just picked up (with my code, it's always the same item displayed on addinventory event
- i don't understant how to use the data returned by the event (in the manual they said:
eEventAddInventory
      the player just got a new inventory item
      DATA = inventory item number that was added
and that seems to be useful for my case)

thanks for your help!

Edit by strazer (Do not double-post!):

aww sorry it works with the use of data!

don't know why my last try doesn't work

Code: ags

if (event == eEventAddInventory) {
player.ActiveInventory=inventory[data];
gPopinv.Visible=true;


::) ::)

but it rests the problem of the pause and if i can do that without using activeinventory (because, if the game isn't paused, the cursor will be in activeinventory mode :s)
----( )----
Click to see "In Production" Topic!
[/color][/b][/url]

Theeph

Quote from: SSH on Fri 20/10/2006 14:17:59
Well, I said to put it on a separate GUI so it wouldn't effect the inv icon... that also makes it easier to position and means you don't get the button text appearing when you turn the graphic off...  :P

Oops. Sorry for misrepresentation :)

Also, I always clear my button text when I'm playing around like this... probably should have mentioned :P

SSH

#7
Instead of using a button with (INV) text, set teh text to blank. Also, give the button a script name, like buttonInvFlash

then:

Code: ags

int invFlashCount;

function on_event(EventType event, int data) {

  if (event == eEventAddInventory) {
    buttonInvFlash.NormalGraphic=inventory[data].Graphic;
    gPopinv.Visible=true;
    invFlashCount=40;
  }
}

function repeatedly_execute() {
  if (invFlashCount>0) {
    invFlashCount--;
    if (invFlashCount==0) {
      gPopinv.Visible=false;
    }
  }
  // rest of your rep_ex code...

}

12

SMF spam blocked by CleanTalk