Hot answers tagged

1

How about changing your approach to the simpler solution? You could just manually rotate the sprite in your update-method with something like the following: sprite.setRotation((sprite.getRotation() + rotationSpeed) % 360);. That way the sprite will smoothly spin around forever, and your code stays clean and straight-forward.


1

The best way to load in music and sound effects resources is through LibGDX's audio methods: Music music = Gdx.audio.newMusic(Gdx.files.internal(path_to_music_file)); Sound sound = Gdx.audio.newSound(Gdx.files.internal(path_to_sound_file)); To play the music: music.setVolume(1f); music.play(); To play the sound effect: long id = sound.play(); sound....


1

You should avoid invoking new instances in your render and update methods. As these methods are called numerous times per second, this can be a pretty straining task, as the unreferenced instances will have to be freed in memory through garbage collection. To solve the two Vector2 problems, easy: Declare and instantiate two global Vector2 attributes, and ...


1

It seems that if the VerticalGroup is added to another layout, then it works. Looking at the code, this is due to VerticalGroup also being a Layout, and so it's prefWidth/Height are used instead of the getWidth/Height methods. I got around this by manually setting the size to the pref. size. setSize(getPrefWidth(), getPrefHeight()); Note, that you don't ...



Only top voted, non community-wiki answers of a minimum length are eligible