New answers tagged

0

The character should have a single state machine. Animations should be controlled by the character state so they don't need their own character-specific state machine except as part of a generic animation system. Status variables (health, ammo, invincibility timer, inventory, etc) are part of deciding which state to transition to but not state machines in ...


0

an engine agnostic way to do it is to use average light mapping. First, you need to generate a black and white map as a 2D array of booleans that is the size of the world where the blocks are True and empty is False. Like This(1 is black, 0 is white): Then you need to create a new 2D array that is the same size as the first array but is an array of ...


1

LibGDX is primary written in java, so it binds OpenGL functions to java methods. In the process of binding LibGDX is not required to keep original namespaces (java's equivalent of c/c++ namespace is package). LibGDX has a few classes which contain bindings to OpenGL functions and fields. Those classes extend each other: class containing bindings to the most ...


2

The relationship between the Gun and the Bullet is purely 'spawner/spawned'. It's not parent-child. In real-life, when you shoot a bullet with a gun, both objects are no longer linked: you can move the gun as you want, once the bullet is out of the barrel, there's nothing you can do to change its trajectory. So in your case, you should make the bullet as ...


4

You must configure GDX to use GL30 prior to calling functions on Gdx.gl30: config.useGL30 = true; com.badlogic.gdx.graphics.GL30 does not contain glClear and glClearColor in its interface because it is a subclass of com.badlogic.gdx.graphics.GL20 and those functions are inherited from GL20 therefore there is no need to define them in GL30's interface. ...


1

Some years ago, Blizzard had an April fool's joke about World of Warcraft: the Ogre character (two-headed), could be played by two players. This was hilarious, because it's a non-sense. You're doing the same thing here: you have two different systems that control the same component. An entity's position should be controlled either by the PhysicsSystem or ...


1

I see two solutions to this: Make your player a part of the TiledMap by adding him to his own layer. This will automatically render him in the correct order like all of your other tiles. Add an integer property to your tiles in whatever program you're using to create your maps named "zIndex" and then sort your tiles by this property and render them in the ...


1

Unless there's a specific reason you'd need (want) to process the data in a State you should probably stick to Ashley's own EntitySystem. Without you yourself expanding the functionality of State, EntitySystems are for sure more flexible, as in you can tell it to not process the system, you can do something when it's added / removed etc. Also the ...


3

A simple way to achieve smooth lighting in a tile based game, is to draw a "lightmap" to a render target, and then drawing this render target over top your scene while alpha blending it. Your light map render target would be the size of your tile map, but in pixels. Each pixel would represent the light color of its corresponding tile. This render texture ...


0

For now this is the way I handle AI messaging with ashley ECS in libgdx. TelegraphAgent implements Telegraph { StateMachine fsm; public TelegraphAgent (StateMachine fsm) { this.fsm = fsm; } @Override public void handleMessage(Telegram msg) { fsm.handleMessage(msg): } } AIComponent implements Component { ...


0

I'm aware this is really late and you've probably already solved the problem but for future readers: This forum post helped me: http://badlogicgames.com/forum/viewtopic.php?f=11&t=12343 If you move the camera while part way through a pan or ANY gesture the coordinate system being used for the x and y coordinates is changed and that's why you get the ...


1

Sort by z position. You will probably want to add an origin to every object as well to determine their position in the game world (ie the players feed, the center of where the box touches the ground, etc.). There are some restrictions for what objects this will work for though. When the players z position becomes larger or smaller than that of an object he ...


0

If only there was a magical place where you could look up things like this. https://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ImageButton.html#draw-com.badlogic.gdx.graphics.g2d.Batch-float- I wonder if that button classes draw routine could help. Hmmmmmm.


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


0

I think that you have error in your collision testing function. Maybe it has to be like this: foreach (Rectangle wall in walls) { /* your code here */ } In your original code you are not testing all the walls from the list generated by getWalls() procedure.


0

The documentation isn't clear about the ordering of the scores. When the documentation doesn't guarantee any kind of order, guarantee it yourself. I suggest you simply iterate through the list, keeping track of the largest (for O(N) time).


0

If you want the text to show up above the monster's head, you'll have to add at least the monster's sprite's height to the base Y of the font, something like: Assets.font.draw(spriteBatch, "Monster", position.x, position.y + getFrame().getHeight()); Secondly, if you put the font rendering code before the sprite/texture rendering code, the font will be ...


0

I don't know LibGDX or if it has a built in animation library, but you can be certain that it does give you the ability to scale a sprite. All you have to do is use a function of the desired graph shape to pick the size you'll render the button on each frame. For example, a linear interpolation for the scaling values will produce a perfectly smooth(err, ...


0

LWJGL is a low level framework that includes window creation, input handling and other low level features. Libgdx is a full featured 2d and 3d game framework that is built on top of LWJGL. The typical workflow for drawing a triangle on screen with LWJGl is: 1- Create a window using the included GLFW3 framework. 2- Create an Opengl context using the built in ...


0

LWJGL is Lightweight Java Game Library. It is not engine. LWJGL is a Java library that enables cross-platform access to popular native APIs useful in the development of graphics (OpenGL), audio (OpenAL) and parallel computing (OpenCL) applications. This access is direct and high-performance, yet also wrapped in a type-safe and user-friendly layer, ...


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


0

Strange bug, after slight editing of image, and saving image as png again, exception dissapper. During debug of application i saw TExture constructor call PixMap constructor and send FileHandle of file as argument, constructor read bytes from image (dont know correctly or with errors) then those bytes go to Gdx2DPixmap(bytes, 0, bytes.length, 0) and that ...


0

I am also picking tile variations based on a tile's eight neighbors. Encoding the neighborhood is fairly simple, but deciding what pattern each set of bits represents is kind of tricky. I currently just have collections of matching ints for each pattern, and I am checking each pattern type for containment. I do have the impression that a Binary Trie could ...


1

I'd try to avoid using any form of event dispatch within an ECS. From the looks of it you're trying to change state based on some kind of input. I assume that block of code where you track input is inside a system. So instead of dispatching an event why not just update the requisite components directly from that system. Systems can process multiple types ...


0

If I'm not mistaken, you want to create a pool of different monster without creating many pools? If yes, just create a MonsterPool that extends Monster public class MonsterPool<T extends Monster> extends Pool<T>{ } public MonsterFactory<T extends Monster> { Array<T> activeMonster = new Array<T>(); MonsterPool<T&...


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


0

There are a lot of different kinds of transition. To concretely answer this question clarify which kind of transition you are looking for. If you want to do a blended transition, you'll need to render a single frame of the old scene to a buffer, render a single frame of the new scene to a buffer, and then do the transition animation. Here's a pointer for ...


0

You are totally defeating the purpose of using an Entity-Component-System by creating that Character class. The whole drive behind ECS architecture is the decoupling/separation of data(Components) and logic(Systems). What you need to do is create separate Systems to handle attack and movement logic. Read these two articles, they'll help you get a better ...


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


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


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


0

This colour usually comes from the texture itself. When using alpha transparency, even fully transparent texels still have an RGB colour, though it's usually unseen. Because we don't see it, image editors and compression tools can be inconsistent in how they handle these areas - filling them with white, black, or streaked-out copies of adjacent texels to ...


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

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()


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


0

The LibGDX Animation class is primarily a container of keyframes (Texture or TextureRegion instances) with some extra logic to pick the correct keyframe given a time and a play mode (normal, loop, ping-pong, etc...) The important part is that the timer that is used to get a keyframe is not built in to the Animation instance and so there should be a separate ...


0

The answer lies in here : shapeLabel.setTouchable(Touchable.disabled); With this I am able to achieve what I intended to do. The other alternative I found is to relay the events using InputMultiplexer. But, I felt the above solution to be simplest.


0

To answer your question; it should be absolutely fine to have static fonts. As long as you remember to dispose of them when you exit the game. What I would recommend though is using the AssetManager (like spectacularbob mentioned in his comment). In reality you should probably use the AssetManager for all of your assets (music, textures, atlases, fonts etc.)...


0

I'm not 100% sure if I understood your question, so hopefully this answer answers some of your questions haha :) My current approach I've encountered this problem multiple times, and the method which I'm using right now is creating my own interpreter. Basically I have a file that looks something like this: [catapult] setName:catapult, setType:siege, ...


0

First of all, we remove these two lines, because we don't want to add them separately: table.add(healthbar).expandX().pad(10).left(); table.add(playerLook).expandX().pad(10).left(); Then we change this: stack.add(table); stage.addActor(stack); to this: table.add(stack); stage.addActor(table); Because we don't wish to add the table to the stack, we ...


0

Dispose() is not called automatically. You have to call it manually whenever you with to dispose a texture (or anything that implements disposable). The only dispose() that's called automatically is ApplicationListener.dispose() and Game.dispose(), since it implements ApplicationListener. As for solving the memory leak I'd suggest only using AssetManager ...


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


0

I think that experimenting with different values for your parameters should fix the issue. Specifically the zero threshhold and deceleration radius. If your deceleration radius is too short the dynamic body won't have enough time to slow down to a speed within the zero threshhold and will overshoot the target. Try playing with the demo that's provided with ...


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


0

There are multiple ways to solve this issue. The first way to solve this would be to use procedural generation and simply create more terrain on the fly when the player reaches the edge of the map. Depending on what you currently have, this could be pretty hard to achieve. The second would be to add walls to the map, so the player can't reach the edge of ...


0

DISCLAIMER: I am still a newbie when it comes to ECS so do not consider the following as a definitive answer To me it seems that a bullet should be an entity instead of a component since it probably has to be rendered (unless you're taking the hitscan route) and has to interact with the world a.k.a. physics. As for pooling, it depends on what has to be ...


0

It seems like you are going about this the wrong way. Linear interpolation is the process of transitioning from one value to a second value, which is exactly what you are looking for with your movement. I'm unaware of java and libgdx syntax, but here's some example code so you get the idea. Here's what you need: Vector2 CurrentPosition : Your characters ...


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


0

The solution can be achieved in multiple ways, but checking the remaining distance between the current and the target position is a good way to go about this. distance = targetPosition.sub(position).getLength(); if (distance < some_small_constant) { position = targetPosition; } The code first creates a vector from the current position to the target ...


0

Question 1: Can we change a file's extension ("file.png" to "file.abc") and read it as if it had the same extension? Yes this is possible with LibGDX. Question 2: How can I put multiple files into same file, just like AAA games do? I ended up putting them inside a Zip file and changed the extension. Question 3: Can I just create a non-compressed ...



Top 50 recent answers are included