HTML and CSS Reference
In-Depth Information
As Listing 24-8 shows, you have added the toolbar layer and the Game Map layer to Game layer. Now that the
Game layer is ready, you can connect it to the game scene, as shown in Listing 24-10.
Listing 24-10. Connecting the Game Layer to Game Scene in GameLayer.js
var GameScene = cc.Scene.extend({
onEnter:function(){
this._super();
var layer = new GameLayer(); // Create the GameLayer.
layer.init();
this.addChild(layer);
}
});
Now the game scene is ready to run, and it should look like Figure 24-16 .
Figure 24-16. Tower Defence Game Map layer and Tool Bar layer
There are three numbers at the bottom-left corner. These numbers represent the following statistics:
Draw calls
Second per frame (SPF)
Frame per second (FPS)
You should try to keep draw calls as few as possible and keep the updating time (SPF) as low as possible to get a
high CPU idle time. For example, the cocos2d engine will cache the tile map automatically to improve performance,
because the tile map is created by lots of tiles, and their position is always the same. This is why the draw calls only
reads 4 with lots of tiles displayed on the screen. SPF will be indicated as 0 when it is less than 1ms.
 
Search WWH ::




Custom Search