cocos2d-x 菜鸟学习笔记二(自适应屏幕分辨率)
来源:互联网 发布:华迪实训基地网络设计 编辑:程序博客网 时间:2024/04/30 19:43
在android中,适应各种分辨率是个很头疼的事,特别是对于游戏来说……网上教程介绍得已经很详细了,下面是个人认为写得比较全的文章链接:
1.http://codingnow.cn/cocos2d-x/975.html 或者http://blog.csdn.net/gg137608987/article/details/8302699
2.http://article.ityran.com/archives/3762
其实对于我来说,最简单的屏幕适配就是使用CCEGLView::sharedOpenGLView()->setDesignResolutionSize(width,Height, kResolutionShowNoBorder);在我看来,setDesignResolutionSize()就是根据对应图片资源尺寸,也就是你设计的界面元素图片最适合的显示分辨率,按最适当的比例显示到屏幕上。这样的话,除了让其它界面元素都使用相对坐标(应该没几个会使用绝对坐标的吧……),就没多少需要做的了。
在最近更新的版本里,已经没有了setResourceDirectory,取而代之的是setSearchPaths,以下是关于它的描述:
/** * Sets the array of search paths. * * You can use this array to modify the search path of the resources. * If you want to use "themes" or search resources in the "cache", you can do it easily by adding new entries in this array. * * @note This method could access relative path and absolute path. * If the relative path was passed to the vector, CCFileUtils will add the default resource directory before the relative path. * For instance: * On Android, the default resource root path is "assets/". * If "/mnt/sdcard/" and "resources-large" were set to the search paths vector, * "resources-large" will be converted to "assets/resources-large" since it was a relative path. * * @param searchPaths The array contains search paths. * @see fullPathForFilename(const char*) * @since v2.1 */如果想显示比较完整清晰,那么针对不同分辨率设计对应尺寸的图片将是必要的,setSearchPaths可以用来设定引用资源的路径,根据不同分辨率设定引用对应的图片资源即可保证完美清晰的显示。下面是cocosWiki上的使用示例:
// set searching paths to "/mnt/sd/example" and "/data/data/org.cocos2dx.example" vector<string> searchPaths;searchPaths.push_back("/mnt/sd/example");searchPaths.push_back("/data/data/org.cocos2dx.example");CCFileUtils::setSearchPaths(searchPaths); // engine will find "1.png" in /mnt/sd/example, if there it is not found, then engine will find "1.png" in /data/data/org.cocos2dx.example// if not found, engine will find "1.png" in Resources/ (this path is platform dependent)CCSprite *pSprite = CCSprite::create("1.png");下面还有些文件命名的注意事项:
- Do not use -hd, -ipad & -ipadhd suffix(后缀) as the "file" name field in .fnt file
- Do not use -hd, -ipad & -ipadhd suffix(后缀) as the "textureFilename" name field in .plist file
- Do not use -hd, -ipad & -ipadhd suffix(后缀) as the "image source" name field in .tmx file
- You should set shared resource's scale property to achieve the same display size on both Retina & Non-Retina devices, but particles are exceptional.
- Use centralized strategy as you can
- cocos2d-x 菜鸟学习笔记二(自适应屏幕分辨率)
- cocos2d-x自适应屏幕分辨率
- cocos2d-x自适应屏幕分辨率
- cocos2d-x自适应屏幕分辨率
- cocos2d-x 1.0版本 自适应屏幕分辨率
- cocos2d-x 2.0版本 自适应屏幕分辨率
- cocos2d-x 2.0版本 自适应屏幕分辨率
- cocos2d-x 2.0版本 自适应屏幕分辨率
- cocos2d-x 2.0版本 自适应屏幕分辨率
- cocos2d-x 2.0版本 自适应屏幕分辨率
- cocos2d-x 2.0版本 自适应屏幕分辨率
- cocos2d-x 2.0版本 自适应屏幕分辨率
- cocos2d-x 2.0版本 自适应屏幕分辨率
- cocos2d-x 2.0版本 自适应屏幕分辨率 .
- cocos2d-x 2.0版本 自适应屏幕分辨率
- cocos2d-x 2.0版本 自适应屏幕分辨率
- cocos2d-x 2.0版本 自适应屏幕分辨率
- cocos2d-x 1.0版本 自适应屏幕分辨率
- 面向对象 - 设计原则总结(OOD)
- 推荐一个免费在线制作Banner的好地方
- DOM4J解析XML
- 可拖动拉伸的左右分栏效果,本例子是用Table以及JS来实现的,左右分栏可改变,拖动中间的边框就可实现宽度的调整,点击时可设置为隐藏左侧列表。
- 调整check_mk的check时间
- cocos2d-x 菜鸟学习笔记二(自适应屏幕分辨率)
- jedis源码中ShardedJedis实现sharding
- sizeof的用法
- linux下bluetooth编程(五)bluetooth与socket
- 使用vector及系统提供的工具进行排序和逆遍历
- 对背景图定位中background
- CSS的选择器
- 康拓展开
- AJAX实现用户登录