Clicking a sprite and changing animations question

Hi guys - I’m trying to learn Gdevelop and I have a simple question. I’m clicking a sprite with two animations. If the sprite is on anim1, I’d like it to go to anim2, and if it’s on anim2, i’d like it to go to anim1. I can get it to make the initial change to anim2, but not back to anim1 on the next click. If I try to include the second condition (play anim1 if on anim2) it doesn’t work at all (probably stuck in some loop). I tried using the same logic I’ve used in other tools, but can’t seem to get it to work.

Thank you in advance for any help!

If you’re just switching between 2 animations, then you can use a Boolean variable and toggle it when the sprite is clicked. False = animation1, true = animation2, this should fix your issue. Specifically use the toggle action (not set to true/false).

Yes, using the following events won’t work because the 2nd event will undo the first event.
If 0 make it 1
If 1 make it 0

As said, you can use a boolean variable and toggle it’s value.
Say if it was a door. You can set the animation by number or by name.

Toggle the variable IsOpen
IsOpen is false set animation to 0 (or “Closed”)
IsOpen is True set animation to 1 (or “Opened”)

You could also use mod(#, #)

mod() returns the remainder from dividing the 1st number by the 2nd number. If the 1st number is less than the 2nd number it returns the 1st number.

1 Like

This is totally off topic, but
How do I set my game up so that once it’s published, players can use most of the features for free, but to get access to extra features they have to pay for a subscription. And when the subscription runs out it only allows them to use the free version. And only that one player can use the access he has from the subscription, I don’t want the player to be able to share the game. FYI, yes I understand variables, etc.
Please help?

IDK, try searching for in app purchase

This came up

Thank you weadsy1 and Keith_1357 for your help :slight_smile:

1 Like