使用 LibGDX,您如何使用单独的图像制作动画? [英] Using LibGDX, how do you have an animation using seperate images ?

查看:25
本文介绍了使用 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天全站免登陆