{"id":92,"date":"2015-07-24T17:51:00","date_gmt":"2015-07-24T17:51:00","guid":{"rendered":"https:\/\/therenaissanceraven.com\/?p=92"},"modified":"2015-07-24T17:51:00","modified_gmt":"2015-07-24T17:51:00","slug":"libgdx-creating-objects-and-movement","status":"publish","type":"post","link":"https:\/\/therenaissanceraven.com\/?p=92","title":{"rendered":"*libGDX* Creating Objects and Movement"},"content":{"rendered":"<p>Here we will be showing how to create a simple object and to make it move. To do this we will first need to make a simple object that we would wish to create. Below is a picture I drew in 3.5 seconds, its a 20&#215;20 pixel png image named &#8220;object.png&#8221;. Note: All asset names need to be lower-cased.<\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/4.bp.blogspot.com\/-LLb0wUjxg_A\/VbJLN1_0hsI\/AAAAAAAAAXw\/1J9MUtxWd64\/s1600\/object.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"http:\/\/4.bp.blogspot.com\/-LLb0wUjxg_A\/VbJLN1_0hsI\/AAAAAAAAAXw\/1J9MUtxWd64\/s1600\/object.png\" \/><\/a><\/div>\n<p>First we should add a little structure to this object, such as its location and speed, however we do wish to create multiple, so writing a whole new one every time would be a pain. Thus we will create an class to form a sort-of blueprint for all of the objects. The class you will need is the following:<\/p>\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<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<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> <span style=\"color: #888888;\">\/\/This is our \"class\" which defines our object \"MyObject\" that we will be creating<\/span><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;\">MyObject<\/span><span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/Creates the Texture or image of our object<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">private<\/span> Texture myTexture <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;\">\"object.png\"<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Gets X location of the courser upon spawning, corrects x loc to be in middle of cursor<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">private<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> xLoc <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> <span style=\"color: #0000dd; font-weight: bold;\">10<\/span><span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #888888;\">\/\/Gets Y location of the courser upon spawning, corrects y loc to be in middle of cursor<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">private<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> yLoc <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;\">getY<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">+<\/span> <span style=\"color: #0000dd; font-weight: bold;\">10<\/span><span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #888888;\">\/\/Defines variables to store the Velocity<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">private<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> xSpeed<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">private<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> ySpeed<span style=\"color: #333333;\">;<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/This relieves the random velocity given to the object upon creation<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #0066bb; font-weight: bold;\">MyObject<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> xspeed<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> yspeed<span style=\"color: #333333;\">){<\/span><br \/>            <span style=\"color: #888888;\">\/\/Sets the velocity sent to it, to the variables defined above<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">xSpeed<\/span> <span style=\"color: #333333;\">=<\/span> xspeed<span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">ySpeed<\/span> <span style=\"color: #333333;\">=<\/span> yspeed<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #888888;\">\/\/This updates the location of our object by adding the speed of each direction to the current location<\/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><br \/>            <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">xLoc<\/span> <span style=\"color: #333333;\">+=<\/span> xSpeed<span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">yLoc<\/span> <span style=\"color: #333333;\">+=<\/span> ySpeed<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>Note: You must add either my object our your own object into the assets folder in the android project. The same location as the default &#8220;badlogic.jpg&#8221;. If you are having issues loading the file into the assets folder, try right clicking the assets folder to open in explorer, you can then drag and drop the file into the assets.<\/p>\n<p>Now that we have the backbones for creating our object, lets get to the actual process of creating\/spawning them upon clicking the screen. To do this, we will need to take two steps: 1) keeping track of all of our objects and 2) spawning them upon being clicked. For the first step we will create an Array that is designed for our object, this will store all of objects so we can access them easily:<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 and array to hold all of our objects<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> Array myObjectArray <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Array<span style=\"color: #333333;\">&lt;<\/span>MyObject<span style=\"color: #333333;\">&gt;();<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Then you are going to put the following code within the Render(float deltaTime) portion:<\/p>\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<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;\">\/\/Code snippet that runs when being 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 \/>            <span style=\"color: #888888;\">\/\/Creates a new Object (which is our moving thingies) with a random x and random y speed<\/span><br \/>            MyObject myObject <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> MyObject<span style=\"color: #333333;\">(<\/span>MathUtils<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">random<\/span><span style=\"color: #333333;\">(-<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">),<\/span>MathUtils<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">random<\/span><span style=\"color: #333333;\">(-<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">));<\/span><br \/>            <span style=\"color: #888888;\">\/\/Adds our new created object to our object array<\/span><br \/>            myObjectArray<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">add<\/span><span style=\"color: #333333;\">(<\/span>myObject<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 creating an object, with a random velocity, and adding into our array that holds all of the objects. Now we will wish to sort through all of the objects and update them allowing with drawing them onto the screen. This portion will also go into the Render(float deltaTime) portion:<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<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #888888;\">\/\/Creates an iterator what will sort through objects of the from of \"MyOjbect\"<\/span><br \/>        Iterator<span style=\"color: #333333;\">&lt;<\/span>MyObject<span style=\"color: #333333;\">&gt;<\/span> rectIter <span style=\"color: #333333;\">=<\/span> myObjectArray<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">iterator<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/This runs through each object in the iterator<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">while<\/span><span style=\"color: #333333;\">(<\/span>rectIter<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">hasNext<\/span><span style=\"color: #333333;\">()){<\/span><br \/>            <span style=\"color: #888888;\">\/\/sets the current object to a new myObject<\/span><br \/>            MyObject myObject <span style=\"color: #333333;\">=<\/span> rectIter<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">next<\/span><span style=\"color: #333333;\">();<\/span><br \/>            <span style=\"color: #888888;\">\/\/updates the current object that it is controlling<\/span><br \/>            myObject<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">Update<\/span><span style=\"color: #333333;\">();<\/span><br \/>            <span style=\"color: #888888;\">\/\/Draws the current object onto the screen<\/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>myObject<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">myTexture<\/span><span style=\"color: #333333;\">,<\/span> myObject<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">xLoc<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">480<\/span><span style=\"color: #333333;\">-<\/span>myObject<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">yLoc<\/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 that is it! You can also add a little X,Y, coordinate transcriber if you wish to the top left of the screen by the following code:<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;\">\/\/Displays x and y cursor position<\/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;\">\"X: \"<\/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> <span style=\"background-color: #fff0f0;\">\"  Y: \"<\/span> <span style=\"color: #333333;\">+<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">480<\/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;\">getY<\/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;\">480<\/span><span style=\"color: #333333;\">);<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>And we are done! You should have something that hopefully functions as such:<\/p>\n<p><a href=\"http:\/\/3.bp.blogspot.com\/-Jzt-ZaSQSAA\/VbJLDcY9yAI\/AAAAAAAAAXo\/dQpq0E5U34Q\/s1600\/Pic%2B3.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"http:\/\/3.bp.blogspot.com\/-Jzt-ZaSQSAA\/VbJLDcY9yAI\/AAAAAAAAAXo\/dQpq0E5U34Q\/s1600\/Pic%2B3.png\" \/><\/a><br \/>Also, the entire class is shown below if you wish: <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<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<br \/>106<br \/>107<br \/>108<br \/>109<br \/>110<br \/>111<br \/>112<br \/>113<br \/>114<br \/>115<br \/>116<br \/>117<br \/>118<br \/>119<br \/>120<br \/>121<br \/>122<br \/>123<br \/>124<br \/>125<br \/>126<br \/>127<br \/>128<br \/>129<br \/>130<br \/>131<br \/>132<br \/>133<br \/>134<br \/>135<\/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 \/><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">com.badlogic.gdx.graphics.Texture<\/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.math.MathUtils<\/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.utils.Array<\/span><span style=\"color: #333333;\">;<\/span><br \/><br \/><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">java.util.Iterator<\/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;\">\/\/Creates and array to hold all of our objects<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> Array myObjectArray <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Array<span style=\"color: #333333;\">&lt;<\/span>MyObject<span style=\"color: #333333;\">&gt;();<\/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;\">true<\/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 \/><br \/>        <span style=\"color: #888888;\">\/\/If you have do not have gameBatch stated in your Game class, you must call:<\/span><br \/>        <span style=\"color: #888888;\">\/\/SpriteBatch gameBatch = new SpriteBatch();<\/span><br \/>        <span style=\"color: #888888;\">\/\/and then replace all \"game.gameBatch\" with just \"gameBatch\"<\/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 \/><br \/>        <span style=\"color: #888888;\">\/\/Code snippet that runs when being 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 \/>            <span style=\"color: #888888;\">\/\/Creates a new Object (which is our moving thingies) with a random x and random y speed<\/span><br \/>            MyObject myObject <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> MyObject<span style=\"color: #333333;\">(<\/span>MathUtils<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">random<\/span><span style=\"color: #333333;\">(-<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">),<\/span>MathUtils<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">random<\/span><span style=\"color: #333333;\">(-<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">));<\/span><br \/>            <span style=\"color: #888888;\">\/\/Adds our new created object to our object array<\/span><br \/>            myObjectArray<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">add<\/span><span style=\"color: #333333;\">(<\/span>myObject<span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/Creates an iterator what will sort through objects of the from of \"MyOjbect\"<\/span><br \/>        Iterator<span style=\"color: #333333;\">&lt;<\/span>MyObject<span style=\"color: #333333;\">&gt;<\/span> rectIter <span style=\"color: #333333;\">=<\/span> myObjectArray<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">iterator<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/This runs through each object in the iterator<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">while<\/span><span style=\"color: #333333;\">(<\/span>rectIter<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">hasNext<\/span><span style=\"color: #333333;\">()){<\/span><br \/>            <span style=\"color: #888888;\">\/\/sets the current object to a new myObject<\/span><br \/>            MyObject myObject <span style=\"color: #333333;\">=<\/span> rectIter<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">next<\/span><span style=\"color: #333333;\">();<\/span><br \/>            <span style=\"color: #888888;\">\/\/updates the current object that it is controlling<\/span><br \/>            myObject<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">Update<\/span><span style=\"color: #333333;\">();<\/span><br \/>            <span style=\"color: #888888;\">\/\/Draws the current object onto the screen<\/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>myObject<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">myTexture<\/span><span style=\"color: #333333;\">,<\/span> myObject<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">xLoc<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">480<\/span><span style=\"color: #333333;\">-<\/span>myObject<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">yLoc<\/span><span style=\"color: #333333;\">));<\/span><br \/>        <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: #888888;\">\/\/Displays x and y cursor position<\/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;\">\"X: \"<\/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> <span style=\"background-color: #fff0f0;\">\"  Y: \"<\/span> <span style=\"color: #333333;\">+<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">480<\/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;\">getY<\/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;\">480<\/span><span style=\"color: #333333;\">);<\/span><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 \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/This is our \"class\" which defines our object \"MyObject\" that we will be creating<\/span><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;\">MyObject<\/span><span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/Creates the Texture or image of our object<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">private<\/span> Texture myTexture <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;\">\"object.png\"<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Gets X location of the courser upon spawning, corrects x loc to be in middle of cursor<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">private<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> xLoc <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> <span style=\"color: #0000dd; font-weight: bold;\">10<\/span><span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #888888;\">\/\/Gets Y location of the courser upon spawning, corrects y loc to be in middle of cursor<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">private<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> yLoc <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;\">getY<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">+<\/span> <span style=\"color: #0000dd; font-weight: bold;\">10<\/span><span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #888888;\">\/\/Defines variables to store the Velocity<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">private<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> xSpeed<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">private<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> ySpeed<span style=\"color: #333333;\">;<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/This relieves the random velocity given to the object upon creation<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #0066bb; font-weight: bold;\">MyObject<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> xspeed<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> yspeed<span style=\"color: #333333;\">){<\/span><br \/>            <span style=\"color: #888888;\">\/\/Sets the velocity sent to it, to the variables defined above<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">xSpeed<\/span> <span style=\"color: #333333;\">=<\/span> xspeed<span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">ySpeed<\/span> <span style=\"color: #333333;\">=<\/span> yspeed<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #888888;\">\/\/This updates the location of our object by adding the speed of each direction to the current location<\/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><br \/>            <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">xLoc<\/span> <span style=\"color: #333333;\">+=<\/span> xSpeed<span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">yLoc<\/span> <span style=\"color: #333333;\">+=<\/span> ySpeed<span style=\"color: #333333;\">;<\/span><br \/>        <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>Bonus: If you notice after you add a lot of the objects, the FPS of the game will slow down considerably. Which is not surpising given how many we are spawning and it is trying to keep track of. Thus, we can dynamically remove all of the objects that happen to off of the screen by altering the existing Iterator code 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<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 an iterator what will sort through objects of the from of \"MyOjbect\"<\/span><br \/>        Iterator<span style=\"color: #333333;\">&lt;<\/span>MyObject<span style=\"color: #333333;\">&gt;<\/span> rectIter <span style=\"color: #333333;\">=<\/span> myObjectArray<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">iterator<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/This runs through each object in the iterator<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">while<\/span><span style=\"color: #333333;\">(<\/span>rectIter<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">hasNext<\/span><span style=\"color: #333333;\">()){<\/span><br \/>            <span style=\"color: #888888;\">\/\/sets the current object to a new myObject<\/span><br \/>            MyObject myObject <span style=\"color: #333333;\">=<\/span> rectIter<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">next<\/span><span style=\"color: #333333;\">();<\/span><br \/>            <span style=\"color: #888888;\">\/\/updates the current object that it is controlling<\/span><br \/>            myObject<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">Update<\/span><span style=\"color: #333333;\">();<\/span><br \/>            <span style=\"color: #888888;\">\/\/Removes object if off screen<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>myObject<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">xLoc<\/span> <span style=\"color: #333333;\">&gt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">800<\/span> <span style=\"color: #333333;\">||<\/span> myObject<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">xLoc<\/span> <span style=\"color: #333333;\">&lt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span> <span style=\"color: #333333;\">||<\/span> myObject<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">yLoc<\/span> <span style=\"color: #333333;\">&lt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span> <span style=\"color: #333333;\">||<\/span> myObject<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">yLoc<\/span> <span style=\"color: #333333;\">&gt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">480<\/span><span style=\"color: #333333;\">){<\/span><br \/>                rectIter<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">remove<\/span><span style=\"color: #333333;\">();<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><br \/>            <span style=\"color: #888888;\">\/\/Draws the current object onto the screen<\/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>myObject<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">myTexture<\/span><span style=\"color: #333333;\">,<\/span> myObject<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">xLoc<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">480<\/span><span style=\"color: #333333;\">-<\/span>myObject<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">yLoc<\/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","protected":false},"excerpt":{"rendered":"<p>Here we will be showing how to create a simple object and to make it move. To do this we will first need to make a simple object that we would wish to create. Below is a picture I drew in 3.5 seconds, its a 20&#215;20 pixel png image named &#8220;object.png&#8221;. Note: All asset names&#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-92","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=\/wp\/v2\/posts\/92","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=92"}],"version-history":[{"count":0,"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=\/wp\/v2\/posts\/92\/revisions"}],"wp:attachment":[{"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=92"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=92"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=92"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}