[Solved] "Cursor on" I found a bug?

Hello all,
I noted a bug using “cursor on” condition.
I’m using Gdevelop Beta 91 on Mint Linux.

The bug is that if I change the order condition the game doesn’t work:


Works well


Failed.

The same commands. I changed only the order.

I hope that my discover can help someone else. (I lost a lot of time to correct the code).

Bye,
J

As a heads up, b91 is old, make sure you update to b92.

As far for your question:

All events happen every frame, in the order they appear in the event list (from top to bottom).

Looking at your events, it may be that it’s having an issue changing the animation fully because you have it happening every frame.

Even if it is fixed, I’d recommend adding the “Trigger Once” condition to both of your events (so it changes the animation only when the condition is first met, rather than every frame the condition is met)

This might help with performance issues down the road.

Hello Silver,
thanks for your answer. Sorry, i don’t understand: the condition is to check if two sprites are colliding (cursor and another object). If yes the cursor arrow become a Hand, if not it is displayed the arrow. It is necessary to check it every frame. I don’t understand why to use once.
Bye,
J

The main reason why you’d want to use “Trigger once” is because you only need to know when either condition is True, as you have 2 events (and therefore are accounting for each state)

E.g. Once you’re in collision, you know you’re in collision, and don’t have to keep knowing this every frame. Therefore you need to only change the state to 1 once, not constantly change the state to 1 every.
Once you’re no longer in collision, you then change the state to 0, but do not need to keep knowing you’re not in collision. You only care once you’re in collision again, which you have covered with your first event.

To be clear, “Trigger once” doesn’t mean “Trigger only once per game, forever”, it means " Trigger once true, but do not trigger again until it becomes false".

1 Like

I miss this specificity always.

So without “Trigger once” your “set animation” are trigger for each frame.
The animation is reset to the first frame each frame, that why people think the event are bugged, but isn’t.

Hello Bouth,
I tried with “once” but it doens’t work.
I tried also to add a text modify (not change animation) but the result is the same:
If you put:

  • touch isn’t on “sprite” → text 1
  • touch is on “sprite” → text 2
    works well
    but
  • touch is on “sprite” → text 2
  • touch isn’t on “sprite” → text 1
    doesn’t work.

I really don’t understand. I suppose that is a bug but the important thing is to understand the workaround.
The same with Beta92 (O.S. Linux Mint)

Bye,
J

I don’t understand your bug.
When i do
image
Link

or


Link
When my cursor is on the object value is 2

Hello Bouth,
this is the project:

https://drive.google.com/open?id=1_PMQq2kEgy3lkg0tem-lO_I3uCH4aCWH

In Main1 you’ll find the "cursor on " conditions; It works well but if you reverse the blocks order it failed.

I really don’t why.

Bye,
J

OK i’ve looked why, and it’s not a bug.
I’ve tried on previous build b87, it work same.
It’s because you use multiples instance of the same object.

For the first instance, ok you are on it debug = “11”
but the others instance you are not on it, so debug goes to “11” to “00”

The eventsheet are read from top to the bottom. The order of your events have an importance.
Because you use multiple instance of your object on scene, the behavior is a bit more tricky to understand.

Oh my Gosh, you are right !!!
Sorry for my questions.

Thanks a lot,
J

Read the basic concept of events in GD are really important for me and you, i miss this point sometime ^^

1 Like