Problem using animation with text

edited November 2013 in Help request
Is it be possible to have an animation that contains "text graphics"? For example, I would expect the following to alternate between HELLO and WORLD, but it just shows HELLO:
[ExampleObject]
Graphic = ExampleGraphic1
AnimationSet = ExampleAnimationSet

[ExampleGraphic1]
Text = ExampleText1
Color = (0, 0, 0)

[ExampleGraphic2]
Text = ExampleText2
Color = (0, 0, 0)

[ExampleText1]
String = HELLO
Font = Font1

[ExampleText2]
String = WORLD
Font = Font1

[ExampleAnimationSet]
AnimationList = ExampleAnimation
LinkList = ExampleLink

[ExampleAnimation]
DefaultKeyDuration = 0.1
KeyData1 = ExampleGraphic1
KeyData2 = ExampleGraphic2

[ExampleLink]
Source      = ExampleAnimation
Destination = ExampleAnimation

If I replace the text graphics with textures, it works as expected:
[ExampleObject]
Graphic = ExampleGraphic1
AnimationSet = ExampleAnimationSet

[ExampleGraphic1]
Texture = hello.png

[ExampleGraphic2]
Texture = world.png

[ExampleAnimationSet]
AnimationList = ExampleAnimation
LinkList = ExampleLink

[ExampleAnimation]
DefaultKeyDuration = 0.1
KeyData1 = ExampleGraphic1
KeyData2 = ExampleGraphic2

[ExampleLink]
Source      = ExampleAnimation
Destination = ExampleAnimation

I'm thinking of using different objects instead (ie one object for "hello" and one for "world") and writing custom animation code but before I go down that path I just wanted to check if I'm missing something basic here...?

Comments

  • edited November 2013
    Hi Boxjar,

    Animations aren't supported for text objects yet but I think it should be pretty straightforward to add this. I'll investigate. In the meantime, I'd suggest using a track in order to accomplish what you want as it's less verbose and much more flexible:
    [ExampleObject]
    Graphic = @
    Text = @
    String = HELLO
    TrackList = ExampleTrack
    
    [ExampleTrack]
    0.25 = Object.SetText ^ WORLD
    0.5 = Object.SetText ^ HELLO
    Loop = true
    

    Of course the track could retrieve the different text parts from config instead of having them "hardcoded".

    Something like:
    [ExampleObject]
    Graphic = @
    Pivot = center
    Text = @
    String =
    TrackList = ExampleTrack
    StringList = HELLO # WORLD # HOW ARE YOU # ?
    Index = 0
    
    [ExampleTrack]
    Loop = true
    0.5 = >> Config.GetValue ExampleObject Index            # ; Get current index, push it twice on the stack
          >  Config.GetValue ExampleObject StringList <     # ; Get word at current index (pop), push it
             Object.SetText ^ <                             # ; Set owner's text with that word (pop)
          >> + < 1                                          # ; Increment current index (pop) and push it twice
          >  Config.GetListCounter ExampleObject StringList # ; Get words in list count, push it
          >  == < <                                         # ; Are count (pop) and new index (pop) equal? push test result
          >  If < 0 <                                       # ; if <test result> (pop) then push 0 otherwise push new index
             Config.SetValue ExampleObject Index <            ; Store new index in config (pop)
    

    You can change the content of ExampleObject.StringList at will, even during runtime (though if you remove words, the "==" test might fail in some cases and you'd need an extra command in the tracklist (min) before doing the comparison).
  • edited November 2013
    I just added animation support for object using text graphics (one could presumably mix & match between text and texture though I haven't tested it).
    In the same time, I also added flipping support for objects using a text graphic. :)
  • edited November 2013
    That's fantastic, thanks iarwain! I'll pull the changes and have a play.

    Haven't used the track feature at all yet but it looks extremely useful to me. Always good to have different options.
  • edited November 2013
    My pleasure. I just realized yesterday I forgot to push my commit on the central repository, it's now done.

    As for the timeline/tracks, here's a more detailed summary of that feature.
  • edited November 2013
    Just saw that the fix was available now so did a quick test. My use case is actually that I'm displaying the same text string, but with different fonts (which I admit may sound a bit mad) and it's now working perfectly. Thanks again!
Sign In or Register to comment.