Questions tagged [java]

Java is both a popular object-oriented programming language and runtime environment which allows Java programs to run unchanged on most hardware and software platforms.

Filter by
Sorted by
Tagged with
1
vote
1answer
71 views

How to add lighting to a 2D Tile-based game in JavaFX?

I'm making a 2D roguelike tile-based game with Java and JavaFX. I'm currently working on adding lighting and darkness to the dungeon, but whenever I try running it, it takes a very long time to load, ...
1
vote
1answer
363 views

Calculating World Unit or Pixels Per Unit values

Is there a formula to calculate world unit or pixels per unit values in LibGdx? Most of my objects fit into a 32x32 or 16x16 frame. When the objects are close to 32x32, and I use ...
0
votes
1answer
51 views

InputListener not working on a custom Actor

Right now I am working on a UI for my game. I'm adding my own UI elements to a group and adding that to a stage. But the listeners I'm adding to the actors are not firing off at all. I have looked on ...
3
votes
2answers
470 views

Strange LibGdx box2d body.ApplyLinearImpulse(); behavior

I have been working on this game NinjaThief and when I apply linear impulse to player body it just keeps on moving. Some of the functions are still unfinished so it looks a bit messy. Here is my code:...
2
votes
2answers
209 views

Understanding HingeConstraint in jBullet

I'm using the java port of BulletPhysics engine jBullet. I'd like to make a joints between 2 triangles so that one edge of the first and one edge of the seconds act like a hinge. But I don't ...
1
vote
1answer
163 views

Handling mouse input depending on selected unit and clicked tile

I am making a turn-based tactical game (think something like X-Com) and I am currently trying to figure out how to handle mouse input in a clean way without a mess of if-statements. I have a lot of ...
4
votes
2answers
2k views

Libgdx Scene2D Table background not showing up

I am using Libgdx's Scene2D API to build my UI and everything has been working as expected until now. I created a Skin and a ...
5
votes
1answer
2k views

Drawing fonts with LWJGL3 with OpenGL

I'm very sorry if this question has already been answered, but since I've been struggling with this for many days I thought I'd give it a shot here. My goal is to somehow render some text on the ...
3
votes
1answer
556 views

Moving sprite using the accelerometer in LibGDX?

I don't know how to use accelerometer in LibGDX; how could I use the the motion sensor? I'm working for a top down game with the motion sensor. I'm new to this framework. My sprite image is already ...
0
votes
1answer
281 views

switching scenes in libgdx?

I'm writing a little something in libgdx to learn more about the platform. Currently, I have a simple generated world consists of tiles, which are just blocks of texture drawn to the screen. It's a ...
1
vote
2answers
441 views

Java - Collision detection (Glitch)

I am working on a platformer game for the final year project in HS. However... The collision detection system I use is basically about checking wether a specific part of the character intersects with ...
1
vote
1answer
50 views

How to choose what to use in Java: Enums or Objects?

I'm in a dilemma over using Enum Types or using class objects in that particular part of my java project. Let's suppose I have an array where I constantly add and remove things from it, but I also ...
5
votes
1answer
1k views

libGDX using Stage and Actor produces different camera angles on desktop and Android Phone

libGDX using Stage and Actor produces different camera angles on desktop and Android Phone. Here are pictures demonstrating the problem: http://brandonyuh.minus.com/mFpdTSgN17VUq On the desktop ...
8
votes
2answers
1k views

Libgdx black rectangles problem

I'm working on a game for Android using Android Studio with LibGDX in Java. I recently found a weird problem when closing and reopening the game. When I first open the game, it works fine. If I click ...
1
vote
1answer
394 views

How to replace tiles in Tiled in AndEngine?

in my Game I Create object layers and interpret the shapes in the engine as collision objects...now I want when Player collide with object, after a few seconds object falls...this works properly but ...
4
votes
2answers
2k views

Why do separate loops run faster than one loop that does multiple things?

My game had some lag, so I tried to improve the performance. I found that if I write my loops separately like this: ...
1
vote
1answer
361 views

Increase friction with a friction joint

I'm making a topdown 2.5D game (think the legend of zelda: a link to the past) using libgdx and box2D. to simulate friction from a topdown perspective, i've set the gravity for the box2D world to 0, ...
0
votes
1answer
286 views

Rendering an isometric tilemap

I have a tile which is 512x256 pixels and I'm trying to render it in an isometric fashion. I have this helper function: ...
0
votes
1answer
367 views

LibGDX: Best Texture Sizes to use for highest resolution?

I have two texture atlases: 1 is 1024x1024 (mostly used for GUI elements), the other is 2048x2048 (for game objects like characters). I used Texture filter mip map linear on them. But when the ...
1
vote
4answers
5k views

How to scale bitmap font without having it pixelated

How do i increase the size of a bitmap font without having it get pixelated, in libgdx?
0
votes
1answer
87 views

Java Swing KeyBindings do not recognize input in a weird way

I am new to programming, so forgive me if I make silly mistakes. I want to make a game, and I started by making the player, and that's where I'm stuck at. I'm trying to use Keybindings (InputMap and ...
0
votes
1answer
28 views

Libgdx, button onclick event crashes

I'm trying to create an android game using libgdx with a Titlescreen, you just press start and your game startes. However I'm having difficulty trying to get these buttons to work. The titlescreen ...
7
votes
2answers
3k views

Matrix rotation wrong orientation LibGDX

I'm having a problem with matrix rotation in libgdx. I rotate it using the method matrix.rotate(Vector3 axis, float angle) but the rotation happens in the model orientation and I need it happens in ...
0
votes
1answer
87 views

Topdown Game Collision Detection

I am working on a simple game with topdown movement, but I am unable to get the collisions to work properly. I know the collision detection itself works, but the constraining of the player is where I ...
0
votes
0answers
17 views

