zoukankan      html  css  js  c++  java
  • 【第六周】【新蜂站会】

    http:https://git.coding.net/Boxer_/homework.git

    ssh:git@git.coding.net:Boxer_/homework.git

    小组名称:新蜂

    组长:武志远

    组成员:宫成荣 谢孝淼 杨柳 李峤

    项目名称:Java俄罗斯方块

    站会时间:11.2

    总任务:

    1,数据库显示模块。

    2,本地记录模块,

     3,俄罗斯方块主模块

    4,按钮窗口模块

    5,下一个窗口模块

    6,等级窗口模块,

    7,分数窗口模块。

    8,版权信息模块。

    每日任务:

    1,利用xml解决硬编码问题。

    遇到困难:xml离搞懂还有很大距离。,

    1,xml里面是这样的。

    <?xml version="1.0" encoding="UTF-8"?>
    <game>
        <frame title = "Java俄罗斯方块" windowUp="32" width = "1168" height="680" padding = "16" windowSize = "7">
            <layer className = "ui.LayerBackground" x ="0" y="0" w="0" h="0"/>
            <layer className = "ui.LayerDataBase" x ="40" y="32" w="334" h="279"/>
            <layer className= "ui.LayerDisk" x ="40" y="343" w="334" h="279"/>
            <layer className = "ui.LayerGame" x ="414" y="32" w="334" h="590"/>
            <layer className = "ui.LayerButton" x ="788" y="32" w="334" h="124"/>
            <layer className = "ui.LayerNext" x ="788" y="188" w="176" h="148"/>
            <layer className= "ui.LayerLevel" x ="964" y="188" w="158" h="148"/>
            <layer className = "ui.LayerPoint" x ="788" y="368" w="334" h="200"/>    
        
        </frame>
        <system>
        
        </system>
        <data>
        
        </data>
        
    </game>
    
                

    2,写了一点xml的解析类

    public class GameConfig {
        //窗口宽度
        private int width;
        //窗口高度
        private int height;
        //标题
        private String title;
        //窗口拔高
        private int windowUp;
        //边框尺寸
        private int windowSize;
        //边框内边距
        private int padding;
        
        private List<LayerConfig> layersConfig;
        
        /**
         * 构造函数
         * 读取XML文件,获取全部游戏配置
         * @throws Exception
         */
        public GameConfig() throws Exception
        {
            //创建XML读取器
            SAXReader read = new SAXReader();
            //读取XML文件
            Document doc = read.read("config/cfg.xml");
            //获得XML文件的根节点
            Element game = doc.getRootElement();
            //配置系统参数
            this.setSystemConfig(game.element("system")) ;
            //配置窗口参数
            this.setUiConfig(game.element("frame"));
            //配置数据库参数
            this.setDataConfig(game.element("data"));
            
        }
        /**
         * 配置窗口
         * 
         * @param frame 配置文件的窗口配置元素
         */
        private void setUiConfig(Element frame)
        {    
            //获取窗口宽度
            this.width=Integer.parseInt(frame.attributeValue("width"));
            //获取窗口高度
            this.height=Integer.parseInt(frame.attributeValue("height"));
            //获取边框粗细
            this.windowSize=Integer.parseInt(frame.attributeValue("windowSize"));
            //获取边框内边距
            this.padding=Integer.parseInt(frame.attributeValue("padding"));
            //获取标题
            this.title = frame.attributeValue("title");
            //获取窗口拔高
            this.windowUp =Integer.parseInt(frame.attributeValue("windowUp"));
            //获取窗体属性
            List<Element> layers = frame.elements("layer");
            layersConfig = new ArrayList<LayerConfig>();
            for(Element layer : layers)
            {
            LayerConfig lc = new LayerConfig(
                    layer.attributeValue("className"),
                    Integer.parseInt(layer.attributeValue("x")),
                    Integer.parseInt(layer.attributeValue("y")),
                    Integer.parseInt(layer.attributeValue("w")),
                    Integer.parseInt(layer.attributeValue("h"))    
                    );        
                layersConfig.add(lc);
            }
        }

  • 相关阅读:
    TypeScript-基础-09-声明文件
    TypeScript-基础-08-类型断言
    TypeScript-基础-07-函数的类型
    TypeScript-基础-06-数组的类型
    TypeScript-基础-05-对象的类型—接口
    TypeScript-基础-04-联合类型
    TypeScript-工程
    小白学前端03
    小白学前端02
    小白学前端
  • 原文地址:https://www.cnblogs.com/Boxer1994/p/6024815.html
Copyright © 2011-2022 走看看