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
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.
The music file itself is in .mp3 format and I load it by an asset manager.
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?
I personally haven't used Tween Engine myself yet, but I think it might be because
Music
is actually just an interface.There are several implementations for the different backends and different file formats. For example
AndroidMusic
,GwtMusic
, and three more implementations ofOpenALMusic
(they are all calledMusic
and are located in thecom.badlogic.gdx.backends.openal.mp3/ogg/wav
packages). You could either register them all with your accessor, or you can useTween.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.