标签:
1 { 2 com.badlogic.gdx.graphics.Color: { 3 green: { a: 1, b: 0, g: 1, r: 0 }, 4 white: { a: 0, b: 1, g: 1, r: 1 }, 5 red: { a: 1, b: 0, g: 0, r: 1 }, 6 black: { a: 1, b: 0, g: 0, r: 0 } 7 }, 8 com.badlogic.gdx.graphics.g2d.BitmapFont: { 9 font: { file: test.fnt } 10 }, 11 com.badlogic.gdx.scenes.scene2d.ui.Button$ButtonStyle: { 12 style:{ 13 down:btnDown,up:btnUp 14 }, 15 }, 16 }
1 package com.mygdx.skin; 2 3 import com.badlogic.gdx.ApplicationAdapter; 4 import com.badlogic.gdx.Gdx; 5 import com.badlogic.gdx.graphics.GL20; 6 import com.badlogic.gdx.scenes.scene2d.Stage; 7 import com.badlogic.gdx.scenes.scene2d.ui.Button; 8 import com.badlogic.gdx.scenes.scene2d.ui.Skin; 9 /** 10 * 使用skin 11 * @author Jack(乐智) 12 * @blog dtblog.cn 13 * @qq 984137183 14 */ 15 public class MainGame extends ApplicationAdapter { 16 //声明skin对象 17 private Skin skin; 18 //声明按钮 19 private Button button; 20 //声明舞台 21 private Stage stage; 22 23 24 @Override 25 public void create() { 26 //实例化skin对象 27 skin=new Skin(Gdx.files.internal("skin/test.json")); 28 //实例化按钮 29 button=new Button(skin.get("style",Button.ButtonStyle.class)); 30 //实例化舞台 31 stage=new Stage(); 32 //添加按钮到舞台 33 stage.addActor(button); 34 //注册舞台监听 35 Gdx.input.setInputProcessor(stage); 36 37 } 38 39 @Override 40 public void render() { 41 //设置屏幕背景黑色 42 Gdx.gl.glClearColor(0, 0, 0, 0); 43 //清屏 44 Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); 45 //更新舞台逻辑 46 stage.act(); 47 //绘制舞台内容 48 stage.draw(); 49 } 50 51 }
【开源java游戏框架libgdx专题】-14-系统控件-Skin类
标签:
原文地址:http://www.cnblogs.com/AIThink/p/5933765.html