zoukankan      html  css  js  c++  java
  • libgdx的菜单配置,以及json文件的结构

    Game->stage

    stage之间的相互切换语句

    ((Game) (Gdx.app.getApplicationListener()))
    .setScreen(new ScreenTwo());

    对于菜单画面

    private Skin skin;
        private Stage stage;
        private Table table;  //用来装按钮,文字等组件
        private Label heading;
        private TextureAtlas atlas;
        private TextButton buttonPlay, buttonExit;

       heading = new Label("Hello Libgdx", skin);//skin是json文件,里面配置好了很多属性,只要写一个skin其他的都不用管
        heading.setFontScale(3);
        //给文字添加颜色变化的动作
        heading.addAction(Actions.repeat(
               20,
             new SequenceAction(Actions.color(skin.getColor("blue"), 0.2f),
              Actions.color(skin.getColor("green"), 0.2f), Actions
              .color(skin.getColor("red"), 0.2f))));

        //将table添加到stage用于显示

        table.add(heading);
        table.getCell(heading).spaceBottom(100);
        table.row();
        table.add(buttonExit);
        table.getCell(buttonExit).spaceBottom(10);
        table.row();

        table.add(buttonPlay);
        stage.addActor(table);

    JSON配置文件
    { com.badlogic.gdx.graphics.Color:{ //完整的类名,后面要加冒号 white:{r:
    1, g:1, b:1, a:1 }, //rgba颜色 键值中间要用冒号 black:{r:0, g:0, b:0, a:1 }, red:{r:1, g:0, b:0, a:1 }, green:{r:0, g:1, b:0, a:1 }, blue:{r:0, g:0, b:1, a:1 } }, com.badlogic.gdx.graphics.g2d.BitmapFont:{ blackFont:{file:data/blackFont.fnt}, //读取字体文件前面要用file:后面的是文件的路径名 whiteFont:{file:data/white.fnt} }, //两个类之间要加逗号 com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle:{ default:{ down: buttonDo,//自动寻找 atlas中命名为buttonDo的配置文件 up: buttonUp, font: blackFont //寻找上面已经定义好的font } }, com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle:{ default:{ font: whiteFont, fontColor: white } } }
  • 相关阅读:
    (转)值得学习百度开源70+项目
    C#中$的用法
    (转载)《C#高级编程》读书笔记
    C#调用大漠插件
    Visual Studio 2017 扩展推荐
    C#操作Dataset数据集与SQLite数据库
    (转载)C#格式规范
    (转载)DataTable与List<T>相互转换
    FastReport.Net
    (转载)C #开源框架
  • 原文地址:https://www.cnblogs.com/yican/p/3789424.html
Copyright © 2011-2022 走看看