Table of Contents
About this Book iAbout the Author iii
Table of Contents iv
Table of figures vi
About the Technology p. 1
Goals of this Book p. 2
Setting up the Code Environment p. 3
The Editor p. 3
XAMPP p. 4
The Browser p. 6
Files and Frameworks p. 6
1 Setting up an EaselJS App p. 7
1.1 The Folder Structure p. 7
1.2 Debugging the Game p. 12
2 Creating a Hero that moves p. 14
3 Mouse- and Touch-Interaction p. 20
4 Converting app.js into a Class p. 22
5 (Pre)Loading multiple Images p. 24
5.1 Assetfactory p. 24
6 Collision Detection (Theory) p. 28
6.1 Distance Based- or Radii-Collision p. 28
6.2 Bounding-Box Collision p. 29
6.3 Pixel Perfect Collision Detection p. 31
6.4 The Code p. 32
6.5 Summary and Comparison p. 33
7 Implementing a collision detection p. 34
7.1 The Code p. 34
7.2 Possible Issues p. 35
8 Adding more Movement p. 38
8.1 Horizontal hero-movement p. 38
8.2 Have the ‘camera follow’ the Hero p. 39
9 Adding multiple, self-arranging Platforms p. 43
9.1 Ability 1: Position itself at the end p. 43
9.2 Ability 2: Detect being out of bounds p. 45
9.3 Place the right Number of Platforms p. 46
10 Adjusting the Size of the Stage and Scaling p. 47
10.1 Adjusting the Stage-Size p. 47
10.2 Adjusting the scale p. 47
11 Rounding up the Gameplay p. 51
11.1 Restricting the number of jumps p. 51
11.2 Resetting the game whenever the hero falls down p. 52
12 Parallax Background p. 54
12.1 The background gradient p. 54
12.2 The Background Grid p. 55
12.3 More parallax Objects (white lines) p. 59
13 Animations and Eye-Candy p. 63
13.1 Generating the SpriteSheet data p. 63
13.2 Creating a BitmapAnimation (Waterfall) p. 64
13.3 Extending platform.js p. 65
14 Audio p. 67
14.1 General Information on Audio p. 67
14.2 Adding Audio through SoundJS p. 68
15 Creating a Menu p. 72
15.1 Adding a Pixel-Font p. 72
15.2 Creating the Menu p. 74
15.3 Implementing Game-States p. 75
16 Implementing a highscore p. 80
16.1 Adding additional labels p. 80
16.2 Updating the current distance/score each tick p. 80
16.3 Saving the highscore to localStorage p. 82
PART II
1 Requirements and Preparations p. 86
1.1 Requirements p. 86
1.2 Android Preparations p. 86
1.3 iOS Preparations p. 88
2 Technologies p. 92
2.1 Available Technologies p. 92
2.2 Comparison p. 93
3 Phonegap Build Service p. 94
3.1 The basic workflow of PhoneGap Build p. 94
3.2 Getting started with PhoneGap Build p. 94
4 CocoonJS p. 100
4.1 The basic workflow of CocoonJS p. 100
4.2 Getting Started with CocoonJS p. 100
4.3 The CocoonJS Build Service p. 104
4.4 Signing the Android APK p. 105
4.5 Using the XCode Project p. 105
5 Install an Application on your device p. 109
5.1 Android p. 109
5.2 iOS p. 109
6 Submitting the App to the Store p. 112
6.1 Google Play Store p. 112
6.2 iTunes App Store p. 112
Links and Resources p. 116
Index p. 118