Search code examples
sprite-kitskshapenode

setFillColor with patternImage cocos2d not working


I am trying to fill a SKShapeNode with an image. I have tried quite a few things but can't get it to work. The game loads, but nothing appears on the screen. Here is my recent code.

self.circle = [[SKShapeNode alloc] init];

        UIBezierPath *bezier = [UIBezierPath bezierPathWithArcCenter:CGPointMake(size.width / 2.0, 220.0) radius:8.0
                                                          startAngle:0.0
                                                            endAngle:2.0 * M_PI
                                                           clockwise:YES];

        [self.circle setPath:bezier.CGPath];
        [self.circle setFillColor:[SKColor colorWithPatternImage:[UIImage imageNamed:@"raceCar.png"]]];
        [self.circle setStrokeColor:[SKColor blueColor]];
        [self.circle setPosition:CGPointMake(0.0, 0.0)];
        [self.circle setZPosition:1000.0];

        SKPhysicsBody *circlePhysics = [SKPhysicsBody bodyWithPolygonFromPath:bezier.CGPath];

        [circlePhysics setCategoryBitMask:16];
        [circlePhysics setCollisionBitMask:0];
        [circlePhysics setContactTestBitMask:2];
        [circlePhysics setDynamic:NO];
        [circlePhysics setUsesPreciseCollisionDetection:YES];

        [self.circle setPhysicsBody:circlePhysics];

        [self addChild:self.circle];

I appreciate any help. Thank you


Solution

  • Color patterns are not supported in Sprite Kit.

    At least it won't work in 7.0 and 7.1. I haven't tried 8.0 yet but haven't heard any reports to the contrary either.