How do I…
Hey guys, I’m still a newbie and I’m scratching my head at this one.
I applied a scale tween to button (panel sprite) object ButtonTryAgain and whenever I hover on the button, the size of the object gets bigger, it doesn’t reset to its original size.
I want the button to get bigger a bit only when its hovered, but instead it inflates.
Can someone with more experience have a look at it, I would highly appreciate it.
So it increases in size once and then that’s it? If so, try adding a
Remove tween 'D' from ButtonTryAgain before the reduction tween.
Thanks, but when I insert what you just suggested between the first tween and wait expression, the whole event gets cancelled out. Literally nothing happens. The weird thing is that I use the exact same tween structure for another object and it works just fine.
I tinkered with this issue and it seems to me that for some reason it doesn’t know the object’s default size(on the screen with 192x192), it behaves in relation to the new size(s).
Could this be caused by the fact that I manually changed the size of the object? What I mean is that the original size was 32x32 but I scaled it up manually to 192x192.
No, add it after the wait instruction. If you do it before the wait then it deletes the inflate tween before the tween has a chance to start.
Personally, I’m not a big fan of using the wait action in this manner.
I’d have the inflate tween in the event preceded by a
"Remove tween 'E' from ButtonTryAgain", and remove the wait and deflate tween actions.
Then I’d also add a new event with conditions that checks
"Tween "D' of ButtonTryAgain has finished", and as actions removes tween “D” and starts the deflate tween “E”.
Check if is this you’re trying to do.
I believe the wait action was to give time for the first/inflate tween finish before starting the second/deflate tween. It wasn’t to act as a delay between animations, which is what the events in your screen shot will do. They add a 0.2s pause between animations sequences.
As far as I know tweens are inherently incompatible with Waits, because tweens are using their own internal timers to operate.
You cannot use a wait with a tween as the previous tween may not finish correctly, or the next one may not start correctly.
There are efforts to make tween-specific wait actions available, though. Add await tween action by arthuro555 · Pull Request #3834 · 4ian/GDevelop · GitHub
No ETA on if/when it goes live.
His code is a bit confuse. Maybe you are correct, and if so, the way he did it makes no sense at all.
I tried this one too, and it still inflates more and more everytime I hover on it.
Here is what I did:
And its result:
Thats just one hover, if I move the cursor out and back in again, it gets even bigger, the deflate tween doesn’t seem to work.
Interesting, because for another object I use exactly that, a wait expression with tweens and it works well.
I tried it without any waits. A scale of just 1.2 caused the button to grow so large that it expanded off the screen.
I don’t think it has anything to do with the wait. I think it’s because it’s a button object. They’re more like containers than a single object. Like sliders, they don’t always resize well. I’m wondering if there’s a conflict between the button object and the object it contains.
A normal scale action of 1.2 works fine but when I try to use a tween to do it, it becomes huge.
Edit: I did more testing. I think everytime you a scale a button it resets the scale to the new size. So, the next scale bases it on the new scale not the original. (This might apply to all of the newer container like objects)
I think as well the observation you made in ‘Edit’ is the underlying issue, I pointed it out in a post above, that’s what I meant by behaving in relation to new sizes.
There has to be a conflict in the extension you just described, I remade the button with a regular sprite object and the problem seems to be solved.
Here’s the sprite object with tweens:
This way it works as intended even with the wait expression. Thank you for testing and helping me with the problem.
On a side note, if it is really a conflict with the object type(at least it seems to me, but I’m still a beginner) shouldn’t this be reported to the devs or authors of the extension(PanelSpriteButton)?
You’re welcome. Yes, this does seem to be a bug and should be reported.
If it works, I’m glad. I can only tell you what the actual dev group says (as shown in that PR and others), in that waits are currently incompatible with tweens.
It might be more of a “wait does not work properly with tweens” rather than “won’t work with tweens” though.