• 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 } } }
  • 相关阅读:
    挖矿病毒 netstat与ss重要区别
    leetcode 正则表达式匹配
    DNS重新绑定攻击
    Mac OS ssh 禁用密码登陆
    linux alias 别名在Bash脚本内不起作用 远程执行alias 命令不工作
    centos 7 搭建 l2tp
    psacct 软件包工具监视所有用户执行的命令
    随机密码生成
    Linux 进程 cpu 使用排序 内存 使用排序
    nginx 反向代理 uri 重写
  • 原文地址:https://www.cnblogs.com/yican/p/3789424.html
Copyright © 2020-2023  润新知