Hot answers tagged

74

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


73

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


2

If you want to make your sprite move at a constant speed alond the squircle, you should transform it into a vectorial path, in order to calculate its linear speed instead of the angular speed as you did. If you want to work with angular speed, there's no problem as it will be a good approssimation anyway. Although you used the formula found on Wikipedia, ...


2

More code would be helpful, but you likely need to put this in your show method. public void show() { Gdx.input.setInputProcessor(yourInputProcessor); // This should keep it from exiting. Gdx.input.setCatchBackKey(true); ... }


1

It seems that if the VerticalGroup is added to another layout, then it works. Looking at the code, this is due to VerticalGroup also being a Layout, and so it's prefWidth/Height are used instead of the getWidth/Height methods. I got around this by manually setting the size to the pref. size. setSize(getPrefWidth(), getPrefHeight()); Note, that you don't ...


1

If you want to setup a physics data for an object that is already on the screen, just right-click on it and select “Edit Physics” button from drop down menu, this will bring up the “Edit Physics” dialog. There you can choose if your object is static or dynamic, set its mass, friction, density and so on, and draw the polygon mesh for its fixture shape. ...


1

It is a little bit difficult understanding your question, but I think your problem is caused by the fact that you update all ballons in the update (float dt) method even though you're not drawing them. This means that when 200 iterations has passed and you draw ballons and ballons2 for the first time, they have already moved some distance.


1

The algorithm you are using right now has a runtime of O( n^2 ). A tree structures can help you get that runtime lowered. Quadtrees have O( log(n) ) From that you can calculate if you will benefit from a quadtree.


1

in your update method you should add the below code. if (Gdx.input.isKeyPressed(Keys.BACK)) { game.setScreen(new MenuScreen(game)); } // and in your game Screen classes show method Add this code Gdx.input.setCatchBackKey(true);


1

Try changing the image using setDrawable() method: loading.setDrawable(new TextureRegionDrawable(new TextureRegion(new Texture("90.png")));


1

You missuse the animation class. you need to do the following: currentframe = animation.getKeyFrame(Gdx.graphics.getDeltaTime(), true); Currently you use an increasing time for your time passed. which is wrong, the animation class handles the passed time by itself. Easier explained: Imagine a cake. If you eat constantly 3 percent you'll see it fade ...


1

Shadow and Ball are key aspects. Shadow size and distence between Ball and shadow should increase when height increase. Also, Ball size should increase when Ball height increase. Shadow position represents position of ball in 2d and when Ball height increase you have to change Ball position (I m assuming that light source is homogen and it is not single ...


1

Brief: The solution is not in collision listeners, but in collision filters. Collision filters have a shouldCollide method that you can implement to return false if you want to disable collision or true to allow it. Collision filters are executed before collision listeners. You can use, for example the linear velocity of the player sprite to decide if you ...


1

You need to learn a little bit more about vectors but I'm going to explain it anyways. First of all, let's say that your 'game unit' is in pixels and that points (coordinates) and vectors have two components x and y. Let's assume that you have two given points A = (x1, y1) and B = (x2, y2). To get the vector between A and B, you have to do the following ...


1

Your primary question is: So how do I implement the force? Considering that your body is always underwater, there's an easy way out of this one: just use gravity :) As iforce2d points out in his tutorial on custom gravity, you can set the gravity scale of any object: //Box2D v2.2.1 onwards body->SetGravityScale(0);//cancel gravity (use -1 to ...



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