Disable Panel sprite buttons

I am currently creating a clicker game and want to have a shop. I am using Panel sprite buttons (from the PanelSpriteButton extension) to create items. These have 3 states: Idle, Hovered and Pressed , which works great if the player has enough money, but still play an animation if they don’t. Videos I have seen say to just not subtract the money if they don’t have enough. However, I don’t want the player to be able to press the button at all, I would like the button to be disabled.

Ideally I would like this to be supported by the extension but if anyone has ways to work around this they would be appreciated. :grinning:

Hi, I have no experience with the extension. I just tried to use it now and failed (I created a panel sprite object but for whatever reason I cannot use it with the conditions of the extension).

Anyway, you you could use a boolean variable that sets your buttons active (variable is set to true) so they can be clicked, hovered etc. and an inactive state (variable is toggled to false) if the player has not enough money.

Thank you. I’m using the panel sprite button not the usual panel sprite. https://wiki.gdevelop.io/gdevelop5/extensions/panel-sprite-button/reference

I don’t want the animation to play when you press the button, instead of playing the animation but not subtracting money

Do you mind sharing your event sheet? In the mid time, you can try loop through items, compare their cost and player’s current amount of money, and deactivate PSB behavior if player doesn’t have enough money. You can do that for example every time AFTER player purchases an item, or receive money, or just that will do that, depends how your game works.

Not sure what you mean here.

I have read the two sentences in the reference but I couldn’t find any ‘panel sprite buttons’ in the asset store. Anyway you got them working and that’s what is important.

I thought about something like this:

All your button actions are determined by the boolean variable.

Since you have obviously many different buttons and you want to disable one after another according to the player’s balance then you need something that GasmoN suggested.

This is the relevant part of my event sheet

The last button extension update (1.4.1) has an action to deactivate interactions.

2 Likes