Skip to main content
WScot.1
Associate III
August 19, 2022
Question

On Off button Animation.

  • August 19, 2022
  • 4 replies
  • 1164 views

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
August 19, 2022

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

WScot.1
WScot.1Author
Associate III
August 22, 2022

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
August 23, 2022

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
August 24, 2022

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