предупреждение:. не для слабонервных
Я использую один набор текстур для всех приборов (-HD вариант) При реализации, что я. что contentScaleForKey
метод в CCFileUtils
возвращает значение bum. Я не нашел другого выхода, кроме врачевания, что в распределении Кокосовых, следующим образом:
-(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),
}];
работает на всех устройствах в настоящее время , с caveat, что я должен быть очень осторожным, если я хочу обновить cocos2d (НИКОГДА не выполняйте мой проект на середине моего проекта).
Что такое 'sharedFileUtils'? – rmaddy
Извините, это от CCFileUtils. Он позволяет мне переписать суффикс по умолчанию для загрузки изображений (т. Е. Ipad обычно ищет -ipad, прежде чем возвращаться на -hd). Я не уверен, почему добавление суффикса @ 2x позволило бы правильно загружать изображения, честно говоря. – grasshopper
Я использую один набор текстур для всех устройств. Во время реализации я обнаружил, что метод 'contentScaleForKey' в' CCFileUtils' возвращает значение bum. Я не нашел другого способа, кроме как докторировать это в распространении кокоса. Работает на всех устройствах сейчас, с предостережением, что я должен быть особенно осторожным, если я хочу обновить cocos2d (НИКОГДА не выполняйте проект на моем битовом заводе). – YvesLeBorg