Do you remember that in your assets
folder, there's a yellow circle called particle.png
? You will use it to create a nice particle effect to simulate the spaceship engine.
Discussing particle systems is beyond the scope of this book, so for more detailed information as well as complete particle generation software compatible with Cocos2d-JS, take a look at https://71squared.com/particledesigner.
Here, you are just going to add the simplest particle effect ever, but you will see it has a visual appeal like the following figure:
First, create a new global variable:
var background;
var gameLayer;var scrollSpeed = 1;
var ship;
var gameGravity = -0.05;
var gameThrust = 0.1;
var emitter;
The emitter will be created and configured in game's init
function:
init:function () { this._super(); this.setMouseEnabled(true); background = new ScrollingBG(); this.addChild(background); this.scheduleUpdate(); this.schedule(this.addAsteroid,0.5) ship = new Ship(); this.addChild(ship...