Hot answers tagged

76

Give the ball a height value. Draw a shadow at the ball's actual 2D position; the shadow will help spatially orient the ball for the player. When you draw the ball itself, offset the Y position by the "height" of the ball. If you want to implement more than just an illusion, use this height value in computations as well -- for example, you can implement the ...


75

Shadow and texture. Texturize the ball to show it rotating. This helps give the illusion of rotation of a sphere, which is more than 2 dimensions. A shadow can trick your brain into believing all sorts of things. Making flat things look like they have a third dimension. You don't even have to change the height of the ball, you just need to change ...


9

It won't hurt performance. It might in fact be (very, very negligible) faster because you save the overhead of passing these objects to the game objects. The reason static classes are often frowned upon is that their static properties are global variables and globals cause all kinds of problems architecture-wise. For example, when you ever decide you might ...


8

As someone who has recently released a libGDX game on Steam, unlike .NET and DirectX, Steam does not provide an option with your application to automatically check and download the version you need of those libraries. It's obtrusive to the user to make them install Java as a system library, as most still view the JRE, especially Oracle's, as some kind of ...


8

I am not familiar to the particular engine you are working with, but in most languages or cases you can use a 1xn matrix (i.e. a vector) where n is the total number of NPCs, that stores the 1-or-0 values, so the position within the vector is related to the NPC number. For instance, in pseudo-code: already_talked = {1,0,1...n} //where n is the total number ...


5

Don't keep newing up TextureRegions, try re-using one and just change the parameters of that. private TextureRegion bgRegion; public void create() { bgRegion= new TextureRegion(bgTexture, -1 * (int)bgObj.getX(),0,256,240); //bgObj is a scrollable object where in each update changes X value of position(Vector2): moves left. } public void draw() { //...


5

You seem to lack some insight on your issue. A couple of things to consider: Is your true maximum frame rate on your PC really 60 or is it more? NVida drivers limit the frame rate to the maximum draw rate of the monitor, typically 60 Hz; this is due to the fact that there is no need to ask to draw faster than what the monitor is able to process. By ...


5

Since Steamworks is a C++ API, you'd need to write a wrapper. You can use the Java Native Interface (JNI) for this, or possible the Java Native Access API instead. The JNI is the "classical" method, the JNA thing seems to be newer and I know less about it. The Steamworks SDK is not public, so I can't link you directly to the interface you'd want to wrap, ...


4

I'm going to tell you how to do it with a computationally cheap way in terms of CPU usage. First, let's say that the calculation of seking if a point is "inside the ellipse or not" is not computationally cheap, while comparing just rectangles with mere "greater than" or "less than" comparisons are ultra cheap. Definition 1) Ellipse and its quadrants If ...


4

You are specifying a time in seconds as an integer value, but you are not taking into account the game's frames per second. If your game was running at 1 frame per second, it would work, because after two frames (thus, two seconds), your object would have travelled the specified distance. It's a simple case of multiplying your time by your FPS: int dst = ...


4

Delta time should not be used to calculate velocity, but position. When you set velocity.y to speed, you are saying "My character will move <speed> pixels per second in the y axis". Later, when you update the actor's position you will calculate the y position by character.position.y += velocity.y * deltaTime; An easy way to think about this is ...


4

If I understood you correctly, instead of defining "canTalk" as a boolean, you can just define it as an integer and start by assigning it either a NULL value or a -1. Then when the player is within the square range of any of the NPC, you just assign the canTalk = NPC index (0,1,2...n where n is total number of NPCs). Then, you set the dialogue function to ...


4

I've run into this kind of trouble a few times, but not yet on 3d. First of all, I'm not really sure you transformed correctly the acceleration formula... maybe this source can help in that way. Secondly, at the end of your post you mention you want to specify a specific TIME for the sprite from one point to the other, if that is your goal then you should ...


4

The Android memory profilers that comes with the Android Developer Tools will allow you to figure out what is consuming your memory. It comes in three parts; Memory Monitor (this is used to find performance problems, so we can ignore this one for this particular problem). Tool Heap Viewer Allocation Tracker Using the Heap Viewer you can take snap-shots ...


3

