libgdx 动画
来源:互联网 发布:隔墙听 淘宝 编辑:程序博客网 时间:2024/06/06 01:38
public class MyGdxGame implements ApplicationListener {Animation animation;Texture texture;TextureRegion[] walkFrames;SpriteBatch batch;TextureRegion textureRegion;float statetime;@Overridepublic void create() {//获取一张分割成田字型的,由四个小图组成的图片texture = new Texture(Gdx.files.internal("data/animation_sheet.png"));//动画就是这四张小图连续动作而成的,把图片分割分别放到TextureRegion数组中TextureRegion[][] temp = TextureRegion.split(texture,//Texture texture texture.getWidth()/2, //int tileWidth texture.getHeight()/2);//int tileHeight//切完之后把2维数组的textureRegion顺序放到1维中walkFrames = new TextureRegion[2 * 2];int index = 0;for (int i = 0; i < 2; i++) {for (int j = 0; j < 2; j++) {walkFrames[index++] = temp[i][j];}}//设置动画祯的频率animation = new Animation(0.02f, walkFrames);batch = new SpriteBatch();statetime = 0;}@Overridepublic void dispose() {}@Overridepublic void render() {Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);/*the time span between the current frame and the last frame in seconds. Might be smoothed over n frames.*/ statetime+=Gdx.graphics.getDeltaTime();textureRegion = animation.getKeyFrame(statetime,true);//当前时间内的图片,循环batch.begin();batch.draw(textureRegion, 300, 300);//动画坐标为(300,300)batch.end();}@Overridepublic void resize(int width, int height) {}@Overridepublic void pause() {}@Overridepublic void resume() {}}
0 0
- libgdx 动画
- (libgdx小结)自定义动画
- libgdx骨骼动画例子
- Libgdx 骨骼动画整理
- libgdx显示gif动画
- 自定义动画--libgdx
- Libgdx之Animation 动画
- libgdx: 缩放动画的实现
- Libgdx专题系列:对象篇 Animation动画
- 使用Libgdx进行游戏开发-动画
- libGDX视频教程(四) -- 游戏动画
- Libgdx播放Spine动画(1)-基础
- Libgdx播放Spine动画(2)-功能
- 在libGDX中使用Spine骨骼动画
- Android-动画提升-基于游戏引擎libGDX-动画开发
- libGDX
- LibGDX
- 使用spine骨骼动画制作的libgdx游戏
- 神奇的图像处理算法
- java.lang.UnsupportedClassVersionError: Unsupported major.minor version 49.0的错误 [转]
- Filter系列五 谈谈启动方面
- 为了您心甘情愿-香味营销
- 简单python常用模块
- libgdx 动画
- 使用FileUpload接收上传内容
- LeetCode: Symmetric Tree
- Convert a given tree to its Sum Tree
- 理解OAuth 2.0
- com学习(四)——用 ATL 写第一个组件
- 在Android上使用Https连接
- android api分析16 Intent实例
- 数组中a和&a的区别