0

SKActionサークル ( byで作成SKShapeNode) をボール ( で作成)に同期させようとしていますSKShapeNode。これがこのコードです。しかし、うまくいきませんでした。私は何をすべきか?

-(void)makeContents{

    //make ground
    UIBezierPath *groundPath = [UIBezierPath bezierPath];
    [groundPath moveToPoint:CGPointMake(0,250)];
    [groundPath addLineToPoint:CGPointMake(568,100)];
    SKShapeNode *ground = [[SKShapeNode alloc] init];
    ground.path = groundPath.CGPath;
    [self addChild:ground];

    //make ball
    SKSpriteNode *ball = [SKSpriteNode spriteNodeWithImageNamed:@"ball.jpeg"];
    ball.position = CGPointMake(10, 320);
    ball.size = CGSizeMake(20, 20);
    ball.physicsBody.dynamic = YES;
    ball.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:3];
    [self addChild:ball];

}

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

    //make circle
    UIBezierPath *circlePath = [UIBezierPath bezierPath];
    [circlePath addArcWithCenter:ball.position radius:10 startAngle:0 endAngle:2*M_PI clockwise:NO];
    circle = [[SKShapeNode alloc] init];
    circle.path = circlePath.CGPath;
    circle.strokeColor = [SKColor blackColor];

    //this line added after first post.
    circle.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:10 center:ball.postion];


    [self addChild:circle];

    //make action
    SKAction *scale = [SKAction sequence:@[[SKAction scaleBy:0.1 duration:2],
                                           [SKAction scaleBy:0 duration:0.01]]];
    [circle runAction:[SKAction repeatActionForever:scale]];

}

よろしくお願いいたします。

4

0 に答える 0