TweenAccessor for music.class in LibGDX(LibGDX 中 music.class 的 TweenAccessor)
问题描述
我一直在想:是否可以在 LibGDX 中使用 Universal Tween Engine 来改变歌曲的音量?我用类似于我的 SpriteAccessor 的代码编写了我自己的 MusicAccessor,它实际上适用于 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,但我想可能是因为 Music
实际上只是一个界面.
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
的另外三个实现(它们都称为 Music
,位于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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:LibGDX 中 music.class 的 TweenAccessor
基础教程推荐
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- 在螺旋中写一个字符串 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01