HTML and CSS Reference
Building a Canvas Editor
What's in This Chapter?
• Serving a game with Node.js
• Creating a touch-friendly editor
• Saving level data
Wrox.com Code Downloads for this Chapter
title.cgi?isbn=9781118301326 on the Download Code tab. The code is in the Chapter 19 download and individu-
ally named according to the names throughout the chapter.
Building off the last chapter, where you built a 2-D platformer, this chapter builds an editor that enables you to
edit the level to modify the tile data that makes up the level and save those changed levels. To allow the level
data to be saved, you need to wrap the game inside of a Node.js application that can handle writing out the saved
Serving the Game with Node.js
Before your app can handle requests to save level data, the game needs to be served from something besides a
static web server. One solution for this would be to write a simple PHP script that takes in the data and saves the
game in the next couple of chapters, it makes more sense to build the editor using Node to get more experience
Creating the package.json File
itor needs a package.json file to let Node know some details about the application, including dependencies.
Create a new directory called editor for the editor, and create a file called package.js with the contents in