Sliding against a wall is “sticky”

I try to implement a ball sliding mechanism in my game. When the ball collides with a wall, it gets bounced. When it's close enough though (after many bounces) it will start to slide against it. But ...
0
votes
1answer
167 views

Tuning physics for a “worms”-like game

I'm using LibGDX and Box2D for my physics but my characters bounce all over the place when moving and if there is a small slope in the terrain they launch off of it. I've tried tweaking settings but ...
1
vote
1answer
53 views

Java - set resolution of game

Hi everybody I am making small game using pure Java 8 and rednering it by Java AWT Graphics2D method . My question is how to make that user can change the quality ...
0
votes
1answer
450 views

Graphics2D.drawImage not working

I'm quite new to java. I'm trying to come up with my own game after watching a few video tutorials. However, I encountered a problem where I cannot draw an external image file that I loaded using the ...
0
votes
0answers
23 views

What design choice should I follow for client-server communication?

My game server currently launches a thread for each connected client, and handles all data exchange through that socket in a server-blocks-until-client-requests fashion. The problem derives from the ...
1
vote
2answers
202 views

libgdx Camera and World Size Question

I'm new to libgdx and especially to using OrthographicCameras. I'm trying to understand how useful they are. The question is, suppose I have a game map 500 units wide. I have an OrtographicCamera ...
1
vote
1answer
549 views

How to use a KeyListener and an input handler together?

The following class implements a KeyListener, and handleInput() method gets called in an endless loop. ...
1
vote
1answer
168 views

How to insert animation into table?

I'm having trouble inserting animation into my libGDX table cell. I have a class which holds 2 tables, one on the left and one on the right. First table is for labels/buttons/other stuff. Second table ...
0
votes
1answer
27 views

Box2d: crash on createBody in beginContact callback

I am getting this error on creating body in contactListener ...
4
votes
1answer
519 views

How do I detect if two sprites are being touched at the same time?

How do I detect if two sprites are being touched at the same time? I was able to detect one sprite, but not if another sprite is being touched by the second pointer. ...
1
vote
2answers
4k views

keyPressed is not working after adding ActionListener to JButton

I have a serious problem while trying to build a menu for my game. I've added two JButton to a main JPanel and added an ActionListener for each of them. The main JPanel also contains the game JPanel ...
0
votes
1answer
253 views

LibGDX - Animate Player using Finite State Machine in Ashley ECS

Hi everyone this is my first question on this forum hope you can clarify my doubt. I'm gonna start by saying that im not very good at english so my apologies. So I have a big school project and I'm ...
0
votes
0answers
19 views

empty screen in my game

Below are 5 activities that form my simple app; I still can't figure out why it doesn't show anything(only a black empty screen): I have another question: Is there any issue with using time in ...
0
votes
1answer
195 views

How do you save the rendering of a tiled map to an image?

Im currently using LibGDX and drawing a tiledmap with the OrthogonalTiledMapRenderer. Is there a way to save one rendering and put it into some file as an image? If you know of a method that doesnt ...
0
votes
1answer
42 views

What is the most efficient way to load all the textures?

I am developing a game (in Java) that is going to have a lot of textures and images in it. What is the most efficient way to load all the textures? I was thinking on pre-loading all the images ...
0
votes
1answer
206 views

Billboard quad in same draw call?

I am currently drawing a isometric world in 3D, meaning the floors and walls are all quads aligned to the original axis in the world and using a rotated orthogonal camera to "distort" the images into ...
0
votes
1answer
327 views

Drag and drop more than one sprite (image) on Libgdx

well i am trying to achieve the same effect of windows desktop , you can select multiple icons and drag all of them to differents positions. here you can see how i select the images in the second ...
0
votes
1answer
173 views

Libgdx can't read .ttf file when running Android configuration

Firstly, I am aware that a similar question was asked some time ago that went unanswered. Currently, it has multiple upvotes but no answer. The error ...
1
vote
1answer
228 views

Slick 2D Image move along with shape

I am trying to move my image along with the shape so I can make the collider with the shape (some kind of space shooter) but my image does not move along with the circle I make for it. It dissapears ...
1
vote
1answer
883 views

LibGDX: How to use AssetManager with Texture Atlases?

A similar question was asked before, but I never saw an answer. How does one load individual texture regions that derive from a texture atlas using assetManager? I know that assetManager relies on a ...
0
votes
1answer
43 views

How do you repeat 2D tiles in Java code when you go out of range?

I am looking up tutorials on how to make 2D games, and I can just copy and paste their code but I would rather know what it means and how to do it. Suppose you have a 2D game window that has a map ...
0
votes
0answers
8 views

adding video to jrame

I am using java to build a game and I want to do something like that example: I am pressing some pre-detmired button that causes a video to start. I want to do something like a cutscene that will ...
1
vote
3answers
9k views

Handling multiple pressed keys with KeyListeners

I'm making a game Applet with Java that uses KeyListeners to control a paddle (for a game like Breakout/Pong). My basic implementation goes like this: ...
4
votes
1answer
618 views

Spawning enemies in four different positions with a fixed trajectory in android game

This is my first android game, I appreciate all the help. I want to define 4 spawning zones starting from out of the screen (left, right, up and down). Enemies coming from this areas have a fixed ...
0
votes
0answers
28 views

best method to draw in android studio games

After several tries to draw my player, enemy object in my game, I often face a problem rendering either because the method cannot be resolved or because I have a player and enemy classes both extend ...
0
votes
0answers
12 views

LibGDX - Java — How do I determine the alpha value of a pixel programmatically?

My goals are to generate hit boxes and click boxes using alpha values (so that parts of my textures that are invisible remain uninteractable) I have code already for determining if the mouse is ...

1
2
3 4 5
66