Roku基本应用程序创建

时间:2016-10-18 11:53:03

标签: roku

我已经在设备和一个基本的hello world程序上完成了roku设置。

接下来我要创建一个带徽标的布局对齐。很难搜索这个来源。有人可以帮我解决这个问题吗?

2 个答案:

答案 0 :(得分:1)

如果没有更多细节,这真的不是一个可回答的问题。有不同的方法可以做到这一点。使用roScreen或roImagecanvas进行只是所描述内容的最简单方法,但每个选项都需要更多问题。 浏览Roku SDK中的示例。找到看起来很有趣的东西并侧面加载它们并查看源代码,你会在那里找到很多答案。

答案 1 :(得分:0)

首先创建这些文件:在源文件夹中的main.brs,LayoutTop.xml,LayoutTop.brs,HomeScene.xml和组件中的HomeScene.brs。然后在这些文件中添加以下代码: main.brs文件:

sub Main()
    showSGScreen()
end sub

sub showSGScreen()
    screen = CreateObject("roSGScreen")
    m.port = CreateObject("roMessagePort")
    screen.setMessagePort(m.port)
    m.scene = screen.CreateScene("HomeScene")
    screen.show()

    while(true)
        msg = wait(0, m.port)
    msgType = type(msg)
        if msgType = "roSGScreenEvent"
            if msg.isScreenClosed() then return
        end if
    end while
end sub

<强> LayoutTop.xml:

<?xml version="1.0" encoding="UTF-8"?>
<component name="layoutTop" extends="Group" xsi:noNamespaceSchemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd">

<script type="text/brightscript" uri="pkg:/components/LayoutTop.brs"/>
<children>
    <Poster
      id="backgroundPoster"
      uri="pkg:/images/backgroundTop.jpg"
      width="1920"
      height="150"
      translation="[0, 0]" 
    />


    <Poster
      id="icon"
      uri="pkg:/images/html5.png"
      width="128"
      height="128"
      translation="[10, 10]" 
    />

</children>

</component>

LayoutTop.brs:

sub init()

end sub

<强> HomeScene.xml:

<?xml version="1.0" encoding="UTF-8"?>
<component name = "HomeScene" extends = "Scene" >
<script type="text/brightscript" uri="pkg:/components/HomeScene.brs"/>
<children>
    <Poster
      id="background"
      uri="pkg:/images/background.jpg"
      width="1920"
      height="1080"
      translation="[0, 0]" 
    />

    <Group >
        <layoutTop
          translation="[0, 0]" 
        />

    </Group>

  </children>
</component>

<强> HomeScene.brs:

sub init()

end sub

毕竟,你应该在你的Roku上获得这个屏幕: enter image description here

相关问题