Inventory item animated!?

Started by Flyman, Sat 04/02/2012 20:40:31

Previous topic - Next topic

Flyman

mmmm, I ask's me if with AGS is possible animated a Inventory item.
Command like this:
iInventory[17].SetView(51, 0);
iInventory[17].Visible = true;
iInventory[17].Animate(0, 1, eRepeat, eNoBlock);

Khris

#1
mmmmmmmm, First of all, it's EITHER inventory[17] OR iInventory.

The inventory[] array is a built in list of all InventoryItems. But, since InventoryItems are global, you use the actual name in any script.

mmmm, As for animating them, you have to change the graphic manually in repeatedly_execute_always, here's a code example from MMM 61:

Code: ags
// Animate acid
  if (player.InventoryQuantity[iMiSo.ID]==1 && IsTimerExpired(11)) {
    int a=iMiSo.Graphic;
    a++;
    if (a==392) a=389;
    iMiSo.Graphic=a;
    SetTimer(11, 10);
  }


mmmmmmmmmmm, Pretty simple actually. The graphic slot is incremented every ten frames, and set back to the first after it has reached the last frame.

Ryan Timothy B

mmmmm Here's a much nicer solution, a module that uses extender functions for the inventory items. Eg: inventory[17].Animate(0, 1, eRepeat, eForward);

The only thing I didn't do was blocking animations, a flipped frame in the view, or frame sounds. I was too lazy. But this works for blocking animations:
Code: ags

iPizza.Animate(0, 1);
while (iPizza.Animating()) Wait();

I just don't recommend doing that if eRepeat is set, unless you have the inventory stop animating at another point.

Here are the extender methods:
Inventory.SetView(int view, OPTIONAL int loop, OPTIONAL int frame);
Inventory.Animate(int loop, int delay, OPTIONAL RepeatStyle, OPTIONAL Direction);
Inventory.Animating();
Inventory.StopAnimating();


http://www.bryvis.com/entertainment/other/agsf/InventoryAnimate.scm
(right click and save as)

Let me know if it has any issues, I didn't test it to the extreme, but it seemed to work just fine.

Flyman

Is possible implemented the animated function for inventory item in AGS?  ::)

Ryan Timothy B

mmmm apparently you have troubles reading. But I suppose I never did walk you through what that file was. You simply import it into AGS by right clicking on scripts and then import module script.

bx83

#5
Ryan Timoothy, do you still have this script file? Link leads to a domian squatter, download is gone.
Could you run me through what the script does maybe?

SMF spam blocked by CleanTalk