Skip to content

Commit 45a98e9

Browse files
committed
Tests now makes correct use of UI points for interface.
1 parent ad12be3 commit 45a98e9

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

cocos2d-ui-tests/MainMenu.m

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,26 +81,27 @@ - (id) init
8181

8282
// Header background
8383
CCSprite9Slice* headerBg = [CCSprite9Slice spriteWithImageNamed:@"Interface/header.png"];
84-
headerBg.positionType = CCPositionTypeMake(CCPositionUnitPoints, CCPositionUnitPoints, CCPositionReferenceCornerTopLeft);
84+
headerBg.positionType = CCPositionTypeMake(CCPositionUnitUIPoints, CCPositionUnitUIPoints, CCPositionReferenceCornerTopLeft);
8585
headerBg.position = ccp(0,0);
8686
headerBg.anchorPoint = ccp(0,1);
87-
headerBg.contentSizeType = CCSizeTypeMake(CCSizeUnitNormalized, CCSizeUnitPoints);
87+
headerBg.contentSizeType = CCSizeTypeMake(CCSizeUnitNormalized, CCSizeUnitUIPoints);
8888
headerBg.contentSize = CGSizeMake(1, kCCUITestHeaderHeight);
8989

9090
[self addChild:headerBg];
9191

9292
// Header label
93-
CCLabelTTF* lblTitle = [CCLabelTTF labelWithString:@"Cocos2d Tests" fontName:@"HelveticaNeue-Medium" fontSize:17];
93+
CCLabelTTF* lblTitle = [CCLabelTTF labelWithString:@"Cocos2d Tests" fontName:@"HelveticaNeue-Medium" fontSize:17 * [CCDirector sharedDirector].UIScaleFactor];
9494
lblTitle.positionType = CCPositionTypeNormalized;
9595
lblTitle.position = ccp(0.5, 0.5);
9696

9797
[headerBg addChild:lblTitle];
9898

9999
// Table view
100100
CCTableView* tableView = [[CCTableView alloc] init];
101-
tableView.contentSizeType = CCSizeTypeMake(CCSizeUnitNormalized, CCSizeUnitInsetPoints);
101+
tableView.contentSizeType = CCSizeTypeMake(CCSizeUnitNormalized, CCSizeUnitInsetUIPoints);
102102
tableView.contentSize = CGSizeMake(1, kCCUITestHeaderHeight);
103103
tableView.rowHeight = kCCTestMenuItemHeight;
104+
tableView.rowHeightUnit = CCSizeUnitUIPoints;
104105
tableView.dataSource = self;
105106

