{"id":514,"date":"2015-12-07T18:30:12","date_gmt":"2015-12-07T10:30:12","guid":{"rendered":"http:\/\/39.100.100.179\/?p=514"},"modified":"2016-10-11T09:30:08","modified_gmt":"2016-10-11T01:30:08","slug":"2-5-0%e7%ae%a1%e7%90%86%e8%87%aa%e5%ae%9a%e4%b9%89%e7%9a%ae%e8%82%a4","status":"publish","type":"post","link":"http:\/\/www.u3d8.com\/?p=514","title":{"rendered":"2.5.0+\b\u7ba1\u7406\u81ea\u5b9a\u4e49\u76ae\u80a4"},"content":{"rendered":"<p>\u767d\u9e6d\u5b98\u7f51\u5df2\u7ecf\u5199\u4e86\u51e0\u4e2a\u65b9\u6cd5\u53bb\u6dfb\u52a0\u81ea\u5b9a\u4e49\u76ae\u80a4\uff0c\u4f46\u5bf9\u4e8e\u7ba1\u7406\u6216\u8c03\u7528\u6765\u8bf4\uff0c\u4e0d\u662f\u7279\u522b\u65b9\u4fbf\u3002\u501f\u9274\u670b\u53cb\u63d0\u4f9b\u7684\u90e8\u5206\u65b9\u6cd5\uff0c\u5206\u4eab\u7ed9\u5927\u5bb6\u3002<\/p>\n<p>\u5b9e\u73b0\u529f\u80fd\uff1a\u663e\u793a\u81ea\u5b9a\u4e49exml\b\u76ae\u80a4\uff0c\u5207\u6362exml\u76ae\u80a4\uff0c\u9690\u85cfexml\u76ae\u80a4\u3001\u79fb\u9664exml\u76ae\u80a4\uff0c\u7ed9\u8be5exml\u76ae\u80a4\u5185\u67d0\u4e2aImage\u7684\u56fe\u7247\u8d44\u6e90\u6dfb\u52a0\u70b9\u51fb\u4e8b\u4ef6<\/p>\n<p>\uff08\u4ee5\u4e0b\u9700\u8981\u521b\u5efa\u7684\u811a\u672c\u7684\u4f4d\u7f6e\u4fe1\u606f\uff0c\u5982\u56fe\uff09<\/p>\n<p><img title=\"2.5.0+\b\u7ba1\u7406\u81ea\u5b9a\u4e49\u76ae\u80a4 - \u7b2c1\u5f20  | u3d8\u6280\u672f\u5206\u4eab\" alt=\"2.5.0+\b\u7ba1\u7406\u81ea\u5b9a\u4e49\u76ae\u80a4 - \u7b2c1\u5f20  | u3d8\u6280\u672f\u5206\u4eab\" loading=\"lazy\" class=\"size-full wp-image-515 alignnone\" src=\"http:\/\/www.u3d8.com\/wp-content\/uploads\/2015\/12\/0F8A909C-2B37-44B9-97B6-36F8C00D0927.jpg\" width=\"273\" height=\"145\" \/><\/p>\n<p>\u4e00\u3001\u6dfb\u52a0\u529f\u80fd\u811a\u672cDialogManager\uff08\u96c6\u5408\u6dfb\u52a0\u3001\u9690\u85cf\u3001\u79fb\u9664\u3001\u66ff\u6362\u7684\u529f\u80fd\uff09\uff0c\u76ee\u524d\u6dfb\u52a0\u4e863\u4e2a\u5206\u7ec4\uff0c\u53ef\u4ee5\u81ea\u5b9a\u4e49\u66f4\u591a\u30023\u4e2a\u5206\u7ec4\u53ef\u4ee5\u540c\u65f6\u663e\u793a2\u4e2aexml\u81ea\u5b9a\u4e49\u9875\u9762<\/p>\n<pre class=\"lang:js decode:true\">\r\nmodule DialogManager\r\n{\r\n    export var dict1 = {};\r\n\r\n    export var dict2 = {};\r\n\r\n    export var dict3 = {};\r\n\r\n    export var moment_dict1:string = \"\";\r\n\r\n    export var moment_dict2:string = \"\";\r\n\r\n    export var moment_dict3:string = \"\";\r\n\r\n    \/**\r\n     *\r\n     * @param dialogClass \u7c7b\u540d\r\n     * @param dialogName  \u7c7b\u540d\r\n     * @param num         \u7ec4\u540d\r\n     *\/\r\n    export function open(dialogClass:any, dialogName:string, num:number = 1)\r\n    {\r\n        \/\/\u5c0f\u7a97\u53e3\r\n        if(num == 1)\r\n        {\r\n            if(this.moment_dict1 != \"\")\r\n            {\r\n                this.dict1[this.moment_dict1].hide();\r\n            }\r\n            if (this.dict1[dialogName] == null)\r\n            {\r\n                var dialog = new dialogClass();\r\n\r\n                dialog.show();\r\n\r\n                this.dict1[dialogName] = dialog;\r\n            }\r\n            else\r\n            {\r\n                if(!this.dict1[dialogName].showing) this.dict1[dialogName].show();\r\n            }\r\n            this.moment_dict1 = dialogName;\/\/\u8bb0\u5f55\u5f53\u524d\u6b63\u5728\u6253\u5f00\r\n\r\n        }\r\n\r\n        else if (num == 2)\r\n        {\r\n            if(this.moment_dict2 != \"\")\r\n            {\r\n                this.dict2[this.moment_dict2].hide();\r\n            }\r\n\r\n\r\n            if (this.dict2[dialogName] == null)\r\n            {\r\n                var dialog = new dialogClass();\r\n\r\n                dialog.show();\r\n\r\n                this.dict2[dialogName] = dialog;\r\n            }\r\n            else\r\n            {\r\n                if(!this.dict2[dialogName].showing) this.dict2[dialogName].show();\r\n            }\r\n\r\n            this.moment_dict2 = dialogName;\/\/\u8bb0\u5f55\u5f53\u524d\u6b63\u5728\u6253\u5f00\r\n\r\n            console.log(\"\u5f53\u524d\u6253\u5f00\",this.moment_dict2);\r\n\r\n        }\r\n\r\n        else if (num == 3)\r\n        {\r\n            if(this.moment_dict3 != \"\")\r\n            {\r\n                this.dict3[this.moment_dict3].hide();\r\n            }\r\n            if (this.dict3[dialogName] == null)\r\n            {\r\n                var dialog = new dialogClass();\r\n\r\n                dialog.show();\r\n\r\n                this.dict3[dialogName] = dialog;\r\n            }\r\n            else\r\n            {\r\n                if(!this.dict3[dialogName].showing) this.dict3[dialogName].show();\r\n            }\r\n            this.moment_dict3 = dialogName;\/\/\u8bb0\u5f55\u5f53\u524d\u6b63\u5728\u6253\u5f00\r\n        }\r\n    }\r\n\r\n    \/**\r\n     * \r\n     * @param dialogName \u7c7b\u540d\r\n     * @param num        \u7ec4\u540d\r\n     * @param hideOnly   \u662f\u5426\u53ea\u9690\u85cf\r\n     *\/\r\n    export function remove (dialogName:string, num:number = 1, hideOnly:boolean = false)\r\n    {\r\n        if (num == 1)\r\n        {\r\n            if (this.dict1[dialogName] != null)\r\n            {\r\n                if(this.dict1[dialogName].parent) {\r\n                    this.dict1[dialogName].hide();\r\n                }\r\n                if (hideOnly == false) {\r\n                    this.dict1[dialogName] = null;\r\n                }\r\n            }\r\n        }\r\n\r\n        else if (num == 2)\r\n        {\r\n            if (this.dict2[dialogName] != null)\r\n            {\r\n                if(this.dict2[dialogName].parent) {\r\n                    this.dict2[dialogName].hide();\r\n                }\r\n                if (hideOnly == false) {\r\n                    this.dict2[dialogName] = null;\r\n                }\r\n            }\r\n        }\r\n\r\n        else if (num == 3)\r\n        {\r\n            if (this.dict3[dialogName] != null)\r\n            {\r\n                if(this.dict3[dialogName].parent) {\r\n                    this.dict3[dialogName].hide();\r\n                }\r\n                if (hideOnly == false) {\r\n                    this.dict3[dialogName] = null;\r\n                }\r\n            }\r\n        }\r\n    }\r\n}<\/pre>\n<p>\u4e8c\u3001\u65b0\u5efaexml\u6587\u4ef6\uff0c\u540d\u79f0GameSkin.exml\uff0c\u4f4d\u7f6e\/src\/skins\/\u4e0b\u3002\u91cc\u9762\u53ea\u662f\u663e\u793a\u4e861\u5f20\u56fe\u7247\uff0c\u56fe\u7247\u540d\u79f0\"game_bg\"\uff0cid\uff1aGame_bg<\/p>\n<pre class=\"lang:js decode:true \">&lt;?xml version='1.0' encoding='utf-8'?&gt;\r\n&lt;e:Skin class=\"GameSkin\" width=\"640\" height=\"960\" xmlns:e=\"http:\/\/ns.egret.com\/eui\" xmlns:w=\"http:\/\/ns.egret.com\/wing\"&gt;\r\n\t&lt;e:Image id=\"Game_bg\" source=\"game_bg\" x=\"0\" y=\"0\"\/&gt;\r\n&lt;\/e:Skin&gt;<\/pre>\n<p>\u4e09\u3001\u5728Main.ts\u811a\u672c\u4e2d\u6dfb\u52a0UIlayer\u9759\u6001\u53d8\u91cf\uff0c\u5e76\u521d\u59cb\u5316\uff0c\u6dfb\u52a0<\/p>\n<pre class=\"lang:js decode:true\">public static euiLayer : eui.UILayer;\r\n    protected startCreateScene(): void {\r\n        Main.euiLayer = new eui.UILayer;\r\n        this.addChild( Main.euiLayer );\r\n    }<\/pre>\n<p>\u56db\u3001\u65b0\u5efats\u6587\u4ef6\uff0c\u540d\u79f0GameView.ts\uff0c\u4f4d\u7f6e\/src\/view\/\u4e0b\u3002<\/p>\n<pre class=\"lang:js decode:true\">\/**\r\n * Created by WangChong on 15\/12\/7.\r\n *\/\r\nclass GameView extends eui.Component {\r\n\r\n    public constructor ()\r\n    {\r\n        super ();\r\n        this.skinName = \"src\/skins\/GameSkin.exml\";  \/\/ \u6307\u5b9aSkin\u76ee\u5f55\u53ca\u5168\u540d\r\n    }\r\n\r\n    \/**\r\n     * \u663e\u793a\u65b9\u6cd5\uff0c\u5728DialogManager\u811a\u672c\u4e2d\u8c03\u7528\r\n     *\/\r\n    public show() {\r\n        if (!this.parent) {\r\n            Main.euiLayer.addChild(this);\r\n        }\r\n    }\r\n\r\n    \/**\r\n     * \u79fb\u9664\u663e\u793a\u65b9\u6cd5\uff0c\u5728DialogManager\u811a\u672c\u4e2d\u8c03\u7528\r\n     *\/\r\n    public hide() {\r\n        if (this.parent) {\r\n            Main.euiLayer.removeChild(this);\r\n        }\r\n    }\r\n\r\n    \/\/ \u6307\u5411GameSkin.exml\u6587\u4ef6\u4e2d\u7684\u8be5ID\u7684\u56fe\u7247\r\n    public Game_bg : eui.Image;\r\n\r\n    \/**\r\n     * add\u65b9\u6cd5\u6267\u884c\u5b8c\u6bd5\uff0c\u8c03\u7528\u8be5\u65b9\u6cd5\r\n     *\/\r\n    public createChildren() {\r\n        super.createChildren();\r\n\r\n        \/\/ \u7ed9\u56fe\u7247\u6dfb\u52a0\u70b9\u51fb\u4e8b\u4ef6\r\n        this.Game_bg.addEventListener(egret.TouchEvent.TOUCH_TAP, function () {\r\n            DialogManager.open( GameView, \"GameView\", 1);\r\n        }, this);\r\n    }\r\n}\r\n<\/pre>\n<p>\u4e94\u3001\u5728Main\u51fd\u6570\u4e2d\u663e\u793a\u8be5\u76ae\u80a4\uff0c\u5e76\u4f20\u5165\u8be5\u7c7b\u540d\uff0c\u53ca\u663e\u793a\u5728\u7b2c\u51e0\u7ec4\u7b49\u53c2\u6570<\/p>\n<pre class=\"lang:js decode:true\">    protected startCreateScene(): void {\r\n\r\n        Main.euiLayer = new eui.UILayer;\r\n        this.addChild( Main.euiLayer );\r\n\r\n        DialogManager.open( GameView, \"GameView\", 1);\r\n    }<\/pre>\n<p>\u516d\u3001\u8fd0\u884c\u6d4b\u8bd5\u662f\u5426\u53ef\u4ee5\u663e\u793a\u8be5\u76ae\u80a4\uff0c\u53ca\u70b9\u51fb\u4e8b\u4ef6\u3002\u70b9\u51fb\u540e\uff0c\u8c03\u7528\u79fb\u9664\u65b9\u6cd5\uff0c\u662f\u5426\u53ef\u4ee5\u79fb\u9664\u8be5\u76ae\u80a4\u3002<\/p>\n<p>\u5982\u9700\u5207\u6362\u76ae\u80a4\uff0c\u5219\u53ef\u4ee5\u76f4\u63a5\u5728\u5f53\u524d\u7ec4\u6253\u5f00\u5176\u5b83\u76ae\u80a4\uff0c\u5982\u5f53\u524d\u5df2\u6253\u5f00GameView\u76ae\u80a4\uff0c\u518d\u6253\u5f00TitleView\u76ae\u80a4\uff0c\u5219GameView\u6d88\u5931\uff0cTitleView\u663e\u793a\u3002<\/p>\n<pre class=\"lang:js decode:true\">DialogManager.open( \bTitleView, \"TitleView\", 1);<\/pre>\n<p>\u5e0c\u671b\u5bf9\u5927\u5bb6\u6709\u5e2e\u52a9~~~<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u767d\u9e6d\u5b98\u7f51\u5df2\u7ecf\u5199\u4e86\u51e0\u4e2a\u65b9\u6cd5\u53bb\u6dfb\u52a0\u81ea\u5b9a\u4e49\u76ae\u80a4\uff0c\u4f46\u5bf9\u4e8e\u7ba1\u7406\u6216\u8c03\u7528\u6765\u8bf4\uff0c\u4e0d\u662f\u7279\u522b\u65b9\u4fbf\u3002\u501f &hellip; <a href=\"http:\/\/www.u3d8.com\/?p=514\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[103],"tags":[149,150,151,148],"_links":{"self":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/514"}],"collection":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=514"}],"version-history":[{"count":5,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/514\/revisions"}],"predecessor-version":[{"id":722,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/514\/revisions\/722"}],"wp:attachment":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=514"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=514"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=514"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}