Best way to give a feedback of combination of 2 items

Started by Manu, Sun 17/01/2021 22:07:18

Previous topic - Next topic

Manu

In my game I want the player to combine two objects to create a new one. Right now my solution is the following:
- inside iObject_UseInv() I check if the active inventory is the other object, and if this is the case:
- I use player.LoseInventory to remove the old objects
- I use player.AddInventory to add the new object
- I use Display to show a message like "Cool, I combined X and Y to get Z".

The problem is this solution is quite ugly because everything happens on the inventory screen, the room and the characters are not visible, and I cannot show any animation. If one of the objects was in the room, I could have shown an animation of the character doing something. But these are two objects that the player can collect, and it makes sense that he can combine them at any time.

Any suggestion?

eri0o

You can use Tween to move two GUIs that have the background image as each of these inventory icons to show them going one on top of another, and then fade both into the resulting icon. This can be a bit hard to code if it's your first time with the Tween module.

Adding sound can also be useful to tell that something is going on.

Khris

You could hide the inventory GUI and play a short animation of the character combining something from their pockets?

Crimson Wizard

Instead of proposing anything specific from technical side, I'd instead give following advice: forget about technical difficulties for a moment and fantasise how you would like to see it in your game (i.e. pretend you are player who sees the game, not one who is making it) :).

Then having a picture in your mind try to figure out how to actually do that, or ask if you don't know how to. Because what you will imagine is likely possible to do in numerous ways.

Manu

You are right, in fact, I'm not totally sure what could be the solution. I was looking for suggestions also from this point of view, not just technical.

If I have to ignore the technical part, what I would like to see is the inventory screen disappear, and nice animation, of the objects merging together and forming a new object, plays in the middle of the screen (while the room is still visible in the background, maybe just a bit darker). Then the new object "flows" nicely to the top of the screen, to show that it will become available in the inventory.

Actually, this last thing would be useful in general. It would be nice to have an animation of the object "entering" the inventory each time the player gets a new object. Or at least a notification on the inventory icon. Especially useful when you don't collect the object, but it's given to you during a dialog for example.


Crimson Wizard

#5
eri0o mentioned the Tween module above, that is useful because it takes care of smooth movement, thus you wont have to script objects moving yourself.

Animation may be played on GUI with animating buttons (and transparent background for example).

Room may be darkened using a half-transparent GUI with a plain color on it.

Moving item could be done again using a gui with item image set as its background graphic, or on a button.
It might be possible to calculate where it should land by reading InvWindow properties, such as TopItem, ItemsPerRow, ItemWidth, ItemHeight etc

This is just to start with something.

Manu


Manu

Quote from: Khris on Sun 17/01/2021 23:46:50
You could hide the inventory GUI and play a short animation of the character combining something from their pockets?

I realized that this suggestion is probably the simplest :)

To close the inventory window do I need to use "GUIControl.Visible=false"?
Is there a way to simulate the click on the close button?



Khris

GUIControl is the generic type of a button or other GUI element but yes, you would need something like
Code: ags
  gInventory.Visible = false; // hide GUI


You can simulate a click on the close button by calling the function that is assigned to it. You also have to pass the mouse button and button itself:
Code: ags
  btnCloseInv_OnClick(btnCloseInv, eMouseLeft);

(Also note that any function you call has to be further up in the script, but handling inv items usually ends up below GUI button functions anyway)

Crimson Wizard

There's also Button.Click() function, which calls its action (but it's not a visual effect so button won't appear pressed).

Manu

"gInventory.Visible = false" works, while "btnInvOK.Click(eMouseLeft)" does not work. It simply does not have any effect. Do you know why?

Also, I'd like to hide the selected object, the one attached to the mouse cursor. Is it possible?

Thanks a lot

Crimson Wizard

Quote from: emabolo on Mon 18/01/2021 22:43:50"btnInvOK.Click(eMouseLeft)" does not work. It simply does not have any effect. Do you know why?

No, I'd need to test this out. This function is rather new and I don't think a lot of people used it in games yet.

Quote from: emabolo on Mon 18/01/2021 22:43:50
Also, I'd like to hide the selected object, the one attached to the mouse cursor. Is it possible?

It's the cursor that takes an image of the inventory item. If it's done with the default method (like in most game templates), it does so when you set "player.ActiveInventory = someitem" and undoes when you set "player.ActiveInventory = null".

Manu

Quote from: Crimson Wizard on Tue 19/01/2021 01:59:20
If it's done with the default method (like in most game templates), it does so when you set "player.ActiveInventory = someitem" and undoes when you set "player.ActiveInventory = null".

It works perfectly, thanks!
The only minor issue is that after using gInventory.Visible = false, the icons bar cannot be reopened, but I solved it by setting Visible to true once I gave the feedback. In the end, it makes sense to show again the inventory.

SMF spam blocked by CleanTalk