scaper12123
9 years agoVisitor
Help with using roSGNode?
EDIT: My problem has changed slightly, but it still involves roSGNodes so I'll just append this post with the issue I'm having. If anybody can help me I would very much appreciate it! I'm having trouble understanding how to add fields to the roSGNode when I create them, and how to make them the focused object on the screen. The following is my code with my best guess as to how it's done. I would appreciate it if somebody could help me figure out what I'm doing wrong (when I attempt to create a node, I get an error in the console saying "Failed to create roSGNode with type Label":
---------------------
I'm trying to use roSGNode to make a label in order to provide a user with some information, but my attempts to learn how to use roSGNode have been turning up stagnate. The documentation only tells me how to form the node, and I don't know how to get all the data I need into the node object or how to properly display it. Below is my current attempt which failed.
Apparently you're not supposed to use the node.field subtext even though the documentation suggests doing so. Could somebody help me straighten out what I'm supposed to do in this scenario?
EDIT: I tried investigating the documentation and used this code to see what would happen:
When I ran the program, it told me that it failed to create an roSGNode with type Label, even though it worked the first time. Am I missing something?
'live is an associative array with the following values:
' start = time which the stream should start
' end = predicted end time for the livestream
' current = a roDateTime object to represent the system time (in UTC)
'stream is just an associative array with one member: stream
' stream contains the fields needed to create the livestream,
' when used as a field in VideoPlayer()
sub CountdownDisplay(live as object, stream as object)
'create initial objects and show scene, so node can be created later
screen = CreateObject("roSGScreen")
port = CreateObject("roMessagePort")
screen.SetMessagePort(port)
screen.Show()
'obtain the time left for initial display of countdown timer
secondsLeft = live.start.AsSeconds() - live.current.AsSeconds()
'here I need to do something to create a visual countdown display
countdown = CreateObject("roSGNode", "Label") 'because this fails to execute, the following three lines crash the program
countdown.vertAlign = center
countdown.horizAligin = center
countdown.text = CountdownTime(secondsLeft) 'CountdownTime() returns a string with format hh:mm:ss
while true
msg = wait(1000, port) 'check for updates every second
if msg = Invalid
live.current.Mark() 'mark the time to ensure it's up to date
secondsLeft = live.start.AsSeconds() - live.current.AsSeconds() 'update secondsLeft
if secondsLeft > 0
'here I need to modify the countdown to display an updated time
countdown.text = CountdownTime(secondsLeft)
else
'assume wait time is over, get rid of the countdown screen, and go to the livestream
screen.Close()
VideoPlayer(stream)
end if
else if type(msg) = "roSGScreenEvent"
if msg.IsScreenClosed()
exit while
end if
end if
end while
return
end sub
---------------------
I'm trying to use roSGNode to make a label in order to provide a user with some information, but my attempts to learn how to use roSGNode have been turning up stagnate. The documentation only tells me how to form the node, and I don't know how to get all the data I need into the node object or how to properly display it. Below is my current attempt which failed.
screen = CreateObject("roSGScreen")
port = CreateObject("roMessagePort")
screen.setMessagePort(port)
'scene = screen.CreateScene("timer")
screen.show()
label = CreateObject("roSGNode", "Label")
label.horizAlign = "center"
label.vertAlign = "center"
label.translation="[0,500]"
label.width="1280"
label.text = "there is no stream right now."
label.setFocus()
Apparently you're not supposed to use the node.field subtext even though the documentation suggests doing so. Could somebody help me straighten out what I'm supposed to do in this scenario?
EDIT: I tried investigating the documentation and used this code to see what would happen:
screen = CreateObject("roSGScreen")
port = CreateObject("roMessagePort")
screen.setMessagePort(port)
'scene = screen.CreateScene("timer")
screen.show()
label = CreateObject("roSGNode", "Label")
aa={horizAlign: "center"
vertAlign: "center"
translation: "[0,500]"
width: "1280"
text: "there is no stream right now."
}
label.AddFields(aa)
label.setFocus()
When I ran the program, it told me that it failed to create an roSGNode with type Label, even though it worked the first time. Am I missing something?