Tag Info

Hot answers tagged

2

First your use of the aspect ratio is nonsense. The aspect ratio is the relation of width to height. So if you have float aspectRatio = (float)myGameHeight / (float) myGameWidth; This means that the the following is true: myGameHeight == aspectRatio * myGameWidth If you want to preserve the aspect ratio of the screen you need to do the following: ...


2

After days of stress, I've finally fixed the problem. After performing a backtrace on the main thread I discovered the program came to a halt when trying to load the Google Analytics trackers. This is the thread backtrace: at com.google.android.gms.analytics.ae.getLogger(Unknown Source) at com.google.android.gms.analytics.ae.W(Unknown Source) at ...


2

This is due to either a context loss or simply you disposing your textures, without recreating them at the proper time (as you pointed out).


1

Are all coins doing the same animation? You could make a method in the Animation class that takes a coin as an argument, then performs the animation on that coin. Then, on another class, you make a loop that traverses the coin list and calls the method in your Animation class, therefore animating each coin as you go through the list. You can also add delay ...


1

Idea behind screens, is to separate logic between different context. However, those screens can still share data and have references to some classes that were originally initialized at original game class. If you don't use screens, you will have to dump all the code to main game class. Even if you try to hide logic behind different classes, you still end up ...


1

Calculating the vector that points from a spring at point A = (x0, y0) to a spring at point B = (x1, y1) is simply: v = (x1 - x0, y1 - y0) Assuming no other forces acting on the player, then changing the player's velocity to some scalar multiple of v when they hit spring A would direct them to spring B. If another force like gravity is involved, then, ...


1

The issue is the else condition after you check the A and D keys, since if no key is pressed it will reset the direction to 0, 0 every time the update() method is called. Instead of calling moveLeft() and moveRight() in the touchDown and touchUp you should keep track of each pointer passed by the touchDown and touchUp methods and check whether the pointers ...


1

If you're also working with box2D, you could try box2Dlights, it's a pretty nice wrapper and it's easy to implement as well.


1

There are ways to do dynamic lighting without shaders, although they're usually not as efficient. They often involve raycasting. The link below has some links to useful resources regarding dynamic lighting. http://www.java-gaming.org/topics/2d-dynamic-lighting/27012/view.html


1

Use Array (or regular java [] array!) (Ground[] grounds = initialize all;) with index that points to the first visible Ground in that array (int first = 0;). Keep some counter (float x = 0;) which will hold progress to the next index. void update(float delta) { x += delta * speed; if(x > groundWidth){ x -= groundWidth; ...



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