Unfortunately, this code doesn't have achievements implemented. But you can follow the google tutorial. https://developers.google.com/games/services/android/achievements
And put all the methods that you create on Source Code/android/src/com/tutstecmobile/AndroidLaucher.java.
After that you just add this new method on the interface that connects the android Project with the core Project. That is located on
Now you can access the method that you created on the AndroidLaucher.java using
To change the initial position of the ball, all you have to do is to go to the PlayState.java. That is located on Source Code/core/src/com/tutstecmobile/states/PlayState.java. Then you go to the line 48, That is this one:
ball = new Ball(world, 200, Main.assetManager.groundTexture.getHeight());
The 200 is the horizontal position and the Main.assetManager.groundTexture.getHeight() is the vertical position. So, to start the ball 1 inch above the ground, you have to change the line to:
ball = new Ball(world, 200, Main.assetManager.groundTexture.getHeight()+100);
Now let's keep the ball in the air. In order to do that you have to remove the gravity, go to the line 44 at the PlayState.java:
world = new World(new Vector2(0, -9f), true);
world = new World(new Vector2(0, 0), true);
Then go to the line 118, there you will find a if statement, this if statement controls what happens after the first touch, so we have to set the gravity again, to set the gravity again you have to put this line after the if statement
world.setGravity(new Vector2(0, -9f));
To change the ball sprite, first you have to go to AssetManager.java. That is located on Source Code/core/src/com/tutstecmobile/utils/AssetManager.java. Then go to the line 17:
public Texture ballTexture;
and add a new texture, this should be your new 17 line
public Texture ballTexture, newBallTexture;
Then, after the line 41, load your new texture and filter it
newBallTexture = new Texture(Gdx.files.internal("data/sprites/ball/newBall.png");
Then, go to the Source Code/android/assets/data/sprites/ball and put the newBall.png there.
Now, let's go to the PlayState.java. That is located on Source Code/core/src/com/tutstecmobile/states/PlayState.java.
Then go to the line 118, there you will find a if statement, this if statement controls what happens after the first touch:
Inside the if statement you will update the ball's sprite
It works without any issues. I am now doing the same for end state, ie. when the ball hits the ground, I want to change the ball image to another ball image. With you current logic, I was able to create a new entry for adding a new texture.
I changed the ball sprite, under AssetManager.java. Then under line 17:
added a new texture
public Texture ballTexture, newBallTexture,endBallTexture;
Then line 41, loaded my new texture and filtered it
newBallTexture = new Texture(Gdx.files.internal("data/sprites/ball/endBall.png"
Then, went to the Source Code/android/assets/data/sprites/ball and put the endBall.png there.
Under PlayState.Java, I added the below line ball.getSprite().set(new Sprite(Main.assetManager.endBallTexture));
It looks like this now.
//Go to the game over state
// ball.getSprite().set(new Sprite(Main.assetManager.endBallTexture)); //added on 27.jan.2017
gsm.push(new GameOverState(gsm, score));
There are no error message upon compilation, but the game does not work as intended. Please suggest your solution.
What is happening is as soon as the ball touches the ground, the game will change the scene to game over. So, you are change the sprite, but you won't see it changing because the game changed the scene. What we can do is when the ball touches the ground, change the sprite, wait for X seconds and then go to the game over scene. Or we can add a ball with this new sprite at the game over scene.
I tried thread.sleep(3000), but it did not work as it is showing error. I also read, it pauses the application; It kills your battery, prevents normal system tasks from running properly, slows down other programs or stops them completely, makes the device unresponsive, and can even cause it to get hot in your hands. Is there any other way to do it?
The problem is that you change the size of the ball and didn't change the density of the ball. So the ball was so heavy that it barely left the floor. To fix this issue to go "Source Code/core/src/com/tutstecmobile/sprites/Ball.java" and at the line 86, you will see
fixtureDef.density = 0.5f;
Try to change the 0.5f to 0.1f, and see if you like the result.
A regular license allows an item to be used in one project for either personal or commercial use by you or on behalf of a client. The item cannot be offered for resale either on its own or as part of a project. Distribution of source files is not permitted.
An extended license allows an item to be used in unlimited projects for either personal or commercial use. The item cannot be offered for resale "as-is". It is allowed to distribute/sublicense the source files as part of a larger project.