我正在使用 SKShapeNode 来创建像山一样的对象。我使用 CGMutablePathRef 给我的路径点
SKShapeNode *shapenode = [[SKShapeNode alloc] init];
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, 0, 0);
......
for (int i = 0; i < [refData count];i++) {
CGPathAddLineToPoint(path, NULL, ((float)i/[refData count])*screenWidthBoundry, [[refData objectAtIndex:i] doubleValue]);
}
CGPathAddLineToPoint(path, NULL, screenWidthBoundry, 0);
CGPathAddLineToPoint(path, NULL, 0, 0);
shapenode.path = path;
shapenode.antialiased = YES;
shapenode.fillColor = [SKColor colorWithRed:17.0/255.0 green:108.0/255.0 blue:125.0/255.0 alpha:1.0];
//shapenode.strokeColor = [UIColor clearColor];
shapenode.lineWidth = 1.0f;
shapenode.physicsBody = [SKPhysicsBody bodyWithEdgeChainFromPath:path];
shapenode.physicsBody.affectedByGravity = NO;
shapenode.physicsBody.categoryBitMask = CollisionTypeMountain;
shapenode.physicsBody.collisionBitMask = 0;
shapenode.physicsBody.contactTestBitMask = CollisionTypeBird;
CGPathRelease(path);
return shapenode;
我的问题是 SkShapeNode 正在减慢 iPhone 4 上的动画速度(在 iPad 和 iPhone 5 上运行流畅,但仍然不是 60 fps)并消耗大量内存。我可以缓存 skshapnode 对象以顺利运行动画吗?任何帮助表示赞赏!