使用LibGDX,你怎么在使用单独的图像的动画? [英] Using LibGDX, how do you have an animation using seperate images ?

查看:216
本文介绍了使用LibGDX,你怎么在使用单独的图像的动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习如何使用LibGDX做游戏,我尝试(使用Eclipse),使一个小平台游戏。我上运行,使动画时,他的动作主角做4图像。但是,我找不到任何东西在网上告诉我如何使动画不使用SpriteSheet。你如何使用4种不同的图像动画?

I'm learning how to make games using LibGDX and I'm trying to make a small platform game (using Eclipse). I made 4 images on the main character running to make an animation when he moves. However, I can't find anything online to show me how to make an animation without using a SpriteSheet. How do you make an animation using 4 different images ?

推荐答案

首先:你不应该使用不同的图像。也许您的播放器就没有多大意义(因为只有一个),但一般而言,您应该始终使用精灵表,又名 TextureAtlas

First of all: You should not use different images. Maybe for your player it does not matter much (because there is only one) but in general you should always use sprite sheets, a.k.a. TextureAtlas.

然而,这是可能的,而不它通过使用不同的纹理。

However, it is possible without it by using different textures.

TextureRegion tex1 = new TextureRegion(new Texture("play_anim_1"));
TextureRegion tex2 = new TextureRegion(new Texture("play_anim_2"));
TextureRegion tex3 = new TextureRegion(new Texture("play_anim_3"));
TextureRegion tex4 = new TextureRegion(new Texture("play_anim_4"));

Animation playerAnimation = new Animation(0.1f, tex1, tex2, tex3, tex4);

这篇关于使用LibGDX,你怎么在使用单独的图像的动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