{"id":95,"date":"2015-07-23T17:50:00","date_gmt":"2015-07-23T17:50:00","guid":{"rendered":"https:\/\/therenaissanceraven.com\/?p=95"},"modified":"2015-07-23T17:50:00","modified_gmt":"2015-07-23T17:50:00","slug":"libgdx-camera-work-and-writing-text","status":"publish","type":"post","link":"https:\/\/therenaissanceraven.com\/?p=95","title":{"rendered":"*libGDX* Camera work and Writing Text"},"content":{"rendered":"<p>In this post we are going to be focusing on creating a camera to view our screen and a very simple act of writing text to appear on screen when touched. First if you are following from the previous post there is something that you will need to change in the main game class:<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<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">    <span style=\"color: #888888;\">\/\/Public void create() is ran when the program is started.<\/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;\">create<\/span> <span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/Creates the SpriteBatch for gameBatch to use<\/span><br \/>  gameBatch <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> SpriteBatch<span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/Creates the font, which is the default font for LIBgdx.<\/span><br \/>  gameFont <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> BitmapFont<span style=\"color: #333333;\">();<\/span><br \/>        <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 \/> <span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>This change is needed so that we may &#8220;pass&#8221; the SpriteBatch and Font that we made into our game screen so that we can use them. Next in the MainGameScreen Class creating a placeholder to &#8220;hold&#8221; the game was passed so that we can access it, and creating a camera to view the screen with.<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<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">    <span style=\"color: #888888;\">\/\/creates a placeholder for the game we are passing (Switch AdlermacGame to name of your Game Class!)<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> AdlermacGame 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;\">\/\/called upon bein set as a screen (Switch AdlermacGame to name of your Game Class!)<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #0066bb; font-weight: bold;\">MainMenuScreen<\/span><span style=\"color: #333333;\">(<\/span>AdlermacGame game<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;\">800<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">480<\/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>Next we will be editing the Render method in the MainScreenClass for two reasons, creating a colored background and adding some text. The code is shown and explained 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<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #888888;\">\/\/this is called every time the game is rendered<\/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 \/><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;\">\/\/initiates the SpriteBatch from the main Game class<\/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;\">\/\/draws the following text with the default font(our batch, text, x, y)<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameFont<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"background-color: #fff0f0;\">\"Hey! I'm Text\"<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">200<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">200<\/span><span style=\"color: #333333;\">);<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/Code snippet that displays when touched<\/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><br \/>            game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameFont<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"background-color: #fff0f0;\">\"and I'm Touched!\"<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">500<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">200<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/ends the SpriteBatch<\/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 \/><br \/>        <span style=\"color: #888888;\">\/\/displays the deltaTime<\/span><br \/>        System<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">out<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">println<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"deltaTime: \"<\/span> <span style=\"color: #333333;\">+<\/span> deltaTime<span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/shows what the Frames Per Second is<\/span><br \/>        System<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">out<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">println<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"FPS: \"<\/span> <span style=\"color: #333333;\">+<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span>f<span style=\"color: #333333;\">\/<\/span>deltaTime<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>This code should display &#8220;and im touched!&#8221; only when the screen is touched (clicked), upon running you should acheive the following results:<\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/1.bp.blogspot.com\/--Yq20vAn4-A\/VbF4hgQ4wfI\/AAAAAAAAAXQ\/kC6zm_iwT5Q\/s1600\/Pic%2B2-6.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img loading=\"lazy\" decoding=\"async\" border=\"0\" height=\"241\" src=\"http:\/\/1.bp.blogspot.com\/--Yq20vAn4-A\/VbF4hgQ4wfI\/AAAAAAAAAXQ\/kC6zm_iwT5Q\/s320\/Pic%2B2-6.png\" width=\"320\" \/><\/a><\/div>\n<p><\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/2.bp.blogspot.com\/-CAa9fw2GweU\/VbF4hi5jhKI\/AAAAAAAAAXU\/Kzs_Qkd2tgs\/s1600\/Pic%2B2-7.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img loading=\"lazy\" decoding=\"async\" border=\"0\" height=\"241\" src=\"http:\/\/2.bp.blogspot.com\/-CAa9fw2GweU\/VbF4hi5jhKI\/AAAAAAAAAXU\/Kzs_Qkd2tgs\/s320\/Pic%2B2-7.png\" width=\"320\" \/><\/a><\/div>\n<p>  Thus we have now created a way to show text when you desire and also change the background color. This is the end of this tutorial, and for the double checkers or people wanting the hole file, here it is. The final look of the 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<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<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #008800; font-weight: bold;\">package<\/span> com<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">mygdx<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">adlermac<\/span><span style=\"color: #333333;\">;<\/span><br \/><br \/><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">com.badlogic.gdx.Gdx<\/span><span style=\"color: #333333;\">;<\/span><br \/><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">com.badlogic.gdx.Screen<\/span><span style=\"color: #333333;\">;<\/span><br \/><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">com.badlogic.gdx.graphics.GL20<\/span><span style=\"color: #333333;\">;<\/span><br \/><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">com.badlogic.gdx.graphics.OrthographicCamera<\/span><span style=\"color: #333333;\">;<\/span><br \/><br \/><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><br \/><br \/>    <span style=\"color: #888888;\">\/\/creates a placeholder for the game we are passing (Switch AdlermacGame to name of your Game Class!)<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> AdlermacGame 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;\">\/\/called upon bein set as a screen (Switch AdlermacGame to name of your Game Class!)<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #0066bb; font-weight: bold;\">MainMenuScreen<\/span><span style=\"color: #333333;\">(<\/span>AdlermacGame game<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;\">800<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">480<\/span><span style=\"color: #333333;\">);<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/this is called every time the game is rendered<\/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 \/><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;\">\/\/initiates the SpriteBatch from the main Game class<\/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;\">\/\/draws the following text with the default font(our batch, text, x, y)<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameFont<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"background-color: #fff0f0;\">\"Hey! I'm Text\"<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">200<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">200<\/span><span style=\"color: #333333;\">);<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/Code snippet that displays when touched<\/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><br \/>            game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameFont<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"background-color: #fff0f0;\">\"and I'm Touched!\"<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">500<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">200<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/ends the SpriteBatch<\/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 \/><br \/>        <span style=\"color: #888888;\">\/\/displays the deltaTime<\/span><br \/>        System<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">out<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">println<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"deltaTime: \"<\/span> <span style=\"color: #333333;\">+<\/span> deltaTime<span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/shows what the Frames Per Second is<\/span><br \/>        System<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">out<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">println<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"FPS: \"<\/span> <span style=\"color: #333333;\">+<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span>f<span style=\"color: #333333;\">\/<\/span>deltaTime<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><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post we are going to be focusing on creating a camera to view our screen and a very simple act of writing text to appear on screen when touched. First if you are following from the previous post there is something that you will need to change in the main game class: 123456789&#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-95","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=\/wp\/v2\/posts\/95","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=95"}],"version-history":[{"count":0,"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=\/wp\/v2\/posts\/95\/revisions"}],"wp:attachment":[{"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=95"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=95"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=95"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}