Carry out the following steps to draw two graphics on our physics objects:
We will first download the graphics we need for this example. To download the graphics, go to http://mak.la/book-assets.
Put the image files for this chapter in the
images
folder.Now, it is time to edit the
index.html
file. Add the following HTML markup to thebody
section:<div id="asset"> <img id="flag" src='images/flag.png'> <img id="bus" src="images/bus.png"> <img id="wheel" src="images/wheel.png"> </div>
We want to hide the asset DIV that contains our
img
tags. Open thecargame.css
file and add the following CSS rule to keep the asset DIV out of our sight:#asset { position: absolute; top: -9999px; }
We will now move on to the logic part. Open the
box2dcargame.js
JavaScript file.In the
restartGame
function, add the highlighted code to assign the reference of theflag
image to the winning destination flag:if...