A lot of great Libgdx extensions have been added to the maven repository such as freetype, tools and many other great libraries. This means you can add extensions in a blink of an eye, at least if you used the gradle LibGDX setup. In your case you want to add freetype, look it up in the link above and select the version you need. Now select the tab Gradle ...


3

In the second case it is not drawing because the constructor with no arguments doesn't set a width and height for the image, however the constructor that takes the drawable obtains the values from it. To fix in your case: Texture texture = new Texture(Gdx.files.internal("cookie.png")); Image itemImage = new Image(); itemImage.setPosition(10, 10); itemImage....


3

I found out a solution to your other problem. To allow the typing of a dot you should create your own implementation of TextFieldFilter like this. public class DigitFilter implements TextFieldFilter { private char[] accepted; public DigitFilter() { accepted = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.'}; } @Override public ...


3

I don't believe there is a built-in function for this. You have a few options though: Use a 9-patch for table background with a border (thats what I do) Place another table underneath the main table, and make the size a bit bigger so you can see the edges, giving the impression of a border. This is probably your best choice since you want to control color/...


3

One option is to use a wake lock. Example from the docs: PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag"); wl.acquire(); // screen and CPU will stay awake during this section wl.release(); I've got this answer from this stack overflow post. ...


3

Try turning on the grid in Tiled (Ctrl+G) and adjusting your "Tile Side Length" in the Map Properties so that the grid matches correctly with your tiles. It may fix the libgdx rendering issue, and would improve the mouse picking in Tiled a little. I know setting up a hexagonal map (and even an isometric map) is somewhat confusing at the moment. It's ...


3

Move this after the for loop: dispose(); ((Game) Gdx.app.getApplicationListener()).setScreen(new GameOver()); You create/set a new GameOver Screen each iteration, that causes probably the freeze and problems.


3

If you just dispose the sound, you're trying to play something unexistent. Also, this is a bad practice because you're constantly creating and destroying a sound when playing it, and that's not needed. Try to get the dispose to the end of the game, place your sound somewhere available and just play or stop it when needed. This is some sketching code, not ...


3

To delete preferences data— Manually On desktop, shared preferences data is in User/.prefs. Simply delete the files in it. On Android, do App Info → Clear data. Programmatically (Android and Desktop) If you change the Key (string) of your sharedpreferece you will lose your data. To do this, use prefs.putInteger("keyString", newValue)


3

RTS's are probably one of the hardest game genres to make because of the huge amount of balancing that has to be done between different units, then on top of that multiplayer adds another layer of complexity... for example look at GreyGoo an RTS made by a proper development studio, they had the experience to balance the game but because of networking ...


3

Disposal patterns like LibGDX's in languages with GCs often have to do with releasing un-managed resources in addition to (or instead of) managed memory. This true with C#'s IDisposable interface, and based on the documentation LibGDX's pattern serves a similar purpose. This means that simply looking at private working-set CPU-side RAM use may not be an ...


3

I don't know about writing an error log on crash, but all Android apps already log to the built-in logger. You just need an app like CatLog to view them. Although verbose, you can usually filter by namespace (and see logs only related to your application). Eclipse does something similar with the built-in log viewer. This is the only log viewer I used when ...


3

I had faced similar problem, when I was building a tower defense game.Where I needed to check for collision between tower boundary (ellipse) and enemies (rectangle), first method : I have used the condition for checking if these points exist inside the ellipse like if(ellipse.contains(point1X,point1Y)||ellipse.contains(point2X,point2Y)...) { System.out....


3

Have you considered playing the sound when the direction of the ball changes? Or like add that as a condition, in addition to the already "collide with object" condition.


3

Sounds like you're looking for the vector magnitude, also called (depending on context) its length, Euclidean norm, or Pythagorean Theorem. ie. speed = sqrt(dot(velocity, velocity)); As Alexandre Vaillancourt points out, in libGDX the len() method does exactly this. Other environments will almost always have an equivalent (eg. in Unity it's .magnitude) ...


3

The texture regions inside don't need to be powers of two. But texture compression cells are often 4x4 so you have to be careful when using compressed textures that the edges of two texture regions don't share the same cell or they'll be compressed together which will degrade the quality if they have different colors. You should leave a N pixel border ...



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