iphone – ccp&cpv – 功能差异和完整形式的可可

前端之家收集整理的这篇文章主要介绍了iphone – ccp&cpv – 功能差异和完整形式的可可前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我的应用程序中有以下代码.

我是使用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;

}

@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;
}

ccp&的功能是什么? CPV?
(我认为这是为了设置图层的位置,但我不确定.所以我要求)

萨加尔

解决方法

从源代码

CGPointExtension.h

#define ccp(__X__,__Y__) CGPointMake(__X__,__Y__)

cpVect.h开始

#define cpVect CGPoint
static inline cpVect cpv(const cpFloat x,const cpFloat y)
{
        cpVect v = {x,y};
        return v;
}

猜你在找的Xcode相关文章