Creating a fairy tale
Since we are dealing with a dragon here, it seems only fair that the environment should also be out of a fairy tale. Hence, we will build our environment with a castle, a midnight sky full of twinkling stars, and a few dark silhouettes. Since we will need this exact same environment in our other major scene, that is, the game world, it's a good idea to separate it out into another class. Thus, we have the FairytaleManager
class defined in the fairytaleManager.js
file:
var MAX_SCROLLING_SPEED = 6; var CASTLE_SPRITE_Y = -50; var SILHOUETTE_SPRITE_Y = 100; var MAX_STARS = 15; function FairytaleManager(parent) { // save reference to GameWorld this.parent = parent; this.screenSize = parent.screenSize; // initialise variables this.castleSpriteSize = cc.SIZE_ZERO; this.castleSprites = []; this.lastCastleIndex = 0; this.silhouetteSpriteSize = cc.SIZE_ZERO; this.silhouetteSprites = []; this.lastSilhouetteIndex = 0; }
First, we declare a few global quantities...