admin管理员组文章数量:1400533
I am trying to implement a screen transition effect in Crank Storyboard using Lua. The goal is to play an animation first and then switch to the target screen. However, when I run my script, the animation does not play—it directly switches to the next screen.
Here's the code I am using:
Copy
Edit
function hide_info_layer(screen)
if screen then
gre.set_layer_attrs_global(screen, { hidden = 1 })
else
print("Error: screen is nil in hide_info_layer")
end
end
function screen_transition(target_screen)
if target_screen then
print("Transitioning to:", target_screen)
gre.set_value("target_sc", target_screen)
gre.send_event("gre.load_screen", target_screen) -- Directly load the screen
else
print("Error: target_screen is nil in screen_transition")
end
end
function cb_presstart_button(mapargs)
local current_screen = mapargs.context_screen
local control = mapargs.context_control
-- Fetch correct screen name
local target_screen = gre.get_value(string.format("%s.screen_name1", control))
print("Current Screen:", current_screen)
print("Target Screen:", target_screen)
if current_screen == target_screen then
print("Already on target screen, no transition needed")
return
end
hide_info_layer(current_screen)
if current_screen == "start" then
gre.set_value("target_sc", target_screen)
print("Triggering animation: punch_NewAnimation")
gre.animation_trigger("punch_NewAnimation")
else
print("Calling screen_transition")
screen_transition(target_screen)
end
end
Observed Behavior:
The animation punch_NewAnimation
does not play when transitioning between screens.
The screen changes immediately after calling gre.animation_trigger()
, skipping the animation effect.
The console prints the expected logs but does not execute the animation before the screen transition.
Attempts to Resolve:
Delaying Screen Change Until Animation Ends
I tried adding a delay after triggering the animation but didn't find a direct way to ensure the transition happens only after the animation completes.
Using Animation Callbacks
I attempted to listen for an animation event before triggering the screen change but couldn't find a working solution.
Expected Behavior:
The animation (punch_NewAnimation
) should play completely.
After the animation finishes, the screen should transition to target_screen
.
Question: How can I ensure that the animation plays fully before transitioning to the next screen? Is there a way to use animation callbacks or events to handle this properly in Crank Storyboard?
本文标签:
版权声明:本文标题:lua - Issue with Screen Transition Animation Not Playing Before Screen Change in Crank Storyboard - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744257643a2597558.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论