标签:
1 package com.mygdx.useactor; 2 3 import com.badlogic.gdx.graphics.Texture; 4 import com.badlogic.gdx.graphics.g2d.Batch; 5 import com.badlogic.gdx.scenes.scene2d.Actor; 6 7 /** 8 * 第一个演员类 9 * @author Jack(乐智) 10 * @blog dtblog.cn 11 * @qq 984137183 12 */ 13 public class FirsrtActor extends Actor{ 14 private Texture texture; 15 public FirsrtActor(){ 16 this.init(); 17 } 18 private void init(){ 19 texture=new Texture("badlogic.jpg"); 20 } 21 @Override 22 public void draw(Batch batch, float parentAlpha) { 23 batch.draw(texture,0,0); 24 } 25 26 }
1 package com.mygdx.useactor; 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.graphics.g2d.SpriteBatch; 7 /** 8 * 游戏主类,使用演员 9 * @author Jack(乐智) 10 * @blog dtblog.cn 11 * @qq 984137183 12 */ 13 public class MainGame extends ApplicationAdapter { 14 public SpriteBatch batch; 15 public FirsrtActor actor; 16 @Override 17 public void create() { 18 batch=new SpriteBatch(); 19 actor=new FirsrtActor(); 20 } 21 22 @Override 23 public void render() { 24 //设置背景颜色为白色 25 Gdx.gl.glClearColor(1, 1, 1, 1); 26 //清屏 27 Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); 28 batch.begin(); 29 actor.draw(batch, 0.3f); 30 batch.end(); 31 } 32 33 }
【开源java游戏框架libgdx专题】-11-核心库-演员类
标签:
原文地址:http://www.cnblogs.com/AIThink/p/5929074.html