cocos2dxHellowoed 发现 2.2.3
cocos2d 笔记
文件夹介绍
cocosdx ----->cocos2d主要代码
CocosDenshion---->cocos2d的声音的
Document------>文档
extensions ---->cocos2d一些拓展
projects ----->一些project
samples------>cocos2d的一些提供的案例
scripting ----->脚本
template ------>模板
tools ------->工具
project介绍
Classes ----->是夸平台的代码
Resources ---->资源(声音,脚本)
proj. ----->是不能够跨平台的代码
主要參数
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
eglView->setViewName("名字");
eglView->setFrameSize(长, 宽);//主要是界面
------------------------------------------------------------------------------ bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
CCDirector* pDirector = CCDirector::sharedDirector();
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView(); pDirector->setOpenGLView(pEGLView);//使pEGLView和pDirector关联,通过setOpenGLView进行关联 // turn on display FPS
pDirector->setDisplayStats(true);//是左下角的显示的fps一般分布会关闭 // set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);//每针多少秒 // create a scene. it's an autorelease object
CCScene *pScene = HelloWorld::scene(); // run
pDirector->runWithScene(pScene); return true;
}
CCScene* HelloWorld::scene(){
// 'scene' is an autorelease object
CCScene *scene = CCScene::create();//创建一个scene // 'layer' is an autorelease object
HelloWorld *layer = HelloWorld::create();//创建一个城 // add layer as a child to scene
scene->addChild(layer);//把scene加入到城 // return the scene
return scene;//在返回scene
} bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )//调用父类的init
{
return false;
} CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin(); /////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it. // add a "close" icon to exit the progress. it's an autorelease object
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback));//创建那个button pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
origin.y + pCloseItem->getContentSize().height/2)); // create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition(CCPointZero);
this->addChild(pMenu, 1); /////////////////////////////
// 3. add your codes below... // add a label shows "Hello World"
// create and initialize a label CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24); // position the label on the center of the screen
pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
origin.y + visibleSize.height - pLabel->getContentSize().height)); // add the label as a child to this layer
this->addChild(pLabel, 1); // add "HelloWorld" splash screen"
CCSprite* pSprite = CCSprite::create("HelloWorld.png"); // position the sprite on the center of the screen
pSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); // add the sprite as a child to this layer
this->addChild(pSprite, 0); return true;
} CCDirector 导演
设置全局属性。推动剧情发展,单例对象
CCDirector* director = CCDirector::sharedDirector();
CCScene 是场景的意思
游戏有多个场景构成。可是某一时刻仅仅有一个场景在执行
CCScene是一个独立的工作流,场景类在cocos里,一般仅仅作为容器。装载其它游戏元素
CCLayer 层类
归类
处理触摸消息
CCColorLayer(颜色), CCMenu
CCSprite 精灵类
抽象游戏角色(主角。敌人,道具。。 。 。。)体现游戏外观(包括了纹理),通过改动属性来改变精灵的位置、颜色、。 。 。。,或者是执行动作让精灵变得生动 CCNode 渲染树的节点类,全部可渲染对象都从CCNode派生 using namespace cocos2d; == USING_NS_CC; 一般用后面的 // 实现create的静态函数,create函数会自己主动调用init函数
CREATE_FUNC(MyLayer); 第一个scene 用runWithScene
pDirector->runWithScene(pScene); 以后scene 用replaceScene
CCDirector::sharedDirector()->replaceScene(MyLayer::scene()); setTouchEnabled(true);
支持触摸 假设不写不赞成触摸
setTouchMode(kCCTouchesAllAtOnce);
多点触摸:比方双手按在手机屏幕什么
setTouchMode(kCCTouchesOneByOne)。
单点触摸:比方单手按在手机屏幕什么 bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent);//当你手指刚刚按下是时候
void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent);//当你手指移动按下是时候
void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent);//当你手指离开按下是时候
void ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent);//当你电话来的时候 CCPoint pt = pTouch->getDelta();//返回的距离
CCPoint pos = _lable->getPosition();//获取_lable的位置
_lable->setPosition(ccpAdd(pos,pt));//改变_lable的位置
cocos2dxHellowoed 发现 2.2.3的更多相关文章
- 探真无阻塞加载javascript脚本技术,我们会发现很多意想不到的秘密
下面的图片是我使用firefox和chrome浏览百度首页时候记录的http请求 下面是firefox: 下面是chrome: 在浏览百度首页前我都将浏览器的缓存全部清理掉,让这个场景最接近第一次访问 ...
- PC分配盘符的时候发现==》RPC盘符不可用
服务器汇总:http://www.cnblogs.com/dunitian/p/4822808.html#iis 服务器异常: http://www.cnblogs.com/dunitian/p/45 ...
- Consul 服务注册与服务发现
上一篇:Mac OS.Ubuntu 安装及使用 Consul 1. 服务注册 对 Consul 进行服务注册之前,需要先部署一个服务站点,我们可以使用 ASP.NET Core 创建 Web 应用程序 ...
- 学习笔记:发现一个IE版本判断的好方法
web开发就不得不面对浏览器兼容性问题,特别是IE的兼容问题.在前端代码中经常要处理一些兼容格式,为了解决这个问题网上找了找识别浏览器版本的方法. 常规js方法 找到一个方法,还不错,可以识别出各 ...
- 分布式服务注册和发现consul 简要介绍
Consul是HashiCorp公司推出的开源工具,用于实现分布式系统的服务发现与配置.与其他分布式服务注册与发现的方案,Consul的方案更"一站式",内置了服务注册与发现框 架 ...
- 解决CSharpGL使用CGCompiler时发现的几个问题
解决CSharpGL使用CGCompiler时发现的几个问题 为了获取CSharpShadingLanguage的token流,我设计了这样一个文法: <Expression> ::= & ...
- Atitit webservice发现机制 WS-Discovery标准的规范attilax总结
Atitit webservice发现机制 WS-Discovery标准的规范attilax总结 1.1. WS-Discovery标准1 1.2. 一.WS-Discovery1 1.2.1. ...
- 工作笔记--哪些bug应由研发发现?
标准: 研发应发现: 主功能流程无法正常使用,以及联调时主功能流程是否正常 功能缺失 打包时数据库表非最新.程序文件非最新: 文件导出时有明显错误(如无法导出.导出后格式明显不对.批量导入出错) ...
- 用struts2标签如何从数据库获取数据并在查询页面显示。最近做一个小项目,需要用到struts2标签从数据库查询数据,并且用迭代器iterator标签在查询页面显示,可是一开始,怎么也获取不到数据,想了许久,最后发现,是自己少定义了一个变量,也就是var变量。
最近做一个小项目,需要用到struts2标签从数据库查询数据,并且用迭代器iterator标签在查询页面显示,可是一开始,怎么也获取不到数据,想了许久,最后发现,是自己少定义了一个变量,也就是var变 ...
随机推荐
- bzoj 3926 转换+广义后缀自动机
思路:重点在于叶子节点只有20个,我们把叶子节点提到根,把20个trie图插入后缀自动机,然后就是算有多少个本质不同的字串. #include<bits/stdc++.h> #define ...
- [CodeForces 893D] Credit Card 贪心
题意: Recenlty Luba有一张信用卡,一开始金额为0,每天早上可以充值任意数量的钱,但有限制,卡里的钱不能超过D.到了晚上,银行会对信用卡进行一次操作,操作有三种: 1.a[i]>0, ...
- 1015 Reversible Primes (20)(20 point(s))
problem A reversible prime in any number system is a prime whose "reverse" in that number ...
- python functools.wraps
我们在使用装饰器的时候,有些函数的功能会丢失,比如func.__name__,func.__doc__,func.__module__ 比如下面这个例子: In [16]: def logged(fu ...
- HTML 模板继承
网站模板的设计,一般的,我们做网站有一些通用的部分,比如 导航,底部,访问统计代码等.合理的规划模板往往会减少工作量,同时也使得罗乱.难以阅读的静态页面布局变得优雅. 假设,我们的网站主页面除了正文是 ...
- leetcode x 的平方根 python
x 的平方根 实现 int sqrt(int x) 函数. 计算并返回 x 的平方根,其中 x 是非负整数. 由于返回类型是整数,结果只保留整数的部分,小数部分将被舍去. 示例 1: 输入: ...
- SPOJ7586 NUMOFPAL manacher算法
题目大意: 求一个串中有多少个回文子串 这..... 妥妥的模板题吧.... 对所有的$r[i] / 2$进行求和即可,其中,$r[i]$为以$i$为中心的回文半径 $r[i] / 2$怎么来的,画下 ...
- hihocoder 1509 异或排序
题面在这里! 考虑前后两个数 x,y,可以发现S只有在(x xor y)的最高有1位上的取值是要被确定的 (如果x==y那么没有限制),可以推一下什么情况下是1/0. 于是我们模拟一下这个操作,判一判 ...
- [Agc001E] BBQ Hard
[Agc001E] BBQ Hard 题目大意 给定\(n\)对正整数\(a_i,b_i\),求\(\sum_{i=1}^{n-1} \sum_{j=i+1}^n \binom{a_i+b_i+a_j ...
- java多线程技术之八(锁机制)
Lock是java.util.concurrent.locks包下的接口,Lock 实现提供了比使用synchronized 方法和语句可获得的更广泛的锁定操作,它能以更优雅的方式处理线程同步问题,我 ...