整理代码结构
调整代码结构,使它能够在ios和android上运行。
结果发现,ios上纹理必须是2的整数次幂,解决方法使用opengles3.0.
ios上读取plist长度不对,解决方法通过nsdictionary 读取,然后再进行转换。
转换代码如下:
/ the value is a string
if ([nsValue isKindOfClass:[NSString class]])
{
dict[key] = Value([nsValue UTF8String]);
return;
}
// the value is a number
if ([nsValue isKindOfClass:[NSNumber class]])
{
NSNumber* num = nsValue;
const char* numType = [num objCType];
if(num == (void*)kCFBooleanFalse || num == (void*)kCFBooleanTrue)
{
dict[key] = Value([num boolValue]);
}
else if(strcmp(numType, @encode(float)) == 0)
{
dict[key] = Value([num floatValue]);
}
else if(strcmp(numType, @encode(double)) == 0)
{
dict[key] = Value([num doubleValue]);
}
else{
dict[key] = Value([num intValue]);
}
return;
}
本文介绍了解决跨平台游戏开发中遇到的问题,包括iOS平台纹理尺寸限制及解决方案,采用OpenGL ES 3.0确保纹理兼容性;同时解决了iOS上读取plist文件长度不正确的问题,通过NSDictionary进行数据转换。
153

被折叠的 条评论
为什么被折叠?



