LibGDX中的music.class的TweenAccessor [英] TweenAccessor for music.class in LibGDX

查看:103
本文介绍了LibGDX中的music.class的TweenAccessor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直想知道:是否可以在LibGDX中使用通用Tween引擎 - 例如 - 更改歌曲的音量?我编写了自己的MusicAccessor,其代码类似于我的SpriteAccessor,它实际上适用于Sprite.class,但是当涉及音乐对象时 - 它总是会出现同样的错误:

I've been wondering: is it possible to use Universal Tween Engine in LibGDX to - for example - change the volume of a song? I wrote my own MusicAccessor with code similar to my SpriteAccessor, which actually works for Sprite.class, but when it comes to music objects - it always gets the same error:

java.lang.RuntimeException: No TweenAccessor was found for the target

问题是,我通过以下方式注册我的访问者: Tween.registerAccessor(Music.class,new MusicAccessor()); 我很确定它实际上已经注册, System.out.println(Tween.getRegisteredAccessor(Music.class)); 打印: the.name.of.my.packages.MusicAccessor@14bb523 。老实说,我被卡住了。

The thing is, I DO register my accessor by: Tween.registerAccessor(Music.class,new MusicAccessor()); I'm quite sure it's actually being registered, as System.out.println(Tween.getRegisteredAccessor(Music.class)); prints: the.name.of.my.packages.MusicAccessor@14bb523. Honestly, I'm stuck.

音乐文件本身是.mp3格式,我是由资产经理加载的。

The music file itself is in .mp3 format and I load it by an asset manager.

所以,我的问题是:为什么Tween引擎无法正确识别我的音乐对象的类?有没有办法使它工作或我是否坚持定期定时器随时间改变音量?更改格式或以不同方式加载音乐文件有帮助吗?

So, my questions are: why the Tween Engine cannot correctly recognise the class of my music object? Is there a way to make it work or am I stuck with regular timers to change the volume over time? Would changing the format or loading the music file in a different way help?

推荐答案

我个人还没有使用过Tween Engine ,但我认为这可能是因为音乐实际上只是一个界面。

I personally haven't used Tween Engine myself yet, but I think it might be because Music is actually just an interface.

有几种不同的实现方式后端和不同的文件格式。例如 AndroidMusic GwtMusic ,以及另外三个 OpenALMusic (它们都被称为音乐,位于 com.badlogic.gdx.backends.openal.mp3 / ogg / wav 包)。您可以使用访问者注册它们,也可以使用 我在代码中找到的Tween.cast() ,但在补间的官方JavaDoc中没有发动机。它可能只是最新版本。

There are several implementations for the different backends and different file formats. For example AndroidMusic, GwtMusic, and three more implementations of OpenALMusic (they are all called Music and are located in the com.badlogic.gdx.backends.openal.mp3/ogg/wav packages). You could either register them all with your accessor, or you can use Tween.cast() which I found in the code, but not in the official JavaDoc of the tween engine. It might be only in the latest version.

这篇关于LibGDX中的music.class的TweenAccessor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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