我不明白为什么不让我把球加到现场。下面的代码是我正在使用的唯一代码。
-(void) addBall:(CGSize)size {
ball = [SKShapeNode shapeNodeWithCircleOfRadius:50];
ball.color = [SKColor colorWithRed:225.0f/255.0f green:76.0f/255.0f blue:76.0f/255.0f alpha:1.0];
ball.position = CGPointMake(self.size.height/2, self.size.width/2);
[self addChild:ball];
}
-(void)didMoveToView:(SKView *)view {
/* Setup your scene here */
[self addBall:size];
}
答案 0 :(得分:1)
-(void) addBall
{
SKShapeNode *ball;
ball = [SKShapeNode shapeNodeWithCircleOfRadius:50];
ball.strokeColor = [SKColor colorWithRed:225.0f/255.0f green:76.0f/255.0f blue:76.0f/255.0f alpha:1.0];
ball.fillColor = [SKColor colorWithRed:225.0f/255.0f green:76.0f/255.0f blue:76.0f/255.0f alpha:1.0];
ball.position = CGPointMake(self.size.height/2, self.size.width/2);
[self addChild:ball];
}
-(void)didMoveToView: (SKView *)view
{
[self addBall];
}
这是有效的,我测试了。