Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
dreamer2057
Level 7

Dynamic animation

Can I work with animation dynamically?

those code from xml can be moved into brightscript?

<ParallelAnimation   id = "ShowMenu" > <!--** ParallelAnimation   id = "testParallelAnimation"   repeat = "true" **-->
<Animation id = "testPosterAnimation" duration = "1" easeFunction = "linear" >
<Vector2DFieldInterpolator key= "[0, 1]" keyValue= "[ [640, 1000], [640, 620] ]" fieldToInterp="menuBar.translation" />
<FloatFieldInterpolator key= "[0, 1]" keyValue= "[ 0.2, 1]" fieldToInterp="menuBar.opacity" />
</Animation>
<Animation id = "testPosterBckgAnimation" duration = "1" easeFunction = "linear" >
<Vector2DFieldInterpolator key= "[0, 1]" keyValue= "[ [0, 870], [0, 490] ]" fieldToInterp="testPosterBckg.translation" />
<FloatFieldInterpolator key= "[0, 1]" keyValue= "[ 0.2, 1 ]" fieldToInterp="testPosterBckg.opacity" />
</Animation>
<Animation id = "testPosterSelectAnimation" duration = "1" easeFunction = "linear" >
<Vector2DFieldInterpolator key= "[0, 1]" keyValue= "[ [230, 910], [230, 530] ]" fieldToInterp="testPosterSelect.translation" />
<FloatFieldInterpolator key= "[0, 1]" keyValue= "[ 0.2, 1 ]" fieldToInterp="testPosterSelect.opacity" />
</Animation>
</ParallelAnimation>
Sincerely, Sergey Shoshin, software developer.
0 Kudos
7 REPLIES 7
lumpenprole
Level 7

Re: Dynamic animation

So, I'm curious about this too. It seems like trying to set fieldToInterp in code fails. Can we get an example of this?
0 Kudos
jaxim
Level 8

Re: Dynamic animation

I am just encountering this. Was there ever a resolution to this? Can we dynamically modify the "fieldToInterp" field?
0 Kudos
lumpenprole
Level 7

Re: Dynamic animation

I've never found a solution. I set a bunch of stripped down animations in the xml, and modify what I can in the code. 
0 Kudos
jaxim
Level 8

Re: Dynamic animation

actually, I found a solution that works for me.
It works when I set the fieldToInterp in the code. I am animating a screen. Here is my code...

screenAnimationInterp.fieldToInterp = screen.id + ".opacity"
screenAnimation.control = "start"
0 Kudos
ajitg_4557
Level 8

Re: Dynamic animation

   i, jaxim
   can you share some part of the code snippet, where you write code for screen animation and also how you find screen id?
    :shock:  :idea:
thanks in advance.
0 Kudos
squirreltown
Level 9

Re: Dynamic animation

I don't use XML at all. All animations can be done in Brightscript .
Init:
m.mainannie = m.top.createChild("ParallelAnimation")        
m.mainannie.id="ThisAnnie"
m.mainannie.repeat = false


m.nodez.clr[i]=m.mainannie.CreateChild("Animation")
m.nodez.clr[i].id="color_"+i.toStr()
 m.nodez.clrcha[i]=m.nodez.clr[i].CreateChild("ColorFieldInterpolator")
 m.nodez.clrcha[i].id="colorcha_"+i.toStr()
 m.nodez.clrcha[i].fieldToInterp= "player_"+i.toStr()+".blendcolor"
 etc.....
                                     

m.mainannie.control = "start"
Kinetics Screensavers
0 Kudos

Re: Dynamic animation

"squirreltown" wrote:
I don't use XML at all. All animations can be done in Brightscript .
Init:
m.mainannie = m.top.createChild("ParallelAnimation")        
m.mainannie.id="ThisAnnie"
m.mainannie.repeat = false


m.nodez.clr[i]=m.mainannie.CreateChild("Animation")
m.nodez.clr[i].id="color_"+i.toStr()
 m.nodez.clrcha[i]=m.nodez.clr[i].CreateChild("ColorFieldInterpolator")
 m.nodez.clrcha[i].id="colorcha_"+i.toStr()
 m.nodez.clrcha[i].fieldToInterp= "player_"+i.toStr()+".blendcolor"
 etc.....
                                     

m.mainannie.control = "start"


Can confirm that this works. I was creating separate objects, then using `#appendChild` to construct the node tree. However, that was not working properly. Instead I decided to use `#createChild`. Here is a code sample:
function _createAnimation(objToAnimate as Object) as Object
 animation = createObject("roSGNode", "Animation")
 animation.id = Substitute("{0}{1}", objToAnimate.id, "Animation")
 animation.delay = 1
 animation.duration = 5
 animation.easeFunction = "linear"

 floatField = animation.createChild("FloatFieldInterpolator")
 floatField.key = [0.0, 0.125, 0.250, 0.375, 0.5, 0.625, 0.750, 0.875, 1.0]
 floatField.keyValue = [0.0, 0.25, 0.5, 0.75, 1.0, 0.75, 0.5, 0.25, 0.0]
 floatField.fieldToInterp = "ticker.opacity"

 return animation
end function
0 Kudos