zhouweikuan cocos2d android-1,搭建cocos2d-android-1环境

下载cocos2d

进入github.com,搜索cocos2d android,点击链接进入下载页

或者直接https://github.com/ZhouWeikuan/cocos2d打开进入下载页。

对于不懂git的小白,只能下载zip。在页面又下角

cocos2d-android

下载后解压得到android开发需要的cocos2d-android文件夹,将它导入eclipse

运行cocos2d-android:

1.由于src目录下的源文件和cocos2d-android.jar内的字节码文件重复,所以应删除libs目录下的cocos2d-android.jar

2.原cocos2d-android项目是一个library,不能运行。项目右键,属性,android.Is Library复选框的勾去掉

运行项目,可以看到很多测试用例,对应与源程序src 目录org.cocos2d.tests下的测试类。

我的第一个游戏:

google上的cocos2d 的辅助教程:一个简单的android游戏制作过程

Mars cocos2d学习笔记:

package org.javaious.firstgame;

import org.cocos2d.layers.CCScene;

import org.cocos2d.nodes.CCDirector;

import org.cocos2d.opengl.CCGLSurfaceView;

import android.os.Bundle;

import android.app.Activity;

import android.view.Menu;

public class MainActivity extends Activity {

//Cocos2d引擎将会把图形绘制在该view对象上

private CCGLSurfaceView view = null;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

view = new CCGLSurfaceView(this);

setContentView(view);

//得到CCDirector对象

CCDirector director = CCDirector.sharedDirector();

//设置应用程序相关的属性

//设置当前游戏程序当中所使用的view对象

director.attachInView(view);

//设置游戏是否显示FPS值 (frames per second)

director.setDisplayFPS(true);

//设置游戏渲染一帧数据所需要的时间

director.setAnimationInterval(1 / 30.0);

//生成游戏场景对象

CCScene scene = CCScene.node();

//生成布景层对象

GameLayer gameLayer = new GameLayer();

//运行游戏场景

director.runWithScene(scene);

scene.addChild(gameLayer);

}

@Override

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.main, menu);

return true;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值