106107
[self addChild:tableView z:-1];
@@ -125,7 +126,7 @@ - (void) selectedRow:(id)sender
125126
- (CCTableViewCell*) tableView:(CCTableView*)tableView nodeForRowAtIndex:(NSUInteger) index
126127
{
127128
CCTableViewCell* cell = [[CCTableViewCell alloc] init];
128-
cell.contentSizeType = CCSizeTypeMake(CCSizeUnitNormalized, CCSizeUnitPoints);
129+
cell.contentSizeType = CCSizeTypeMake(CCSizeUnitNormalized, CCSizeUnitUIPoints);
129130
cell.contentSize = CGSizeMake(1, kCCTestMenuItemHeight);
130131

131132
CCSpriteFrame* frameNormal = [CCSpriteFrame frameWithImageNamed:@"Interface/table-bg-normal.png"];
@@ -134,8 +135,8 @@ - (CCTableViewCell*) tableView:(CCTableView*)tableView nodeForRowAtIndex:(NSUInt
134135
[cell.button setBackgroundSpriteFrame:frameNormal forState:CCControlStateNormal];
135136
[cell.button setBackgroundSpriteFrame:frameHilite forState:CCControlStateHighlighted];
136137

137-
CCLabelTTF* label = [CCLabelTTF labelWithString:[[self testClassNames] objectAtIndex:index] fontName:@"HelveticaNeue" fontSize:17];
138-
label.positionType = CCPositionTypeMake(CCPositionUnitPoints, CCPositionUnitNormalized, CCPositionReferenceCornerBottomLeft);
138+
CCLabelTTF* label = [CCLabelTTF labelWithString:[[self testClassNames] objectAtIndex:index] fontName:@"HelveticaNeue" fontSize:17 * [CCDirector sharedDirector].UIScaleFactor];
139+
label.positionType = CCPositionTypeMake(CCPositionUnitUIPoints, CCPositionUnitNormalized, CCPositionReferenceCornerBottomLeft);
139140
label.position = ccp(20, 0.5f);
140141
label.anchorPoint = ccp(0, 0.5f);
141142

cocos2d-ui-tests/TestBase.m

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ - (id) init
3838

3939
// Create test content
4040
self.contentNode = [CCNode node];
41-
self.contentNode.contentSizeType = CCSizeTypeMake(CCSizeUnitNormalized, CCSizeUnitInsetPoints);
41+
self.contentNode.contentSizeType = CCSizeTypeMake(CCSizeUnitNormalized, CCSizeUnitInsetUIPoints);
4242
self.contentNode.contentSize = CGSizeMake(1, 44);
4343
self.contentNode.name = @"TestBase Content Node";
4444

@@ -48,25 +48,25 @@ - (id) init
4848

4949
// Header background
5050
CCSprite9Slice* headerBg = [CCSprite9Slice spriteWithImageNamed:@"Interface/header.png"];
51-
headerBg.positionType = CCPositionTypeMake(CCPositionUnitPoints, CCPositionUnitPoints, CCPositionReferenceCornerTopLeft);
51+
headerBg.positionType = CCPositionTypeMake(CCPositionUnitUIPoints, CCPositionUnitUIPoints, CCPositionReferenceCornerTopLeft);
5252
headerBg.position = ccp(0,0);
5353
headerBg.anchorPoint = ccp(0,1);
54-
headerBg.contentSizeType = CCSizeTypeMake(CCSizeUnitNormalized, CCSizeUnitPoints);
54+
headerBg.contentSizeType = CCSizeTypeMake(CCSizeUnitNormalized, CCSizeUnitUIPoints);
5555
headerBg.contentSize = CGSizeMake(1, 44);
5656

5757
[self addChild:headerBg];
5858

5959
// Header label
60-
_lblTitle = [CCLabelTTF labelWithString:NSStringFromClass([self class]) fontName:@"HelveticaNeue-Medium" fontSize:17];
60+
_lblTitle = [CCLabelTTF labelWithString:NSStringFromClass([self class]) fontName:@"HelveticaNeue-Medium" fontSize:17 * [CCDirector sharedDirector].UIScaleFactor];
6161
_lblTitle.positionType = CCPositionTypeNormalized;
6262
_lblTitle.position = ccp(0.5f,0.5f);
6363

6464
[headerBg addChild:_lblTitle];
6565

66-
_lblSubTitle = [CCLabelTTF labelWithString:@"" fontName:@"HelveticaNeue-Light" fontSize:14];
66+
_lblSubTitle = [CCLabelTTF labelWithString:@"" fontName:@"HelveticaNeue-Light" fontSize:14 * [CCDirector sharedDirector].UIScaleFactor];
6767
_lblSubTitle.shadowColor = [CCColor blackColor];
6868
_lblSubTitle.shadowBlurRadius = 2.5;
69-
_lblSubTitle.positionType = CCPositionTypeMake(CCPositionUnitNormalized, CCPositionUnitPoints, CCPositionReferenceCornerTopLeft);
69+
_lblSubTitle.positionType = CCPositionTypeMake(CCPositionUnitNormalized, CCPositionUnitUIPoints, CCPositionReferenceCornerTopLeft);
7070
_lblSubTitle.position = ccp(0.5, 64);
7171
_lblSubTitle.horizontalAlignment = CCTextAlignmentCenter;
7272

@@ -76,7 +76,7 @@ - (id) init
7676
CCSpriteFrame* frame = [[CCSpriteFrameCache sharedSpriteFrameCache]spriteFrameByName:@"Interface/btn-back.png"];
7777

7878
_btnBack = [CCButton buttonWithTitle:NULL spriteFrame:frame];
79-
_btnBack.positionType = CCPositionTypeMake(CCPositionUnitPoints, CCPositionUnitPoints, CCPositionReferenceCornerTopLeft);
79+
_btnBack.positionType = CCPositionTypeMake(CCPositionUnitUIPoints, CCPositionUnitUIPoints, CCPositionReferenceCornerTopLeft);
8080
_btnBack.position = ccp(22, 22);
8181
_btnBack.background.opacity = 0;
8282

@@ -85,7 +85,7 @@ - (id) init
8585

8686
// Prev button
8787
_btnPrev = [CCButton buttonWithTitle:NULL spriteFrame:[[CCSpriteFrameCache sharedSpriteFrameCache]spriteFrameByName:@"Interface/btn-prev.png"]];
88-
_btnPrev.positionType = CCPositionTypeMake(CCPositionUnitPoints, CCPositionUnitPoints, CCPositionReferenceCornerBottomLeft);
88+
_btnPrev.positionType = CCPositionTypeMake(CCPositionUnitUIPoints, CCPositionUnitUIPoints, CCPositionReferenceCornerBottomLeft);
8989
_btnPrev.position = ccp(22, 22);
9090
_btnPrev.background.opacity = 0;
9191

@@ -94,7 +94,7 @@ - (id) init
9494

9595
// Next button
9696
_btnNext = [CCButton buttonWithTitle:NULL spriteFrame:[[CCSpriteFrameCache sharedSpriteFrameCache]spriteFrameByName:@"Interface/btn-next.png"]];
97-
_btnNext.positionType = CCPositionTypeMake(CCPositionUnitPoints, CCPositionUnitPoints, CCPositionReferenceCornerBottomRight);
97+
_btnNext.positionType = CCPositionTypeMake(CCPositionUnitUIPoints, CCPositionUnitUIPoints, CCPositionReferenceCornerBottomRight);
9898
_btnNext.position = ccp(22, 22);
9999
_btnNext.background.opacity = 0;
100100

@@ -103,7 +103,7 @@ - (id) init
103103

104104
// Reload button
105105
_btnReload = [CCButton buttonWithTitle:NULL spriteFrame:[[CCSpriteFrameCache sharedSpriteFrameCache]spriteFrameByName:@"Interface/btn-reload.png"]];
106-
_btnReload.positionType = CCPositionTypeMake(CCPositionUnitNormalized, CCPositionUnitPoints, CCPositionReferenceCornerBottomLeft);
106+
_btnReload.positionType = CCPositionTypeMake(CCPositionUnitNormalized, CCPositionUnitUIPoints, CCPositionReferenceCornerBottomLeft);
107107
_btnReload.position = ccp(0.5, 22);
108108
_btnReload.background.opacity = 0;
109109

cocos2d-ui-tests/ios/AppDelegate.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
4444

4545
[self setupCocos2dWithOptions:@{
4646
CCSetupDepthFormat: @GL_DEPTH24_STENCIL8,
47+
CCSetupTabletScale2X: @YES,
4748
// CCSetupScreenMode: CCScreenModeFixed,
4849
// CCSetupScreenOrientation: CCScreenOrientationPortrait,
49-
// CCSetupTabletScale2X: @YES,
5050
// CCSetupShowDebugStats: @YES,
5151
}];
5252

0 commit comments

Comments
 (0)