Sag*_*ari 4 iphone xcode cocos2d-iphone
我的应用程序中有以下代码.
我是使用COCOS在iPhone中进行游戏开发的新手.
Sprite *bg=[Sprite spriteWithFile:@"menu.png"];
[bg setPosition:ccp(240,160)];
[self addChild:bg z:0];
[self addChild:[GameLayer node] z:1];
}
return self;
Run Code Online (Sandbox Code Playgroud)
}
@end
@implementation GameLayer
-(id)init{
if(self=[super init]){
Label *test=[Label labelWithString:@"Hello World" fontName:@"Helvetica" fontSize:24];
test.position=cpv(160, 240);
test.visible=YES;
[self addChild:test];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
ccp和cpv的功能是什么?(我认为这是为了设置图层的位置,但我不确定.所以我要求)
萨加尔
ccp是COCOS定义的一个简单宏,可以轻松创建CGPoint.所以它只不过是一个点(x,y坐标)它被定义为:
#define ccp(__X__,__Y__) CGPointMake(__X__,__Y__)
Run Code Online (Sandbox Code Playgroud)
position是Label对象的一个属性,它可能将屏幕上的位置设置为由创建的点ccp().我不知道哪个角被用作参考点(中心/左上角/左下角?)因为我从未使用过COCOS所以请亲自试试.
祝好运
| 归档时间: |
|
| 查看次数: |
5868 次 |
| 最近记录: |