私はcocos2dを使用していると私は(私が円を描くようにしたい、それが動作します)cccnodeをサブクラス化している の.h[convertToGl]を呼び出す必要がありますか?
@interface CCSpriteCircle : CCSprite {
float radius;
float angle; //in radians
NSUInteger segments;
BOOL drawLineToCenter;
ccColor4B cColor;
}
-(id) initWithRadius: (float)radius_ withAngle: (float)angle_ withSegments: (NSUInteger)segments_ withDrawLineToCenter:(BOOL)drawLineToCenter_;
@property(nonatomic,assign) float radius;
@property(nonatomic,assign) float angle;
@property(nonatomic,assign) NSUInteger segments;
@property(nonatomic,assign) BOOL drawLineToCenter;
@property(nonatomic,assign) ccColor4B cColor;
@end
//私の.mファイル
@implementationのCCSpriteCircle @synthesize半径、角度、セグメント、drawLineToCenter、cColor;
-(id) initWithRadius: (float)radius_ withAngle: (float)angle_ withSegments: (NSUInteger)segments_ withDrawLineToCenter:(BOOL)drawLineToCenter_
{
if((self=[super init])) {
self.radius = radius_;
self.angle = angle_;
self.segments = segments_;
self.drawLineToCenter = drawLineToCenter_;
//[self draw];
}
return self;
}
-(void)draw {
glLineWidth(1);
glColor4ub(cColor.r, cColor.g, cColor.b, cColor.a);
ccDrawCircle(ccp(self.position.x,self.position.y), radius, angle, segments, drawLineToCenter);
// restore original values
glLineWidth(1);
glColor4ub(255,255,255,255);
glPointSize(1);
}
@end
すべて私が480に私のccspritecircleの中心を配置する場合(つまり、画面端だ)ことを除いて正常に動作し、それが表示されますが、私は200pxのにそれを置く場合には、画面の終わりだdoesntのは。
私はこのような私のHelloWorldのシーンに位置コードを変更する場合: から:
circle_.position = CCP(480、0);その後、私はもうサークルを参照してくださいいけない
circle_.position = [[CCDirector sharedDirector] convertToGL: CGPointMake(480,0)];
:へ
。何か間違っているのですか?