1.關于COCOS2d的單例和導演類
~~~
//1.COCOS2d的常用單例
CCDirector *sharedDirector = [CCDirector sharedDirector];
CCSpriteFrameCache *SpritesharedCache = [CCSpriteFrameCache sharedSpriteFrameCache];
CCTextureCache *TextureCache = [CCTextureCache sharedTextureCache];
// CDAudioManager *sharedManager = [CDAudioManager sharedManager];
// SimpleAudioEngine *sharedEngine = [SimpleAudioEngine sharedEngine];
//2.CCDirector 導演類
//作用:訪問和改變場景,訪問2d的配置細節,訪問視圖,暫停,恢復,結束游戲,在UIKit和OPenGLEs之間轉化坐標
//1.主程序啟動并顯示第一個場景
[[CCDirector sharedDirector]runWithScene:[HelloWorldLayer scene]];
//2 講傳入場景作為當前的場景
[[CCDirector sharedDirector]pushScene:[HelloWorldLayer scene]];
//3 運行待運行場景中的倒數第二個場景,當前場景被釋放
[[CCDirector sharedDirector]popScene];
//4 直接使用新的場景更換當前的場景,當前場景被釋放
[[CCDirector sharedDirector]replaceScene:[HelloWorldLayer scene]];
//5結束當前運行中的場景
[[CCDirector sharedDirector] end];
//6 暫停當前的場景
[[CCDirector sharedDirector]pause];
//7 恢復場景的運行
[[CCDirector sharedDirector]resume];
//8繪制場景
// -(void)draw;
//9講UIKit坐標系中的坐標轉換為OPENGL ES 坐標系中的坐標
UITouch *myTouch = [touches angObject];
CGPoint location = [myTouch locationInView:[myTouch view]];
location = [[CCDirector sharedDirector]convertToGL:location];
~~~