- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
据我所知,要在cocos2dx中做一个应用,我需要三套资源ipad、ipadhd和iphone
从一个应用程序示例中,我看到为了支持所有分辨率的设备,我的 friend 使用的 Assets 大小(背景图像)是:
硬盘驱动器:2272 X 1536
iPad: 1136 X 768
苹果手机:568 X 384
这些尺寸适用于横向模式游戏。这是我的问题:1. 为什么我们特别需要这些尺寸?2. 我正在尝试制作一款采用相同 Assets 大小的纵向模式游戏(但由于我在纵向模式下工作,因此我将图像尺寸设为 1536 X 2272、768 X 1136 和 384 X 568)。但是,出于某种原因,BG 图像在模拟器/设备上显示时会放大。我在这里附上屏幕截图。
原始图片:
模拟器中显示的图像:
作为引用,这里是设置设备分辨率大小和内容比例因子的代码:
#define TARGET_DESIGN_RESOLUTION_SIZE DESIGN_RESOLUTION_480X320
typedef struct tagResource
{
cocos2d::CCSize size;
char directory[100];
}Resource;
static Resource smallResource = { cocos2d::CCSizeMake(320, 480), "iphone" };
static Resource mediumResource = { cocos2d::CCSizeMake(768,1024), "iPad" };
static Resource largeResource = { cocos2d::CCSizeMake(1536,2048), "ipadhd" };
#if (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_480X320)
static cocos2d::CCSize designResolutionSize = cocos2d::CCSizeMake(320, 480);
#elif (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_1024X768)
static cocos2d::CCSize designResolutionSize = cocos2d::CCSizeMake(768,1024);
#elif (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_2048X1536)
static cocos2d::CCSize designResolutionSize = cocos2d::CCSizeMake(1536,2048);
#elif (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_NONE)
static cocos2d::CCSize designResolutionSize = cocos2d::CCSizeMake(320, 480);
#else
#error unknown target design resolution!
#endif
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
CCDirector* pDirector = CCDirector::sharedDirector();
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
pDirector->setOpenGLView(pEGLView);
// Set the design resolution
pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height,kResolutionNoBorder);
CCSize frameSize = pEGLView->getFrameSize();
std::vector<std::string> resDirOrders;
// if the frame's height is larger than the height of medium resource size, select large resource.
if (frameSize.width > mediumResource.size.width)
{
resDirOrders.push_back(largeResource.directory);
pDirector->setContentScaleFactor(largeResource.size.width/designResolutionSize.width);
}
// if the frame's height is larger than the height of small resource size, select medium resource.
else if (frameSize.width > smallResource.size.width)
{
resDirOrders.push_back(mediumResource.directory);
pDirector->setContentScaleFactor(mediumResource.size.width/designResolutionSize.width);
}
// if the frame's height is smaller than the height of medium resource size, select small resource.
else
{
resDirOrders.push_back(smallResource.directory);
pDirector->setContentScaleFactor(smallResource.size.width/designResolutionSize.width);
}
CCFileUtils::sharedFileUtils()->setSearchPaths(resDirOrders);
// turn on display FPS
pDirector->setDisplayStats(false);
// 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 = GameLayer::scene();
// run
pDirector->runWithScene(pScene);
return true;
}
最佳答案
实际上,这是因为您的资源( Assets )大小(分辨率)与您设置的设计分辨率不匹配。您的 Assets 具有不同的宽高比,设计分辨率具有不同的宽高比。
我从来没有真正在我的游戏中使用 contentScaleFactor。如果所有 Assets 的比例相同,只需将设计分辨率设置为 Assets 的相同分辨率即可。如果您使用 kResolutionExactFit 策略,Cocos2d-x 会自动重新缩放到设备屏幕。
我认为您应该阅读 Detailed explanation of cocos2d-x multi-resolution support .这是一篇写得很好的文章。
关于android - cocos2dx 应用程序的 Assets 大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21960257/
我无法从主题做一个场景。 我安装了 DirectX 2009 年 3 月 9 日的 SDK,它是 9,“sub”-version c,但是“sub-sub”-version 是 41,所以库 (d3d
我的团队和我一直在努力解决我们在进入 Beta 版之前尝试混淆我们的 Android 应用程序时遇到的异常。 我们得到的异常是: Error:Uncaught translation error: c
我在将同事的 Android 源代码编译为 APK 时遇到问题。这是控制台中显示的错误 :app:transformClassesWithDexForDebug AGPBI: {"kind":"err
我最近在尝试为 Android 构建 apk 时遇到了我的 Azure CI 管道问题。 我收到以下错误: Build-tool 31.0.0 is missing DX at /usr/local/
我的 HelloWorld.java 中有以下代码: public class HelloWorld { public static void main(String[] args) {
我的 Android 应用程序使用了大量非常重要的外部库。这些库都是用 Java 编写的,并简单地添加到构建路径中。 从 Eclipse 中启动应用程序需要很长时间,大约 5 分钟。这非常令人沮丧!
所以我的问题有点简单。我有一个顶点缓冲区,我用创建它 pDevice->CreateVertexBuffer( m_dwCount * sizeof(CUSTOMVERTEX)
eclipse 中有没有办法将参数传递给 dx(--no-optimize 等)以提高 dx 处理速度? 最佳答案 创建少于 300 行的方法,在我创建了一个 2000 行的方法之前,在 Dx 处理中
有没有关于“dx”的文档? 我特别想知道 --core-library 选项的作用。 最佳答案 什么是“dx”工具? dx 工具将 Java 类文件转换为 *.dex(Dalvik 可执行文件)* 文
我目前正在为x86汇编学习考试。 我没有太多运气来搜索“:”,这太常见了标点符号:/ IDIV - Signed Integer Division Usage: IDIV src Modifies f
我有一个输出 jcamp-dx (*.jdx) 文件的仪器。有我可以用来查看数据的软件,但我宁愿用它做一些其他事情,比如在网页上绘制它,这在我必须访问数据的软件中是不允许的。 数据文件是纯文本,但它们
我正在尝试根据是否选中复选框来设置按钮的启用/禁用。下面是我的 javascript 和 asp 代码,它不起作用。我不确定是否根本没有调用该函数,或者我禁用按钮的方式有问题。 function O
我需要从命令行构建我的 android 应用程序(我正在使用 Java7 编译代码),但是当我尝试创建 dex 文件时出现以下错误 trouble processing: bad class file
我尝试使用这段代码缩放矩阵: D3DXMATRIX & rMatrix = m_Matrices[i]; D3DXMatrixScaling(&rMatrix, 2.0
最近我又回到了 C++ 中。我已经离开 C++/CLI 而使用 C# 至少一年了,我有点生疏了。我正在查看适用于 Windows 8 的 Direct3D 应用程序的基本示例,但找不到任何可以解释
当我在 eclipse ADT 中运行 android 应用程序时,“Dx 写入输出时遇到问题:已经准备好”出现在控制台中,然后应用程序照常运行。出现此消息的原因是什么?我该如何解决? 最佳答案 我遇
我想使用 C++ 进行插件开发。在开发 VST 或 DX 之间犹豫不决。有什么考虑?我知道有些主机更容易支持一种或另一种格式(Cubase:VSTs,Cakewalk:DXs),但这就是我所知道的。
我正在尝试根据类型可视化一些评分,但是我很难找到如何根据类型对系列进行分组。 图表选项如下: $scope.chartOptions = { dataSource: data,
如何为 d/d(n*x) 运算符生成模板? 我正在编写一个需要计算图像中线导数的程序。如果我们想计算关于 d/dx 的最简单的导数近似,我们可以运行以下操作: diff[x] = -1.0 * ima
我使用 dev extreme Angular 应用程序中的 UI 框架。 在文档中我找到了如何设置 focus 它说使用 method focus() 但是DxTextBoxComponent中没有
我是一名优秀的程序员,十分优秀!