Hot answers tagged java
Mathematically speaking, a distance is a value which is never lower than 0. You can see this thing in your getDistance() function implementation: the argument passed to the square root function is a sum between powers of 2. A power of 2 is always positive, their sum is positive as well, and the sqrt() function will always give back a positive value. So, no ...
Your best bet is to make a class that replicates Javas Graphics class in LWJGL. For textures you can write your own LWJGL wrapper or use Slick 2D
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.
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....
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 ...
Only top voted, non community-wiki answers of a minimum length are eligible