1、创建一个Android应用程序
2、生成一个SurfaceView对象,作为Activity当中所显示的内容;
3、得到CCDirector对象,并通过该对象设置应用程序各种属性
coco2d程序的基本属性
1、director.attachinView(mGLSurfaceView):用于设置应用程序使用的GL试图
2、director.setDeviceOrientation(CCDirector.kCCDeviceOrientationLandsscapeLeft):用于设置应用程序方向;
3、director.setDisplayFPS(true):设置应用程序是否需要显示应用程序的FPS值;
4、director.seAnimationInterval(1.0f/30):设置每帧所需的时间
生成布景层层与场景对象
1、创建一个布景层类继承CCLayer;
2、调用CCScene类的node()方法生成场景对象;
3、生成布景层对象,并添加至场景对象中;
4、执行场景对象
代码:`view = new CCGLSurfaceView(this);
//得到CCDirector对象
CCDirector director=CCDirector.sharedDirector();
//设置应用程序相关的属性
director.attachInView(view);//设置当前游戏程序所使用的View
director.setDisplayFPS(true);//设置游戏是否显示FPS值
director.setAnimationInterval(1/30.0); //设置游戏的渲染一帧所需要时间FPS值
CCScene scene = CCScene.node();//生成一个游戏场景对象
//生成布景层对象
GameLayer gameLayer = new GameLayer();
scene.addChild(gameLayer);
//运行游戏场景对象
director.runWithScene(scene);
setContentView(view);`
public class GameLayer extends CCLayer{
public GameLayer(){
}
}