egret GUI 和 egret Wing 是我看到h5 最渣的設計

一個抄襲FlexLite抄的連本身思想都沒有,別人精髓都不懂的垃圾框架。也不學學MornUI,好歹有點本身想法。web

 

先來個最小可用集合吧:json

 

1. egret create legogame --type gui。生成一個帶gui的項目。框架

2. 用webstorm打開這個傻逼項目。webstorm

3. 修改theme.thm:ui

{
    "skins":
    {
        "egret.gui.Button":"skins.simple.ButtonSkin"
    }
}

4. 修改resource.jsonthis

{
    "groups":[
    {
        "keys":"button_disabled_png,button_down_png,button_normal_png,bgImage",
        "name":"preload"
    }],
    "resources":[
    {
        "name":"button_disabled_png",
        "scale9grid":"3,4,14,13",
        "type":"image",
        "url":"assets/simple/NormalButton/button_disabled.png"
    },
    {
        "name":"button_down_png",
        "scale9grid":"4,3,13,14",
        "type":"image",
        "url":"assets/simple/NormalButton/button_down.png"
    },
    {
        "name":"button_normal_png",
        "scale9grid":"4,3,13,15",
        "type":"image",
        "url":"assets/simple/NormalButton/button_normal.png"
    },
    {
        "name":"bgImage",
        "type":"image",
        "url":"assets/bg.jpg"
    }
    ]
}

5. 進入resource/assets/simple目錄,保留NormalButton,其餘刪掉。進入src/skins/simple/ 除了buttonskin.exml,其餘刪掉。url

6. 進入ShowcaseSkin.exml, 刪除List,獲得:spa

<?xml version='1.0' encoding='utf-8'?>
<e:Skin width="480" height="800" xmlns:e="http://ns.egret-labs.org/egret" xmlns:w="http://ns.egret-labs.org/wing">
    <w:HostComponent name="egret.gui.SkinnableComponent"/>
    <w:Declarations/>
    <e:states>
        <e:State name="normal"/>
        <e:State name="disabled"/>a
    </e:states>
    <e:Button id="btnShowMessage" label="click" y="50" horizontalCenter="0"/>
</e:Skin>

7. 進入Showcase.ts,除了button,其餘都刪除:code

class Showcase extends egret.gui.SkinnableComponent {

    public constructor() {
        super();
        this.skinName = "skins.scene.ShowcaseSkin";
    }

    public btnShowMessage:egret.gui.Button;

    public partAdded(partName:string, instance:any):void {
        super.partAdded(partName, instance);
    }
}

8. 在legogame目錄下面,運行egret build, egret startserver。獲得只有一個button的結果。orm

 

這個就是最小可用集:Mininum available set。

 

繼續研究resource.json和theme.thm是否是多餘的。還有那個buttonskin.exml 文件

相關文章
相關標籤/搜索