Again, dealing with an asset, we want to preload that in our
preload() function, like so:
That’s all there is to it! Now let’s add the sprite to our canvas within our
What this does is wherever the camera is set on the painted map, we want to paint the sprite to the exact middle of said camera center. View the demo below and use the keyboard arrows to move around. As you can see, the sprite stays in place…
Also note, our global variables are now as follows:
Our next tutorial will switch focus from moving the camera only, to following our sprite as it moves along the map!
If you would like the source files for this tutorial: Download source files