_rossbower
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2016
11:32 AM
Create animation in BrightScript?
I would like to create an animation node purely in BrightScript, no XML involved. I have created the following function:
This mirrors an animation node I have created in XML. As far as I can tell, all fields are identical on my programmatically-created animation node and my XML-created node. However, the animation node I created in code doesn't run, while the one I created in XML does. Is created animation nodes in BrightScript not supported? If so, why not? What prevents this from working?
function SymetricScaleAnimation(target as object) as object
print "In SymetricScaleAnimation"
animation = CreateObject("roSGNode", "Animation")
animation.duration = .15
animation.repeat = true
animation.easeFunction="linear"
animatin.id = "animateScaleBS"
interp = CreateObject("roSGNode", "Vector2DFieldInterpolator")
interp.key = [0.0, 1.0]
interp.keyValue = [[1,1], [3,3]]
interp.fieldToInterp = target.id + ".scale"
animation.AppendChild(interp)
return animation
end function
This mirrors an animation node I have created in XML. As far as I can tell, all fields are identical on my programmatically-created animation node and my XML-created node. However, the animation node I created in code doesn't run, while the one I created in XML does. Is created animation nodes in BrightScript not supported? If so, why not? What prevents this from working?
3 REPLIES 3

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2016
01:22 PM
Re: Create animation in BrightScript?
You have a typo in the code.
I wonder if that's causing it to crash the thread or if it's a copy/paste error in your post. Are you seeing any errors in the SG debugger consoles?
animatin.id = "animateScaleBS"
I wonder if that's causing it to crash the thread or if it's a copy/paste error in your post. Are you seeing any errors in the SG debugger consoles?
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)

RokuJoel
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2016
01:31 PM
Re: Create animation in BrightScript?
Engineering says:
Joel
Animaton nodes have to be associated with a Scene in order to work. If they are created in the scene graph render thread, that happens by default. If you create them in the main Brightscript thread or a task thread, it doesn’t.
In that case, parenting the Animation node to any node in the Scene’s scene graph will cause that association to happen. So instead of using CreateObject(“roSGNode”, “Animation”), try this:
animation = someNode.createChild(“Animation”)
where someNode is either the Scene node or any node that is parented to the Scene.
Generally, other than ContentNodes, creating nodes in the main Brightscript thread is not a recommended best practice for using the scene graph APIs.
Joel
_rossbower
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2016
01:58 PM
Re: Create animation in BrightScript?
"RokuJoel" wrote:
Engineering says:Animaton nodes have to be associated with a Scene in order to work. If they are created in the scene graph render thread, that happens by default. If you create them in the main Brightscript thread or a task thread, it doesn’t.
In that case, parenting the Animation node to any node in the Scene’s scene graph will cause that association to happen. So instead of using CreateObject(“roSGNode”, “Animation”), try this:
animation = someNode.createChild(“Animation”)
where someNode is either the Scene node or any node that is parented to the Scene.
Generally, other than ContentNodes, creating nodes in the main Brightscript thread is not a recommended best practice for using the scene graph APIs.
Joel
Thanks Joel, this solved my issue! I ended up creating a component and defining the animations in XML, but reparenting the animations was the key.