I've been trying to program a circle button, but the animation and positioning has been wonky thus far and it's driving me crazy. Essentially, it is comprised of two images: one larger white circle and one smaller brown circle. It should theoretically look like this:
- theoretical circle button.png (3.51 KiB) Viewed 1266 times
They are separated because of the animation I wanted. When you hover over it, the smaller circle becomes a different color (also a separate image) and becomes bigger. However, I haven't been ideally successful. Whenever I get one part right, something else always goes awry. Here is the code I have been using for now that
doesn't have any positioning issues:
Code: Select all
screen circlebuttons:
zorder 100
fixed:
image "circle_back":
xalign 0.5 yalign 0.5
button:
xalign 0.5 yalign 0.5
add "circle_small"
action NullAction()
image circle_small:
on idle:
"gui/circlesmall_idle.png"
xanchor 0.0 yanchor 0.0
zoom 1.0
on hover:
"gui/circlesmall_hover.png"
xanchor 0.0 yanchor 0.0
linear 0.5 zoom 1.1
image circle_back:
"gui/circle_back.png"
xalign 0.5 yalign 0.5
The only issue with this code is that the hover animation is inconsistent. For some odd reason, it only works whenever you first hover over the button, and then it just flashes back and forth from the hover and idle images without zooming (and then eventually doesn't sense hovering anymore). If I remove
linear 0.5, it's perfectly fine though. However, I'd ideally like to have
linear 0.5 be there since the animation I have in mind needs to have a smooth transition. If there's anyway to have this work, that'd be wonderful!