创建第一个cocos2d 应用

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(){

    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值