Search code examples
animationrokubrightscriptscenegraph

How to change the interpolator(s) on a Roku Scenegraph animation node?


Taking an example from the Roku SDK docs:

<Animation id="transAnimation"
       duration="1"
       repeat="true"
       easeFunction="linear" >
    <Vector2DFieldInterpolator id = "myInterp2"
        key="[0.0, 1.0]"
        keyValue="[ [640.0, 320.0], [100.0, 100.0] ]"
    fieldToInterp="myPoster.translation" />
</Animation>

After I've done a find on "transAnimation" is it possible to change the interpolator in brightscript code? There are interpolators present in the XML, but after the scenegraph is built they no longer appear as children of my animation node.


Solution

  • Yes you can do that, find the interpolators with m.top.findNode and modify the reverse value like so

    myInterp2 = m.top.findNode("myInterp2")  
    myInterp2.reverse = true  
    

    Assuming this is a toggle-able item you'll need to unset the reverse in the original animation:

    myInterp2 = m.top.findNode("myInterp2")  
    myInterp2.reverse = false  
    

    HOWEVER, I just went through this last week and for some reason could not get it to work on Roku 4 despite it having 7.7 (worked fine on 1, 3, and ultra but on R4 it did not reverse?!), so rather than goof around with it for hours I went back to adding a separate animation to handle the reverse.