When I run the below code my roku has a black screen and eventually crashes.
I think the issue is the while true loop but I haven't figured out how to have a wait or sleep
I found sleep() but it did not do anything to stop the crash
Neither did a thing with wait(0,port) (I may have implemented it wrong)
Here are all my files, their names and locations are designated by "FILE pkg:/*****/****.***"
File pkg:/components/Pong.brs
Yeah, you can't do stuff like that on the UI thread - i.e. not in any visual component.
https://developer.roku.com/en-gb/docs/developer-program/core-concepts/threads.md
You could create a 'Task' node which updates its ballXPos field on an interval, and have the UI code watch that field and update the x position when it changes.
Or if you don't want to bother with tasks, you can use a Timer node set to repeat and run your game loop code in that:
https://developer.roku.com/en-gb/docs/references/scenegraph/control-nodes/timer.md
Yeah, you can't do stuff like that on the UI thread - i.e. not in any visual component.
https://developer.roku.com/en-gb/docs/developer-program/core-concepts/threads.md
You could create a 'Task' node which updates its ballXPos field on an interval, and have the UI code watch that field and update the x position when it changes.
Or if you don't want to bother with tasks, you can use a Timer node set to repeat and run your game loop code in that:
https://developer.roku.com/en-gb/docs/references/scenegraph/control-nodes/timer.md
Thank you! This works really well!
A few things about their example for others who might find this thread :
Make sure to change the "extends" thing from "Group" to "Scene"
And you can also set the timer to really low values like 0.01