Pushing Views with underlying animations

I added some animations to the view directly beneath the topmost view and it seems to consistently crash or not perform correctly.
For example, if I do X.AnimationTimeSensor('Anim').Start it will, in fact, start, but if i pass false for loop it will loop no matter what I do.
Then when animation is finished, it seems to crash as I push a view on top.

Any help is appreciated. Thanks.

If it helps any, Lazarus does not produce an error, as it hangs. but I can get it to point me to castleuicontrols_container.inc and to SavedFrontView.Pause

I would need to see the testcase to reproduce the issue, to help better.

In general, playing animations in our engine definitely works, for looping or not looping animations. And it is simplest to play them using MyScene.PlayAnimation. See our docs that show using scenes and PlayAnimation:

And see examples, like examples/animations/play_animation/.

( Using the MyScene.AnimationTimeSensor(...).Start makes also sense, but only if you want to play multiple simultaneous animations on the same model, like in examples/animations/simultaneous_animations_one_scene/ . )

Looking at the other thread, it seems you are unsure how to create instances of a class. And in above example, X must be valid for the call X.AnimationTimeSensor('Anim').Start to work. So

  • double-check you have created / assigned X properly.
  • And double-check you actually have the animation with given name, so X.AnimationTimeSensor('Anim') is not nil.
  • (And preferably, just use X.PlayAnimation('Anim') which is simpler and advised in most cases.)

While I am having issues with class instances and what not (this is my first real foray into anything past somewhat basic scripting [and even then it was usually bash]), I believe everything to be in order. Everything compiles on run (at least on lazarus, as I use the LCLIntF unit in this project) but when actually running it hangs and dies the second I use animations on the second-most view (Office).

Source code can be found below. As always, thank you for your help (and patience :sob:)

ACompleteForfeit-0.1-src.zip (30.2 MB)

After seeing it after sleeping im just blind and was calling things in the update method, mb

1 Like

OK, cool, thank you for sending the testcase – I was going to analyze it now, but I understand it’s solved now :slight_smile: Thank you!

And no worries, we’re patient :), I’m happy to help with any issues. We all learn :slight_smile:

Note: Still I recommend to follow my advise and use X.PlayAnimation(...) most or the time.

  • I see you use X.AnimationTimeSensor(...).Start often in your project, but this is a more specialized way to play animations (useful only really if you want to play multiple animations in one TCastleScene simultaneously, like in castle-engine/examples/animations/simultaneous_animations_one_scene at master · castle-engine/castle-engine · GitHub ). For most usage of animations, X.PlayAnimation(...) is simpler and better.

  • Also X.PlayAnimation(...) makes a nice warning in the log when given animation doesn’t exist. In contrast, using X.AnimationTimeSensor(...).Start will just crash with SIGSEGV when the animation doesn’t exist, because X.AnimationTimeSensor(...) is nil. You could secure from it, doing code like

    MyAnim := X.AnimationTimeSensor('foo');
    if MyAnim = nil then
      WritelnWarning('No animation foo on scene ' +X.Name)
    else
      MyAnim.Start(...)
    

    … but it’s simpler to just use X.PlayAnimation in most cases :slight_smile: