{"id":89,"date":"2015-08-20T17:53:00","date_gmt":"2015-08-20T17:53:00","guid":{"rendered":"https:\/\/therenaissanceraven.com\/?p=89"},"modified":"2015-08-20T17:53:00","modified_gmt":"2015-08-20T17:53:00","slug":"libgdx-complete-tutorial-how-to-make-a-simple-libgdx-game-continued","status":"publish","type":"post","link":"https:\/\/therenaissanceraven.com\/?p=89","title":{"rendered":"*libGDX* Complete Tutorial: How to make a simple libgdx game &#8211; continued"},"content":{"rendered":"<p>Hello again! We are going to take our icicle mayhem game we just made (our whatever version you happened to have created!) and add some more advanced stuff to it, such as a main menu, achievements, and animations. We are going to build right off of the last post, so please visit that if you wish to get your game up to date for this tutorial.<\/p>\n<p><b>Step 1:<\/b><br \/>Adding a Main Menu! This is like the trunk to the tree of life, this is where we can branch off to many things, such as achievements, easy mode, hard mode, settings, high scores, etc, etc. To start we are going to create two java classes called MainMenuScreen and AchievementScreen, and fill them with the bare bones needed to make a &#8220;screen&#8221; work in libgdx, I&#8217;m also including the same background in this as the GameScreen as it will work well for our main menu. (For achievementScreen, just change the word MainMenuScreen to AchievementScreen in the two locations it appears).<\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">  1<br \/>  2<br \/>  3<br \/>  4<br \/>  5<br \/>  6<br \/>  7<br \/>  8<br \/>  9<br \/> 10<br \/> 11<br \/> 12<br \/> 13<br \/> 14<br \/> 15<br \/> 16<br \/> 17<br \/> 18<br \/> 19<br \/> 20<br \/> 21<br \/> 22<br \/> 23<br \/> 24<br \/> 25<br \/> 26<br \/> 27<br \/> 28<br \/> 29<br \/> 30<br \/> 31<br \/> 32<br \/> 33<br \/> 34<br \/> 35<br \/> 36<br \/> 37<br \/> 38<br \/> 39<br \/> 40<br \/> 41<br \/> 42<br \/> 43<br \/> 44<br \/> 45<br \/> 46<br \/> 47<br \/> 48<br \/> 49<br \/> 50<br \/> 51<br \/> 52<br \/> 53<br \/> 54<br \/> 55<br \/> 56<br \/> 57<br \/> 58<br \/> 59<br \/> 60<br \/> 61<br \/> 62<br \/> 63<br \/> 64<br \/> 65<br \/> 66<br \/> 67<br \/> 68<br \/> 69<br \/> 70<br \/> 71<br \/> 72<br \/> 73<br \/> 74<br \/> 75<br \/> 76<br \/> 77<br \/> 78<br \/> 79<br \/> 80<br \/> 81<br \/> 82<br \/> 83<br \/> 84<br \/> 85<br \/> 86<br \/> 87<br \/> 88<br \/> 89<br \/> 90<br \/> 91<br \/> 92<br \/> 93<br \/> 94<br \/> 95<br \/> 96<br \/> 97<br \/> 98<br \/> 99<br \/>100<br \/>101<br \/>102<br \/>103<br \/>104<br \/>105<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">MainMenuScreen<\/span> <span style=\"color: #008800; font-weight: bold;\">implements<\/span> Screen<span style=\"color: #333333;\">,<\/span>InputProcessor <span style=\"color: #333333;\">{<\/span><br \/>    <span style=\"color: #888888;\">\/\/Creates a reference to hold our \"passed\" game.<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> MyGdxGame game<span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/Defining the camera to be used<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> OrthographicCamera camera<span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/Texture for the cave background<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> Texture caveBackground <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Texture<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"cavebackground.png\"<\/span><span style=\"color: #333333;\">);<\/span><br \/><br \/><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #0066bb; font-weight: bold;\">MainMenuScreen<\/span><span style=\"color: #333333;\">(<\/span>MyGdxGame game<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/assigns the game we passed to the placeholder<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">game<\/span> <span style=\"color: #333333;\">=<\/span> game<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #888888;\">\/\/creates the camera<\/span><br \/>        camera <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> OrthographicCamera<span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/Sets the screen to be 800 width by 480 height<\/span><br \/>        camera<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setToOrtho<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #0000dd; font-weight: bold;\">480<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #0000dd; font-weight: bold;\">800<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/very important, lets us use the Input methods!<\/span><br \/>        Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">input<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setInputProcessor<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">);<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/>    <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">render<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span> deltaTime<span style=\"color: #333333;\">){<\/span><br \/>        <span style=\"color: #888888;\">\/\/Sets the color to be applied after clearing the screen (R,G,B,A)<\/span><br \/>        Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gl<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">glClearColor<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">255<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Clears the screen<\/span><br \/>        Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gl<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">glClear<\/span><span style=\"color: #333333;\">(<\/span>GL20<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">GL_COLOR_BUFFER_BIT<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/updates camera view<\/span><br \/>        camera<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">update<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/makes the camera fit onto the available screen<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setProjectionMatrix<\/span><span style=\"color: #333333;\">(<\/span>camera<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">combined<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Starts gameBatch for drawing<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">begin<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/All drawing needs to be done here<\/span><br \/>        <span style=\"color: #888888;\">\/\/Draws the Cave Background starting at x = 0, y = 0<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>caveBackground<span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Ends the gameBatch after drawing<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">end<\/span><span style=\"color: #333333;\">();<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/This method gets called when a key is pressed down<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">keyDown<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> keycode<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/happens upon lifting finger off of key<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">keyUp<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> keycode<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/called when the person lifts their finger off of the screen<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">touchUp<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> x<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> y<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> pointer<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> button<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">touchDown<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> screenX<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> screenY<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> pointer<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> button<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">keyTyped<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">char<\/span> character<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">touchDragged<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> x<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> y<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> pointer<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">mouseMoved<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> x<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> y<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">scrolled<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> amount<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">resize<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> width<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> height<span style=\"color: #333333;\">){<\/span><br \/><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">show<\/span><span style=\"color: #333333;\">(){<\/span><br \/><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">hide<\/span><span style=\"color: #333333;\">(){<\/span><br \/><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">pause<\/span><span style=\"color: #333333;\">(){<\/span><br \/><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">resume<\/span><span style=\"color: #333333;\">(){<\/span><br \/><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">dispose<\/span><span style=\"color: #333333;\">(){<\/span><br \/><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Now, we need to actually open this screen first, before the GameScreen, to do this, go to the MyGdxGame.Java class and edit the portion where we &#8220;setScreen&#8221; in the create function to the following:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">1<br \/>2<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">        <span style=\"color: #888888;\">\/\/this will set the screen to our next class \"MainMenuScreen\"<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setScreen<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">new<\/span> MainMenuScreen<span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">));<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>This will now set our first screen of the game to our MainMenuScreen. Now we need to add some options\/buttons to the screen. One drawback right now is that the buttons I will be creating will be graphically-tactile free.. as in, once your finger touches the button, it does not visually depress. We can make an animation play when the button is pressed, and maybe ill include that latter but for now, we will keep them static.<\/p>\n<p>mainmenuscreen.png:<\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/1.bp.blogspot.com\/-c5Jy80_niZA\/Vdc4ijH1cHI\/AAAAAAAAAc8\/FBTzwlMy0wc\/s1600\/mainmenuscreen.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/1.bp.blogspot.com\/-c5Jy80_niZA\/Vdc4ijH1cHI\/AAAAAAAAAc8\/FBTzwlMy0wc\/s1600\/mainmenuscreen.png\" \/>&nbsp;<\/a><\/div>\n<div style=\"clear: both; text-align: left;\">Now we are going to create a new variable in the MainMenuScreen to use our Texture:<\/div>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">1<br \/>2<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">    <span style=\"color: #888888;\">\/\/Texture for button Overlay<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> Texture menuTexture <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Texture<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"mainmenuscreen.png\"<\/span><span style=\"color: #333333;\">);<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Adding our texture to draw in the render section after we draw the cavebackground:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">1<br \/>2<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">        <span style=\"color: #888888;\">\/\/draws our button overlay<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>menuTexture<span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">);<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>&nbsp;We are now going to create two rectangles the same shape as the button to use, we define them as follows:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">1<br \/>2<br \/>3<br \/>4<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">    <span style=\"color: #888888;\">\/\/Rectangle for our play button<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> Rectangle playButton <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Rectangle<span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">70<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">505<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">355<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">73<\/span><span style=\"color: #333333;\">);<\/span><br \/>    <span style=\"color: #888888;\">\/\/Rectangle for our achievement button<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> Rectangle achievementButton <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Rectangle<span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">74<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">340<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">355<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">73<\/span><span style=\"color: #333333;\">);<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Now that we have the buttons on screen, we need to be able to press them. Thus we will go into the touchDown function in MainMenuScreen:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">    <span style=\"color: #888888;\">\/\/function is called upon the screen being pressed<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">touchDown<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> screenX<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> screenY<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> pointer<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> button<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/this changes the screenX and screenY from the pixel number on the phone, to the pixel<\/span><br \/>        <span style=\"color: #888888;\">\/\/number associated with our game.<\/span><br \/>        <span style=\"color: #333399; font-weight: bold;\">float<\/span> xPos <span style=\"color: #333333;\">=<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)<\/span>screenX<span style=\"color: #333333;\">\/<\/span>Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">graphics<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getWidth<\/span><span style=\"color: #333333;\">()*<\/span><span style=\"color: #0000dd; font-weight: bold;\">480<\/span><span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #333399; font-weight: bold;\">float<\/span> yPos <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">800<\/span><span style=\"color: #333333;\">-(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)<\/span>screenY<span style=\"color: #333333;\">\/<\/span>Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">graphics<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getHeight<\/span><span style=\"color: #333333;\">()*<\/span><span style=\"color: #0000dd; font-weight: bold;\">800<\/span><span style=\"color: #333333;\">;<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/if click was in our play button<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>playButton<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">contains<\/span><span style=\"color: #333333;\">(<\/span>xPos<span style=\"color: #333333;\">,<\/span>yPos<span style=\"color: #333333;\">)){<\/span><br \/>            <span style=\"color: #888888;\">\/\/Tells MyGdxGame.java to set the screen now to our GameScreen<\/span><br \/>            game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setScreen<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">new<\/span> GameScreen<span style=\"color: #333333;\">(<\/span>game<span style=\"color: #333333;\">));<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/if click was in our achievement screen<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>achievementButton<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">contains<\/span><span style=\"color: #333333;\">(<\/span>xPos<span style=\"color: #333333;\">,<\/span>yPos<span style=\"color: #333333;\">)){<\/span><br \/>            <span style=\"color: #888888;\">\/\/Tells MyGdxGame.java to set the screen now to our AchievementScreen<\/span><br \/>            game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setScreen<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">new<\/span> AchievementScreen<span style=\"color: #333333;\">(<\/span>game<span style=\"color: #333333;\">));<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Now we are able to enter the AchievementScreen and GameScreen, but we are lacking the ability to be able to go back to the main menu. Thus we will have to rework some of the GameScreen&#8217;s end game code to allow the player to either replay the level or return to the main menu to look at achievements or other future add-ons. To start, I edited the old gameOver.png to include our buttons.<br \/>gameOver.png: <\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/4.bp.blogspot.com\/-Kd1uK5CMKU8\/VddBQczKT_I\/AAAAAAAAAdQ\/C8Z-Hsz2xwA\/s1600\/gameOver.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/4.bp.blogspot.com\/-Kd1uK5CMKU8\/VddBQczKT_I\/AAAAAAAAAdQ\/C8Z-Hsz2xwA\/s1600\/gameOver.png\" \/><\/a><\/div>\n<p>We will once again define two new rectangles in our GameScreen class for the buttons:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">1<br \/>2<br \/>3<br \/>4<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">    <span style=\"color: #888888;\">\/\/Rectangle for our play button<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> Rectangle replayButton <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Rectangle<span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">62<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">425<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">340<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">62<\/span><span style=\"color: #333333;\">);<\/span><br \/>    <span style=\"color: #888888;\">\/\/Rectangle for our achievement button<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> Rectangle mainMenuButton <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Rectangle<span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">62<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">264<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">340<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">62<\/span><span style=\"color: #333333;\">);<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Then we are going to edit the checkScreenPress() function code to down to just directions:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">    <span style=\"color: #888888;\">\/\/checks if the screen is pressed<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">checkScreenPress<\/span><span style=\"color: #333333;\">(){<\/span><br \/>        <span style=\"color: #888888;\">\/\/if screen is pressed<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">input<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">isTouched<\/span><span style=\"color: #333333;\">())<\/span> <span style=\"color: #333333;\">{<\/span><br \/>            <span style=\"color: #888888;\">\/\/gets the location of the press, and determines which half of the screen was pressed<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">if<\/span> <span style=\"color: #333333;\">((<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)<\/span> Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">input<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getX<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">\/<\/span> Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">graphics<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getWidth<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">&lt;=<\/span> <span style=\"color: #333333;\">.<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>                <span style=\"color: #888888;\">\/\/if left half of screen, go left<\/span><br \/>                character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">goLeft<\/span><span style=\"color: #333333;\">();<\/span><br \/>            <span style=\"color: #333333;\">}<\/span> <span style=\"color: #008800; font-weight: bold;\">else<\/span> <span style=\"color: #333333;\">{<\/span><br \/>                <span style=\"color: #888888;\">\/\/if not on the left half of screen, it must be going right<\/span><br \/>                character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">goRight<\/span><span style=\"color: #333333;\">();<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Then we are going to dump the gameOver handling and button selection into the touchDown function as follows:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">    <span style=\"color: #888888;\">\/\/called when screen is touched<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">touchDown<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> screenX<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> screenY<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> pointer<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> button<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/only work when game is Over<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>gameOver<span style=\"color: #333333;\">){<\/span><br \/>            <span style=\"color: #888888;\">\/\/this changes the screenX and screenY from the pixel number on the phone, to the pixel<\/span><br \/>            <span style=\"color: #888888;\">\/\/number associated with our game.<\/span><br \/>            <span style=\"color: #333399; font-weight: bold;\">float<\/span> xPos <span style=\"color: #333333;\">=<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)<\/span>screenX<span style=\"color: #333333;\">\/<\/span>Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">graphics<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getWidth<\/span><span style=\"color: #333333;\">()*<\/span><span style=\"color: #0000dd; font-weight: bold;\">480<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #333399; font-weight: bold;\">float<\/span> yPos <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">800<\/span><span style=\"color: #333333;\">-(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)<\/span>screenY<span style=\"color: #333333;\">\/<\/span>Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">graphics<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getHeight<\/span><span style=\"color: #333333;\">()*<\/span><span style=\"color: #0000dd; font-weight: bold;\">800<\/span><span style=\"color: #333333;\">;<\/span><br \/><br \/>            <span style=\"color: #888888;\">\/\/if click was in our replay button<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>replayButton<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">contains<\/span><span style=\"color: #333333;\">(<\/span>xPos<span style=\"color: #333333;\">,<\/span>yPos<span style=\"color: #333333;\">)){<\/span><br \/>                <span style=\"color: #888888;\">\/\/resets char x position<\/span><br \/>                character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span> <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">240<\/span><span style=\"color: #333333;\">;<\/span><br \/>                <span style=\"color: #888888;\">\/\/clears icicles by creating new array<\/span><br \/>                icicleArray <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Array<span style=\"color: #333333;\">&lt;<\/span>Icicle<span style=\"color: #333333;\">&gt;();<\/span><br \/>                <span style=\"color: #888888;\">\/\/resets vars<\/span><br \/>                gameOver <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>                <span style=\"color: #888888;\">\/\/if score was higher than the high score<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>score <span style=\"color: #333333;\">&gt;<\/span> highScore<span style=\"color: #333333;\">){<\/span><br \/>                    <span style=\"color: #888888;\">\/\/write value of score to our file<\/span><br \/>                    file<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">writeString<\/span><span style=\"color: #333333;\">(<\/span>String<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">valueOf<\/span><span style=\"color: #333333;\">(<\/span>score<span style=\"color: #333333;\">),<\/span><span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">);<\/span><br \/>                    <span style=\"color: #888888;\">\/\/set our in-game high score to our new score<\/span><br \/>                    highScore <span style=\"color: #333333;\">=<\/span> score<span style=\"color: #333333;\">;<\/span><br \/>                <span style=\"color: #333333;\">}<\/span><br \/>                <span style=\"color: #888888;\">\/\/resets score<\/span><br \/>                score <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/><br \/>            <span style=\"color: #333333;\">}<\/span><br \/>            <span style=\"color: #888888;\">\/\/if click was in our main menu button<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>mainMenuButton<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">contains<\/span><span style=\"color: #333333;\">(<\/span>xPos<span style=\"color: #333333;\">,<\/span>yPos<span style=\"color: #333333;\">)){<\/span><br \/>                <span style=\"color: #888888;\">\/\/Tells MyGdxGame.java to set the screen now to our MainMenuScreen<\/span><br \/>                game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setScreen<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">new<\/span> MainMenuScreen<span style=\"color: #333333;\">(<\/span>game<span style=\"color: #333333;\">));<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>And then we have fully functional menu menu and gameScreen buttons to travel back and forth:<\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/3.bp.blogspot.com\/-XFajHtysJ6c\/VddGrDjBg6I\/AAAAAAAAAdk\/9svHo7qqFZ0\/s1600\/Capture11654564665.PNG\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/3.bp.blogspot.com\/-XFajHtysJ6c\/VddGrDjBg6I\/AAAAAAAAAdk\/9svHo7qqFZ0\/s1600\/Capture11654564665.PNG\" \/><\/a><\/div>\n<p>Then the last final step is to add a back arrow button to the achievement screen. We are not going to use the button style in the previous two screens because we would prefer to have pictures of achievements displayed on the screen. Here is the back arrow button i quickly designed:<br \/>backarrow.png:<\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/2.bp.blogspot.com\/-qru_wEAeaHg\/VddH4gGOJVI\/AAAAAAAAAds\/ikpOmpwlgys\/s1600\/backarrow.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/2.bp.blogspot.com\/-qru_wEAeaHg\/VddH4gGOJVI\/AAAAAAAAAds\/ikpOmpwlgys\/s1600\/backarrow.png\" \/><\/a><\/div>\n<p>Now we will add it as a texture to our AchievementScreen and create a rectangle for it:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">1<br \/>2<br \/>3<br \/>4<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">    <span style=\"color: #888888;\">\/\/Texture for the back arrow<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> Texture backArrow <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Texture<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"backarrow.png\"<\/span><span style=\"color: #333333;\">);<\/span><br \/>    <span style=\"color: #888888;\">\/\/Rectangle for our back arrow<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> Rectangle backArrowButton <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Rectangle<span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">800<\/span><span style=\"color: #333333;\">-<\/span>backArrow<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getHeight<\/span><span style=\"color: #333333;\">(),<\/span>backArrow<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getWidth<\/span><span style=\"color: #333333;\">(),<\/span>backArrow<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getHeight<\/span><span style=\"color: #333333;\">());<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Draw it in our render function after cavebackground:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">1<br \/>2<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">        <span style=\"color: #888888;\">\/\/draws our back arrow<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>backArrow<span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">800<\/span><span style=\"color: #333333;\">-<\/span>backArrow<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getHeight<\/span><span style=\"color: #333333;\">());<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>And then finally adding code to the touchDown function to work when the screen is touched:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">    <span style=\"color: #888888;\">\/\/called when screen is touched<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">touchDown<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> screenX<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> screenY<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> pointer<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> button<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/this changes the screenX and screenY from the pixel number on the phone, to the pixel<\/span><br \/>        <span style=\"color: #888888;\">\/\/number associated with our game.<\/span><br \/>        <span style=\"color: #333399; font-weight: bold;\">float<\/span> xPos <span style=\"color: #333333;\">=<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)<\/span>screenX<span style=\"color: #333333;\">\/<\/span>Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">graphics<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getWidth<\/span><span style=\"color: #333333;\">()*<\/span><span style=\"color: #0000dd; font-weight: bold;\">480<\/span><span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #333399; font-weight: bold;\">float<\/span> yPos <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">800<\/span><span style=\"color: #333333;\">-(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)<\/span>screenY<span style=\"color: #333333;\">\/<\/span>Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">graphics<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getHeight<\/span><span style=\"color: #333333;\">()*<\/span><span style=\"color: #0000dd; font-weight: bold;\">800<\/span><span style=\"color: #333333;\">;<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/if click was in our play button<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>backArrowButton<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">contains<\/span><span style=\"color: #333333;\">(<\/span>xPos<span style=\"color: #333333;\">,<\/span>yPos<span style=\"color: #333333;\">)){<\/span><br \/>            <span style=\"color: #888888;\">\/\/Tells MyGdxGame.java to set the screen now to our GameScreen<\/span><br \/>            game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setScreen<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">new<\/span> MainMenuScreen<span style=\"color: #333333;\">(<\/span>game<span style=\"color: #333333;\">));<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>And bam! we have all of the screens functional to go back and forth with. We will be stopping here with just these two screens, but you can easily envision how you would be able to add more screens later:<\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/3.bp.blogspot.com\/-N1pCkPfAd74\/VddcPSoBpNI\/AAAAAAAAAeA\/iF5RfkZG0gI\/s1600\/adsfgggg.PNG\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/3.bp.blogspot.com\/-N1pCkPfAd74\/VddcPSoBpNI\/AAAAAAAAAeA\/iF5RfkZG0gI\/s1600\/adsfgggg.PNG\" \/><\/a><\/div>\n<p><b>Step 2:<\/b><br \/>Creating achievements! The main aspect of achievements that needs to be worked in, is in the fact that you must save the achievements much like you do for the high score, so that we are able to save which achievements have been completed. So to help encompass that for us, we will be creating an AchievementManager.Java class as follows that stores our achievements, loads achievements, and saves achievements:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<br \/>38<br \/>39<br \/>40<br \/>41<br \/>42<br \/>43<br \/>44<br \/>45<br \/>46<br \/>47<br \/>48<br \/>49<br \/>50<br \/>51<br \/>52<br \/>53<br \/>54<br \/>55<br \/>56<br \/>57<br \/>58<br \/>59<br \/>60<br \/>61<br \/>62<br \/>63<br \/>64<br \/>65<br \/>66<br \/>67<br \/>68<br \/>69<br \/>70<br \/>71<br \/>72<br \/>73<br \/>74<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">AchievementManager<\/span> <span style=\"color: #333333;\">{<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/creates a reference to a local file called achievements<\/span><br \/>    FileHandle file <span style=\"color: #333333;\">=<\/span> Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">files<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">local<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"achievements.txt\"<\/span><span style=\"color: #333333;\">);<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/list of variables in order in the file<\/span><br \/>    <span style=\"color: #888888;\">\/\/achievement1 = score 10 points<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> achievement1 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #888888;\">\/\/achievement2 = score 20 points<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> achievement2 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #888888;\">\/\/achievement3.. you see where this is going 30 points..<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> achievement3 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> achievement4 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> achievement5 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #0066bb; font-weight: bold;\">AchievementManager<\/span><span style=\"color: #333333;\">(){<\/span><br \/>        <span style=\"color: #888888;\">\/\/loads achievements<\/span><br \/>        loadAchievements<span style=\"color: #333333;\">();<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/this loads the achievements<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">loadAchievements<\/span><span style=\"color: #333333;\">(){<\/span><br \/>        <span style=\"color: #888888;\">\/\/if file exists<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>file<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">exists<\/span><span style=\"color: #333333;\">())<\/span> <span style=\"color: #333333;\">{<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">try<\/span> <span style=\"color: #333333;\">{<\/span><br \/>                <span style=\"color: #888888;\">\/\/creates a buffered reader<\/span><br \/>                BufferedReader bufferedReader <span style=\"color: #333333;\">=<\/span> file<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">reader<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">254<\/span><span style=\"color: #333333;\">);<\/span><br \/>                <span style=\"color: #888888;\">\/\/reads each of our 5 lines as booleans<\/span><br \/>                achievement1 <span style=\"color: #333333;\">=<\/span> Boolean<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">parseBoolean<\/span><span style=\"color: #333333;\">(<\/span>bufferedReader<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">readLine<\/span><span style=\"color: #333333;\">());<\/span><br \/>                achievement2 <span style=\"color: #333333;\">=<\/span> Boolean<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">parseBoolean<\/span><span style=\"color: #333333;\">(<\/span>bufferedReader<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">readLine<\/span><span style=\"color: #333333;\">());<\/span><br \/>                achievement3 <span style=\"color: #333333;\">=<\/span> Boolean<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">parseBoolean<\/span><span style=\"color: #333333;\">(<\/span>bufferedReader<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">readLine<\/span><span style=\"color: #333333;\">());<\/span><br \/>                achievement4 <span style=\"color: #333333;\">=<\/span> Boolean<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">parseBoolean<\/span><span style=\"color: #333333;\">(<\/span>bufferedReader<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">readLine<\/span><span style=\"color: #333333;\">());<\/span><br \/>                achievement5 <span style=\"color: #333333;\">=<\/span> Boolean<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">parseBoolean<\/span><span style=\"color: #333333;\">(<\/span>bufferedReader<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">readLine<\/span><span style=\"color: #333333;\">());<\/span><br \/>                <span style=\"color: #888888;\">\/\/closes the buffered reader<\/span><br \/>                bufferedReader<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">close<\/span><span style=\"color: #333333;\">();<\/span><br \/>            <span style=\"color: #333333;\">}<\/span> <span style=\"color: #008800; font-weight: bold;\">catch<\/span> <span style=\"color: #333333;\">(<\/span>IOException e<span style=\"color: #333333;\">){<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/updates achievements and writes files<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">update<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> score<span style=\"color: #333333;\">){<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/I am sure there is better ways than doing this, but anyways.. checking if you<\/span><br \/>        <span style=\"color: #888888;\">\/\/beat any achievements then setting them true.<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>score <span style=\"color: #333333;\">&gt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">10<\/span><span style=\"color: #333333;\">){<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>score <span style=\"color: #333333;\">&gt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">20<\/span><span style=\"color: #333333;\">){<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>score <span style=\"color: #333333;\">&gt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">30<\/span><span style=\"color: #333333;\">){<\/span><br \/>                    <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>score <span style=\"color: #333333;\">&gt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">40<\/span><span style=\"color: #333333;\">){<\/span><br \/>                        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>score <span style=\"color: #333333;\">&gt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">50<\/span><span style=\"color: #333333;\">){<\/span><br \/>                            achievement5 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">true<\/span><span style=\"color: #333333;\">;<\/span><br \/>                        <span style=\"color: #333333;\">}<\/span><br \/>                        achievement4 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">true<\/span><span style=\"color: #333333;\">;<\/span><br \/>                    <span style=\"color: #333333;\">}<\/span><br \/>                    achievement3 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">true<\/span><span style=\"color: #333333;\">;<\/span><br \/>                <span style=\"color: #333333;\">}<\/span><br \/>                achievement2 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">true<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><br \/>            achievement1 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">true<\/span><span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/writes file<\/span><br \/>        file<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">writeString<\/span><span style=\"color: #333333;\">(<\/span><br \/>                        <span style=\"color: #888888;\">\/\/writes each achievement with including a line break between each<\/span><br \/>                        String<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">valueOf<\/span><span style=\"color: #333333;\">(<\/span>achievement1<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">\"n\"<\/span> <span style=\"color: #333333;\">+<\/span><br \/>                        String<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">valueOf<\/span><span style=\"color: #333333;\">(<\/span>achievement2<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">\"n\"<\/span> <span style=\"color: #333333;\">+<\/span><br \/>                        String<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">valueOf<\/span><span style=\"color: #333333;\">(<\/span>achievement3<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">\"n\"<\/span> <span style=\"color: #333333;\">+<\/span><br \/>                        String<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">valueOf<\/span><span style=\"color: #333333;\">(<\/span>achievement4<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">\"n\"<\/span> <span style=\"color: #333333;\">+<\/span><br \/>                        String<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">valueOf<\/span><span style=\"color: #333333;\">(<\/span>achievement5<span style=\"color: #333333;\">)<\/span><br \/>                <span style=\"color: #333333;\">,<\/span><span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">);<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/><br \/><span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Now that we have a manager to store and load our achievements, lets improve the AchievementScreen.Java class now so that we can display the achievements. To showcase the achievements, we will be using a very simple 5 static achievement boxes that we can overlay onto the screen. The textures are as follows:<br \/>achievementlayer1.png<\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/2.bp.blogspot.com\/-9UQwVKDZcOs\/Vdd4cnbATgI\/AAAAAAAAAeU\/BxN_TS_3tNM\/s1600\/achievementlayer1.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/2.bp.blogspot.com\/-9UQwVKDZcOs\/Vdd4cnbATgI\/AAAAAAAAAeU\/BxN_TS_3tNM\/s1600\/achievementlayer1.png\" \/><\/a><\/div>\n<p>achievementlayer2.png:<\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/2.bp.blogspot.com\/-DGIfGqL-StY\/Vdd4kBDkuaI\/AAAAAAAAAec\/jvjpdelRAcw\/s1600\/achievementlayer2.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/2.bp.blogspot.com\/-DGIfGqL-StY\/Vdd4kBDkuaI\/AAAAAAAAAec\/jvjpdelRAcw\/s1600\/achievementlayer2.png\" \/><\/a><\/div>\n<p>redX.png:<\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/2.bp.blogspot.com\/-eQnBwNR6UEk\/Vdd4qon6RRI\/AAAAAAAAAek\/BJNFIZ_5PNI\/s1600\/redX.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/2.bp.blogspot.com\/-eQnBwNR6UEk\/Vdd4qon6RRI\/AAAAAAAAAek\/BJNFIZ_5PNI\/s1600\/redX.png\" \/><\/a><\/div>\n<p>So how this is going to work, is that we will draw layer 1, then redX&#8217;s over the achievements that have not been unlocked, then draw layer 2. So to start, here are the&nbsp; new variables that we need to define in AchievementScreen:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">    <span style=\"color: #888888;\">\/\/creates a achievement manager object<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> AchievementManager achievementManager <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> AchievementManager<span style=\"color: #333333;\">();<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/creates textures for achievement displays<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> Texture achievementLayer1 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Texture<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"achievementlayer1.png\"<\/span><span style=\"color: #333333;\">);<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> Texture achievementLayer2 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Texture<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"achievementlayer2.png\"<\/span><span style=\"color: #333333;\">);<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> Texture redX <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Texture<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"redX.png\"<\/span><span style=\"color: #333333;\">);<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Then we will need to draw them, the render method and function call needed for this are both shown below:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<br \/>38<br \/>39<br \/>40<br \/>41<br \/>42<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">render<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span> deltaTime<span style=\"color: #333333;\">){<\/span><br \/>        <span style=\"color: #888888;\">\/\/Sets the color to be applied after clearing the screen (R,G,B,A)<\/span><br \/>        Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gl<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">glClearColor<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">255<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Clears the screen<\/span><br \/>        Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gl<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">glClear<\/span><span style=\"color: #333333;\">(<\/span>GL20<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">GL_COLOR_BUFFER_BIT<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/updates camera view<\/span><br \/>        camera<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">update<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/makes the camera fit onto the available screen<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setProjectionMatrix<\/span><span style=\"color: #333333;\">(<\/span>camera<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">combined<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Starts gameBatch for drawing<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">begin<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/All drawing needs to be done here<\/span><br \/>        <span style=\"color: #888888;\">\/\/Draws the Cave Background starting at x = 0, y = 0<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>caveBackground<span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/draws our back arrow<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>backArrow<span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">800<\/span><span style=\"color: #333333;\">-<\/span>backArrow<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getHeight<\/span><span style=\"color: #333333;\">());<\/span><br \/>        <span style=\"color: #888888;\">\/\/draws the achievements<\/span><br \/>        drawAchievements<span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/Ends the gameBatch after drawing<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">end<\/span><span style=\"color: #333333;\">();<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">drawAchievements<\/span><span style=\"color: #333333;\">(){<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>achievementLayer1<span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(!<\/span>achievementManager<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">achievement1<\/span><span style=\"color: #333333;\">){<\/span><br \/>            game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>redX<span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">52<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">459<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(!<\/span>achievementManager<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">achievement2<\/span><span style=\"color: #333333;\">){<\/span><br \/>            game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>redX<span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">185<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">459<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(!<\/span>achievementManager<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">achievement3<\/span><span style=\"color: #333333;\">){<\/span><br \/>            game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>redX<span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">322<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">459<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(!<\/span>achievementManager<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">achievement4<\/span><span style=\"color: #333333;\">){<\/span><br \/>            game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>redX<span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">116<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">333<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(!<\/span>achievementManager<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">achievement5<\/span><span style=\"color: #333333;\">){<\/span><br \/>            game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>redX<span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">253<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">333<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>achievementLayer2<span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">);<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>We then also have to have a way to update the achievements during game play. Thus, in GameScreen we will need to define a new AchievementManager as so:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">1<br \/>2<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">    <span style=\"color: #888888;\">\/\/creates an achievement manager<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> AchievementManager achievementManager <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> AchievementManager<span style=\"color: #333333;\">();<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>and finally need to do some re-coding of the touchDown() method in game screen:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<br \/>38<br \/>39<br \/>40<br \/>41<br \/>42<br \/>43<br \/>44<br \/>45<br \/>46<br \/>47<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">    <span style=\"color: #888888;\">\/\/called when screen is touched<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">touchDown<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> screenX<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> screenY<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> pointer<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> button<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/only work when game is Over<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>gameOver<span style=\"color: #333333;\">){<\/span><br \/>            <span style=\"color: #888888;\">\/\/this changes the screenX and screenY from the pixel number on the phone, to the pixel<\/span><br \/>            <span style=\"color: #888888;\">\/\/number associated with our game.<\/span><br \/>            <span style=\"color: #333399; font-weight: bold;\">float<\/span> xPos <span style=\"color: #333333;\">=<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)<\/span>screenX<span style=\"color: #333333;\">\/<\/span>Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">graphics<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getWidth<\/span><span style=\"color: #333333;\">()*<\/span><span style=\"color: #0000dd; font-weight: bold;\">480<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #333399; font-weight: bold;\">float<\/span> yPos <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">800<\/span><span style=\"color: #333333;\">-(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)<\/span>screenY<span style=\"color: #333333;\">\/<\/span>Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">graphics<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getHeight<\/span><span style=\"color: #333333;\">()*<\/span><span style=\"color: #0000dd; font-weight: bold;\">800<\/span><span style=\"color: #333333;\">;<\/span><br \/><br \/>            <span style=\"color: #888888;\">\/\/if click was in our replay button<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>replayButton<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">contains<\/span><span style=\"color: #333333;\">(<\/span>xPos<span style=\"color: #333333;\">,<\/span>yPos<span style=\"color: #333333;\">)){<\/span><br \/>                <span style=\"color: #888888;\">\/\/resets char x position<\/span><br \/>                character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span> <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">240<\/span><span style=\"color: #333333;\">;<\/span><br \/>                <span style=\"color: #888888;\">\/\/clears icicles by creating new array<\/span><br \/>                icicleArray <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Array<span style=\"color: #333333;\">&lt;<\/span>Icicle<span style=\"color: #333333;\">&gt;();<\/span><br \/>                <span style=\"color: #888888;\">\/\/resets vars<\/span><br \/>                gameOver <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>                <span style=\"color: #888888;\">\/\/if score was higher than the high score<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>score <span style=\"color: #333333;\">&gt;<\/span> highScore<span style=\"color: #333333;\">){<\/span><br \/>                    <span style=\"color: #888888;\">\/\/write value of score to our file<\/span><br \/>                    file<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">writeString<\/span><span style=\"color: #333333;\">(<\/span>String<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">valueOf<\/span><span style=\"color: #333333;\">(<\/span>score<span style=\"color: #333333;\">),<\/span><span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">);<\/span><br \/>                    <span style=\"color: #888888;\">\/\/set our in-game high score to our new score<\/span><br \/>                    highScore <span style=\"color: #333333;\">=<\/span> score<span style=\"color: #333333;\">;<\/span><br \/>                <span style=\"color: #333333;\">}<\/span><br \/>                <span style=\"color: #888888;\">\/\/updates achievements<\/span><br \/>                achievementManager<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">update<\/span><span style=\"color: #333333;\">(<\/span>score<span style=\"color: #333333;\">);<\/span><br \/>                <span style=\"color: #888888;\">\/\/resets score<\/span><br \/>                score <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><br \/>            <span style=\"color: #888888;\">\/\/if click was in our main menu button<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>mainMenuButton<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">contains<\/span><span style=\"color: #333333;\">(<\/span>xPos<span style=\"color: #333333;\">,<\/span>yPos<span style=\"color: #333333;\">)){<\/span><br \/>                <span style=\"color: #888888;\">\/\/updates achievements<\/span><br \/>                achievementManager<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">update<\/span><span style=\"color: #333333;\">(<\/span>score<span style=\"color: #333333;\">);<\/span><br \/>                <span style=\"color: #888888;\">\/\/Tells MyGdxGame.java to set the screen now to our MainMenuScreen<\/span><br \/>                game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setScreen<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">new<\/span> MainMenuScreen<span style=\"color: #333333;\">(<\/span>game<span style=\"color: #333333;\">));<\/span><br \/>                <span style=\"color: #888888;\">\/\/if score was higher than the high score<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>score <span style=\"color: #333333;\">&gt;<\/span> highScore<span style=\"color: #333333;\">){<\/span><br \/>                    <span style=\"color: #888888;\">\/\/write value of score to our file<\/span><br \/>                    file<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">writeString<\/span><span style=\"color: #333333;\">(<\/span>String<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">valueOf<\/span><span style=\"color: #333333;\">(<\/span>score<span style=\"color: #333333;\">),<\/span><span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">);<\/span><br \/>                    <span style=\"color: #888888;\">\/\/set our in-game high score to our new score<\/span><br \/>                    highScore <span style=\"color: #333333;\">=<\/span> score<span style=\"color: #333333;\">;<\/span><br \/>                <span style=\"color: #333333;\">}<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>and hopefully you are now about to achieve some of those really really really hard achievements!<\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/3.bp.blogspot.com\/-d-VRnJCpKWg\/Vdd6V8aupAI\/AAAAAAAAAes\/wkCmCpc8Amk\/s1600\/Capture15544888.PNG\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/3.bp.blogspot.com\/-d-VRnJCpKWg\/Vdd6V8aupAI\/AAAAAAAAAes\/wkCmCpc8Amk\/s1600\/Capture15544888.PNG\" \/><\/a><\/div>\n<p><b>Step 3:<\/b><br \/>Adding your first animation!<br \/>We will be adding an animation that is already completed with an .atlas file. To create an animation sprite sheet along with a texture mapping file, please view my blog post on this (in the making&#8230;), or other tutorials online. Here is the sprite sheet for our walking actions:<\/p>\n<p>&#8230;&#8230;To be continued later&#8230;. <\/p>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello again! We are going to take our icicle mayhem game we just made (our whatever version you happened to have created!) and add some more advanced stuff to it, such as a main menu, achievements, and animations. We are going to build right off of the last post, so please visit that if you&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-89","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=\/wp\/v2\/posts\/89","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=89"}],"version-history":[{"count":0,"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=\/wp\/v2\/posts\/89\/revisions"}],"wp:attachment":[{"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=89"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=89"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=89"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}