iOS のスプライト キットは初めてです。シーンにシェイプ ノードを追加したいと考えています。シーンは灰色で、形状はシーンの中央にある白い円です。私のシーンコードは以下です。何らかの理由で、ノードをシーンに追加する最後の行により、ノード数が 2 つ増えます。その行を除外すると、ノードが 0 になり、灰色のシーンだけになります。しかし、線を離れると、円はそこにありますが、ノード数は 2 です。これは大きな問題です。円にノードを追加すると、ノード数が本来の 2 倍になり、速度が低下するためです。誰が問題が何であるか知っていますか?とても有難い!
@interface ColorWheelScene()
@property BOOL contentCreated;
@end
@implementation ColorWheelScene
- (void)didMoveToView:(SKView *)view {
if(!self.contentCreated) {
[self createSceneContents];
self.contentCreated = YES;
}
}
- (void)createSceneContents {
self.backgroundColor = [SKColor grayColor];
self.scaleMode = SKSceneScaleModeAspectFit;
SKShapeNode *wheel = [[SKShapeNode alloc]init];
UIBezierPath *path = [[UIBezierPath alloc] init];
[path moveToPoint:CGPointMake(0.0, 0.0)];
[path addArcWithCenter:CGPointMake(0.0, 0.0) radius:50.0 startAngle:0.0 endAngle:(M_PI*2.0) clockwise:YES];
wheel.path = path.CGPath;
wheel.fillColor = [SKColor whiteColor];
wheel.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame));
[self addChild:wheel];
}
@end