2017-06-28 10 views
0

私は、ユーザーがリモコンを押したときにボックスの高さをどのように変更するかを考えようとしています。ここでKeypress上の矩形の高さを変更するには?

<component name="PlutoScene" extends="Scene"> 

    <script type="text/brightscript" uri="pkg:/components/homescreen.brs" /> 

    <children> 
    <LayoutGroup id="root"> 
    <Rectangle id="header" width="1280" height="300" color="0x000000"> 
    </Rectangle> 
    <LayoutGroup id="body" layoutDirection="horiz"> 
    <Rectangle id="rect1" height="270" width="400" color="0xffffff" /> 
    <Rectangle id="rect2" height="270" width="2" color="0x000000" /> 
    <Rectangle id="rect3" height="270" width="878" color="0xffffff" /> 
    </LayoutGroup> 
    <Rectangle id="footer" width="1280" height="150" color="0x000000"> 
    </Rectangle> 
</LayoutGroup> 
</children> 
</component> 

をhomescreen.brsファイル内の関数である:

はここで、コンポーネントの

sub init() 
m.rect1 = m.top.findNode("rect1") 
m.rect = m.rect1.boundingRect() 
end sub 

function onKeyEvent(key as String, press as Boolean) as Boolean 
if press then 
    if (key = "Up") then 
    m.rect.height = m.rect.height * 2 
    end if 
end if 
end function 

答えて

2

それはそれよりも簡単です。 onKeyEventを次のように変更してください。

function onKeyEvent(key as String, press as Boolean) as Boolean 
if press then 
    if (key = "Up") then 
    m.rect1.height = m.rect1.height * 2 
    end if 
end if 
end function 
関連する問題