CCLabelTTF通用设备问题

时间:2015-06-19 20:31:50

标签: ios objective-c opengl-es cocos2d-iphone cclabelttf

我在CCNodeColor上有一个CCLabelTTF,它将在屏幕上滚动。我的问题是它在iPad Mini,iPhone 4,5,6上看起来很完美,在iPhone6 +,iPad Air,iPad Retina上完全出错了。我改变了contentSizeType,没有任何改变。当前的字体大小是15.0f,但是如果我将它降低到5.0f它将正常工作(但它会太小)。奇怪的是,如果我将字体更改为25.0f,它将无法在任何设备上运行。我事先并不了解contentSize,因为它基于NSString的长度。这一切都可以在SpriteBuilder中完成吗?我在应用程序的其他方面使用SpriteBuilder。我正在使用最新的Cocos2d版本。以下是图片和代码:

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<div ng-app="app" ng-controller="ctrl">
  Edit
  <div class="form-control" type="search" ng-model="seach" ng-change="searchChanged()" contenteditable="true"></div>
  {{seach}}
</div>

这是我在调试区域注意到的。我完全迷失了这些东西

self.tickerOne = [CCNodeColor nodeWithColor:[CCColor redColor]];
self.tickerTwo = [CCNodeColor nodeWithColor:[CCColor redColor]];

self.dataSourceArray = [self.dataSource setDataSourceArray];

NSString *stockTickerString = [self.dataSourceArray componentsJoinedByString:@" |  "];

self.tickerOne.positionType = CCPositionTypeNormalized;
self.tickerOne.anchorPoint = ccp(0.5f,0.0f);
self.tickerOne.name = @"tickerOne";

CCLabelTTF *tickerLabel = [CCLabelTTF labelWithString:stockTickerString fontName:@"ArialMT" fontSize:**15.0f**];
tickerLabel.positionType = CCPositionTypeNormalized;
tickerLabel.anchorPoint = ccp(0.5f,0.5f);
tickerLabel.position = ccp(0.5f,0.5f);
tickerLabel.name = @"tickerLabel1";


self.contentSizeType = CCSizeTypePoints;
self.contentSize = CGSizeMake(tickerLabel.contentSize.width*1.5,tickerLabel.contentSize.height*2);
self.tickerOne.contentSize = self.contentSize;

[self addChild:self.tickerOne];
[self.tickerOne addChild:tickerLabel z:10];

图片:iPad Retina标签字体大小15.0f enter image description here

图片:iPhone 6标签字体大小15.0f enter image description here

图片:iPhone 6标签字体大小25.0f enter image description here

0 个答案:

没有答案