Hot answers tagged

3

LibGDX is based on LWGL and its advantage are that a lot of the base stuff is already written and you don't need to write it. Some people prefer to write it themselves though. LibGDX is generally used in mobile game development, but can also be used on Windows, Mac and Html. Some final words: For beginners I would suggest using LibGDX, because it is easier ...


3

At the GPU API level (that is, the D3D or OpenGL level) drawing something with a different texture is generally going to involve issuing a new draw call. Draw calls only use the current state as-of the point where the call is issued; changing textures is a state change. "Sprite batch" implementations generally use some kind of sorting to minimize draw calls;...


2

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 ...


2

error: y has private access in Polygon This simply means, that the y field is private in the Polygon class. Instead of trying to use balls1.y to reach that variable, use setPosition(float x, float y), getX() and getY()


2

to remove class information, use fileJson.setTypeName(null) to display all infomation including default value (in your case "false" is default of boolean), use fileJson.setUsePrototypes(false); see more in documents


2

There are several options: Have a non-scrolling background image which is more attractive than just pure black. This might make the game appear a bit more abstract. (example from Disgaea D2) Add a decorative border which looks as if the game takes place on a tabletop or similar (Example from Rings of Power) Design your maps with a non-reachable border ...


2

The short answer is that you can't return different subclasses from a Pool. Even if you used a static variable to pass parameters to newObject(), newObject() is only called when all of the pooled objects are already being used; meaning that you would never know which subclass you are getting when you obtained a pooled object. Before continuing down this ...


2

Your intuition is correct, the easiest way to do it would be to normalize your vector, and then rescale it using the Projectile.maxSpeed. If you need the angle for some reason, you can get the direction to the target by using the atan2, which can be used to convert an x and y difference into a rotation. Here's some C pseudo-code to show you: float x_diff = ...


2

If you want the simplest method you could just use something along the lines of a Factory: public class CharacterFactory { public static Entity spawnCharacter(PooledEngine engine) { CharacterComponent character = engine.createComponent(CharacterComponent.class); TextureComponent texture = engine.createComponent(TextureComponent.class)...


1

It may seem redundant to have a position component when the Sprite class has x and y properties but this is actually a very valid setup. First, instead of calling it a SpriteComponent lets call it a DisplayComponent instead and implement it as follows: class DisplayComponent implements Component { Sprite display; } The context of the component is now ...


1

If you're going to use two images anyways, why don't you simply just have one image without an outline and one with an outline and just swap between them? As for other methods of drawing an outline, it can be done using multiple methods. If you're going to draw an outline on simple textures (let's say a square) use a ShapeRenderer (docs & tutorial) and ...


1

From the libGDX github wiki: Note: By default, the Json class will not write those fields which have values that are identical to a newly constructed instance. If you wish to disable this behavior and include all fields, call json.setUsePrototypes(false);.


1

It's hard to know what's going on without images or code so not sure if this addresses your particular issue or not, but 'Linear' in this context means that OpenGL applies a bilinear filter to the texture when it is sampled. A bilinear filter is an average of the pixels from the original image around the sample position so you may get slightly blurry ...


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....



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