在公司上班所做的一些笔记
来源:互联网 发布:怀孕食谱软件 编辑:程序博客网 时间:2024/05/16 09:22
1.关于屏幕幕适配
公司的项目基本上所有的屏幕大小都能完全适配好,首先的看了下它的AppDelegate.cpp文件,他是用的:
pEGLView->setDesignResolutionSize( 1280, 720,kResolutionNoBorder );
如果有的地方没适配好,就手动设置,它们的适配方法是:
// 自适应#define DESIGN_VIEWCCEGLView::sharedOpenGLView()->getDesignResolutionSize()#define VISIBLE_VIEWCCDirector::sharedDirector()->getVisibleSize()#define VISIBLE_ORIGINCCDirector::sharedDirector()->getVisibleOrigin()// 自适应位置,只有父窗口需要setvoid SetToVisiblePos( CCNode *node );float getWidthScale();float getHigthScale();void swCcbControl::SetToVisiblePos( CCNode *node ) {if (!node){ return ;} CCAssert( node != NULL, "" ); node->setPosition( node->getPosition().x * ( VISIBLE_VIEW.width / DESIGN_VIEW.width ) + VISIBLE_ORIGIN.x,node->getPosition().y *
( VISIBLE_VIEW.height / DESIGN_VIEW.height ) + VISIBLE_ORIGIN.y );node->setScale(VISIBLE_VIEW.width / DESIGN_VIEW.width );}float swCcbControl::getHigthScale(){ return VISIBLE_VIEW.height / DESIGN_VIEW.height;}float swCcbControl::getWidthScale(){float yy = VISIBLE_ORIGIN.y;float xx = VISIBLE_ORIGIN.x;float vw = VISIBLE_VIEW.width;float dw = DESIGN_VIEW.width;float vh = VISIBLE_VIEW.height;float dh = DESIGN_VIEW.height;CCSize winsize = CCDirector::sharedDirector()->getWinSize();float winx = winsize.width;float winy = winsize.height; return VISIBLE_VIEW.width / DESIGN_VIEW.width;}用法:mClose->setScaleY(swCcbControl::getWidthScale());
这样基本上就能适配所有屏幕了。
当屏幕休眠时或进入后台时,在AppDelegate.cpp中添加方法:这样就可以前后台切换了。
void AppDelegate::applicationDidEnterBackground()
{
cocos2d::CCDirector::sharedDirector()->stopAnimation();
// if you use SimpleAudioEngine, it must be pause CocosDenshion::SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();}// this function will be called when the app is active againvoid AppDelegate::applicationWillEnterForeground()
<span style="font-family: Arial, Helvetica, sans-serif;">{</span>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="white-space:pre"></span>cocos2d::CCDirector::sharedDirector()->startAnimation();</span>
// if you use SimpleAudioEngine, it must resume here CocosDenshion::SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();}
2.用到的一些宏:
// 判断vector取值是否越界#define VEC_VALUE( objPtr, vecName, pos )((objPtr->vecName.size() > pos ) ? objPtr->vecName[pos] : 0 )// 获得数组长度#define SW_ARRAY_LEN(arr) ( sizeof(arr) / sizeof(arr[0]) )
0 0
- 在公司上班所做的一些笔记
- 在台资公司上班
- 最后一天在公司上班
- 在公司第一天上班
- 在新公司上班感想
- 【菜鸟笔记】到公司上班第七天的总结
- 项目组的同志在公司上班(20060124)
- 11月在新公司上班,是音频方向的
- 对自己之前做过项目所做的一些笔记
- 放假回来 上班的第一天你在做什么?
- 要去新的公司上班了。
- 公司上班的第一天
- 20090914开始在新公司上班
- 在非技术公司做技术职员的一些切身感受
- 在stm8单片机上做路由协议的一些笔记
- 在互联网公司和行业软件公司上班,有什么区别?
- 在公司做项目的一点体会
- 在公司做的第一次技术分享
- malloc()与 alloc()区别
- 字符编码就是那点事 (ANSI、GBK、GB2312、UTF-8、GB18030和 UNICODE)
- which命令
- cocos2d-x 3.0 跨平台游戏开发(官方售价550元)
- Delphi调用MSSQL存储过程返回的多个数据集的方法
- 在公司上班所做的一些笔记
- 射频卡(mifare)防冲突机制详解
- HDFS HA
- 判断一个单链表是否有环及环的链接点
- POJ2503-Babelfish
- 暑期个人赛--第二场--A
- Access restriction: The type * is not accessible due to restrict,报错问题
- 第29条:优先考虑类型安全的异构容器
- KMP算法详解