on iPad retina @2x 正确加载,但 -hd 以一半大小加载,即使图像相同
on iPad retina @2x loads properly, but -hd loads at half-size even though images are identical
@2x 图像与-hd 图像完全相同,除了后缀。同时包括 @2x 和 -hd 允许程序在所有设备上正常 运行,但显然我想摆脱一组以减小文件大小。
当使用 [sharedFileUtils setiPadSuffix:@"@2x"]
时,iPad 使用 @2x 图像,一切都很好。以正确的内容比例和所有内容加载。
当使用 [sharedFileUtils setiPadSuffix:@"-hd"]
时,iPad 确实使用了 -hd 图像(用 [sharedFileUtils fullPathForFilename:@"image.png"]
检查过)。但是,所有内容突然以 50% 的大小加载。
(我是 运行宁 Cocos2d 3.4.3 和 Xcode 6.1.1)
为什么要这样做?
警告:胆小者勿入。
我正在为所有设备使用一组纹理(-hd 变体)。在实施时,我发现 CCFileUtils
returns 中的 contentScaleForKey
方法是一个流浪汉值。除了在 cocos' 发行版中进行篡改外,我没有找到其他方法,如下所示:
-(CGFloat) contentScaleForKey:(NSString*)k inDictionary:(NSDictionary *)dictionary
{
// XXX XXX Super Slow
// ylb fix for single set of textures
return 2.0f;
// ylb : super fast now :)
}
我在 AppDelegate(版本 3.2.1)中设置如下:
@implementation AppDelegate
NSString *kCCFileUtilsSuffixDefault = @"default";
NSString *kCCFileUtilsSuffixiPad = @"ipad";
NSString *kCCFileUtilsSuffixiPadHD = @"ipadhd";
NSString *kCCFileUtilsSuffixiPhone = @"iphone";
NSString *kCCFileUtilsSuffixiPhoneHD = @"iphonehd";
NSString *kCCFileUtilsSuffixiPhone5 = @"iphone5";
NSString *kCCFileUtilsSuffixiPhone5HD = @"iphone5hd";
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// This is the only app delegate method you need to implement when inheriting from CCAppDelegate.
// This method is a good place to add one time setup code that only runs when your app is first launched.
// Setup Cocos2D with reasonable defaults for everything.
// There are a number of simple options you can change.
// If you want more flexibility, you can configure Cocos2D yourself instead of calling setupCocos2dWithOptions:.
// [[CCFileUtils sharedFileUtils] setEnableiPhoneResourcesOniPad:YES];
[GEFileUtil initializeWithProductDirectoryName:@"battles" andMaximumGames:4];
TRACE(@"Setting up cocos2d in fixed screen mode");
[GERuntimeConstants setDeviceType:CCScreenModeFixedSize];
NSDictionary *dic = [CCFileUtils sharedFileUtils].suffixesDict;
[dic setValue:@"-hd" forKey:kCCFileUtilsSuffixDefault];
[dic setValue:@"-hd" forKey:kCCFileUtilsSuffixiPhone];
[dic setValue:@"-hd" forKey:kCCFileUtilsSuffixiPad];
[dic setValue:@"-hd" forKey:kCCFileUtilsSuffixiPadHD];
[dic setValue:@"-hd" forKey:kCCFileUtilsSuffixiPhoneHD];
[dic setValue:@"-hd" forKey:kCCFileUtilsSuffixiPhone5];
[dic setValue:@"-hd" forKey:kCCFileUtilsSuffixiPhone5HD];
[self setupCocos2dWithOptions:@{
// Show the FPS and draw call label.
CCSetupShowDebugStats : @(YES),
// More examples of options you might want to fiddle with:
// (See CCAppDelegate.h for more information)
// Use a 16 bit color buffer:
// CCSetupPixelFormat: kEAGLColorFormatRGB565,
// Use a simplified coordinate system that is shared across devices.
CCSetupScreenMode : CCScreenModeFixed,
// Run in landscape mode.
CCSetupScreenOrientation : CCScreenOrientationLandscape,
// Run at a reduced framerate. Prefer that to 'dang' jitter
CCSetupAnimationInterval : @(1.0 / 30.0),
// Run the fixed timestep extra fast.
CCSetupFixedUpdateInterval : @(1.0 / 60.0),
// clipping with stensil
CCSetupDepthFormat : [NSNumber numberWithUnsignedInt:GL_DEPTH24_STENCIL8_OES],
// Make iPad's act like they run at a 2x content scale. (iPad retina 4x)
// CCSetupTabletScale2X: @(YES),
}];
现在在所有设备上工作,注意 如果我想更新 cocos2d,我必须格外小心(永远不要在我的位工厂中进行项目).
@2x 图像与-hd 图像完全相同,除了后缀。同时包括 @2x 和 -hd 允许程序在所有设备上正常 运行,但显然我想摆脱一组以减小文件大小。
当使用 [sharedFileUtils setiPadSuffix:@"@2x"]
时,iPad 使用 @2x 图像,一切都很好。以正确的内容比例和所有内容加载。
当使用 [sharedFileUtils setiPadSuffix:@"-hd"]
时,iPad 确实使用了 -hd 图像(用 [sharedFileUtils fullPathForFilename:@"image.png"]
检查过)。但是,所有内容突然以 50% 的大小加载。
(我是 运行宁 Cocos2d 3.4.3 和 Xcode 6.1.1)
为什么要这样做?
警告:胆小者勿入。
我正在为所有设备使用一组纹理(-hd 变体)。在实施时,我发现 CCFileUtils
returns 中的 contentScaleForKey
方法是一个流浪汉值。除了在 cocos' 发行版中进行篡改外,我没有找到其他方法,如下所示:
-(CGFloat) contentScaleForKey:(NSString*)k inDictionary:(NSDictionary *)dictionary
{
// XXX XXX Super Slow
// ylb fix for single set of textures
return 2.0f;
// ylb : super fast now :)
}
我在 AppDelegate(版本 3.2.1)中设置如下:
@implementation AppDelegate
NSString *kCCFileUtilsSuffixDefault = @"default";
NSString *kCCFileUtilsSuffixiPad = @"ipad";
NSString *kCCFileUtilsSuffixiPadHD = @"ipadhd";
NSString *kCCFileUtilsSuffixiPhone = @"iphone";
NSString *kCCFileUtilsSuffixiPhoneHD = @"iphonehd";
NSString *kCCFileUtilsSuffixiPhone5 = @"iphone5";
NSString *kCCFileUtilsSuffixiPhone5HD = @"iphone5hd";
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// This is the only app delegate method you need to implement when inheriting from CCAppDelegate.
// This method is a good place to add one time setup code that only runs when your app is first launched.
// Setup Cocos2D with reasonable defaults for everything.
// There are a number of simple options you can change.
// If you want more flexibility, you can configure Cocos2D yourself instead of calling setupCocos2dWithOptions:.
// [[CCFileUtils sharedFileUtils] setEnableiPhoneResourcesOniPad:YES];
[GEFileUtil initializeWithProductDirectoryName:@"battles" andMaximumGames:4];
TRACE(@"Setting up cocos2d in fixed screen mode");
[GERuntimeConstants setDeviceType:CCScreenModeFixedSize];
NSDictionary *dic = [CCFileUtils sharedFileUtils].suffixesDict;
[dic setValue:@"-hd" forKey:kCCFileUtilsSuffixDefault];
[dic setValue:@"-hd" forKey:kCCFileUtilsSuffixiPhone];
[dic setValue:@"-hd" forKey:kCCFileUtilsSuffixiPad];
[dic setValue:@"-hd" forKey:kCCFileUtilsSuffixiPadHD];
[dic setValue:@"-hd" forKey:kCCFileUtilsSuffixiPhoneHD];
[dic setValue:@"-hd" forKey:kCCFileUtilsSuffixiPhone5];
[dic setValue:@"-hd" forKey:kCCFileUtilsSuffixiPhone5HD];
[self setupCocos2dWithOptions:@{
// Show the FPS and draw call label.
CCSetupShowDebugStats : @(YES),
// More examples of options you might want to fiddle with:
// (See CCAppDelegate.h for more information)
// Use a 16 bit color buffer:
// CCSetupPixelFormat: kEAGLColorFormatRGB565,
// Use a simplified coordinate system that is shared across devices.
CCSetupScreenMode : CCScreenModeFixed,
// Run in landscape mode.
CCSetupScreenOrientation : CCScreenOrientationLandscape,
// Run at a reduced framerate. Prefer that to 'dang' jitter
CCSetupAnimationInterval : @(1.0 / 30.0),
// Run the fixed timestep extra fast.
CCSetupFixedUpdateInterval : @(1.0 / 60.0),
// clipping with stensil
CCSetupDepthFormat : [NSNumber numberWithUnsignedInt:GL_DEPTH24_STENCIL8_OES],
// Make iPad's act like they run at a 2x content scale. (iPad retina 4x)
// CCSetupTabletScale2X: @(YES),
}];
现在在所有设备上工作,注意 如果我想更新 cocos2d,我必须格外小心(永远不要在我的位工厂中进行项目).