<新機能項目>
- 座標位置設定:positionTypeプロパティ
・このプロパティで画面座標位置指定方法を変更できます。
1.CCPositionTypePoints:従来通り(デフォルト)
2.CCPositionTypeUIPoints:UIKit座標系 - 左上原点
3.CCPositionTypeNormalized:親ノードの最大値を1.0とした割合指定 - コンテンツサイズ設定:contentSizeTypeプロパティ
・このプロパティでコンテンツサイズ指定方法を変更できます。
1.CCSizeTypePoints:従来通り(デフォルト)
2.CCSizeTypeUIPoints:UIKit座標系 - 左上原点
3.CCSizeTypeNormalized:親ノードの最大値を1.0とした割合指定
<positionTypeプロパティ設定サンプル>
// create and initialize a Label
CCLabelTTF *label = [CCLabelTTF labelWithString:@"Hello World"
fontName:@"Marker Felt" fontSize:64];
// ask director for the window size
CGSize size = [[CCDirector sharedDirector] winSize];
// position the label on the center of the screen
label.position = ccp( size.width /2 , size.height/2 );
// add the label as a child to this Layer
[self addChild: label];
// Hello world
CCLabelTTF *label = [CCLabelTTF labelWithString:@"Hello World"
fontName:@"Chalkduster" fontSize:36.0f];
label.positionType = CCPositionTypeNormalized;
label.color = [CCColor redColor];
label.position = ccp(0.5f, 0.5f); // Middle of screen
[self addChild:label];
<所感>
- cocos2d v3系の目玉機能と言えそうな新機能です。 うーん素晴らしい(^o^)
- 上記プロパティを「……TypeNormalized」に設定することで相対位置(割合)で設定可能になりますので、画面サイズに依存しない位置指定やサイズ指定が可能となり柔軟な配置が実現できます。
└ iPhone 5以降での4インチ画面サイズ(1,136 x 640 px)対応にも使えそうです - CCLayout、CCLayoutBox等の配置用ノードと組み合わせて全てのノードを相対配置にしておけば今後新たな画面サイズが登場しても大丈夫そうですね。
ではまた〜
0 件のコメント:
コメントを投稿