Skip to main content
WScot.1
Associate III
Aug 19, 2022 3:54 PM UTC
Question

On Off button Animation.

I have an on/off button animation which rotates 90 anti-clockwise on switch-off and rotates 90 clockwise on switch-on. The problem I have is that the Animation resets when I change screen and I don't always want this to happen?

This topic has been closed for replies.

4 replies

MM..1
Super User
Aug 19, 2022 7:13 PM UTC

Show your setup screen func, or place here setup state.

WScot.1
WScot.1Author
Associate III
Aug 22, 2022 9:03 AM UTC

One way to solve this is to have two animations, an 'on' to 'off' and an 'off' to 'on' animation. Simply control the alpha values to the correct animation when a screen change occurs. I don't know if there's another way to do this with just one animation that would be neater?

::setupScreen()

state = presenter->getState();

if(state)

{

animation1.setAlpha(ON);

animation2.setAlpha(OFF);

}

else

{

animation1.setAlpha(OFF);

animation2.setAlpha(ON);

}

wired
Senior II
Aug 23, 2022 6:40 PM UTC

animatedImage widget can be set to reverse the direction of animation. You just need to remember the last direction that was set.

WScot.1
WScot.1Author
Associate III
Aug 24, 2022 8:00 AM UTC

Thanks for your reply, I haven't tried that, but I will now. Thanks again. Will.