为什么 SKSpriteNode node.frame.size.width 小于 node.size.width ?
这是示例代码,可能您需要插入自己的图像
- (void)DrawRect:(SKSpriteNode *)node
{
SKShapeNode *rect = [[SKShapeNode alloc] init];
CGMutablePathRef myPath = CGPathCreateMutable();
CGPathAddRect(myPath, nil, node.frame);
rect.path = myPath;
rect.lineWidth = 1;
rect.strokeColor = [SKColor whiteColor];
rect.glowWidth = 0;
[self addChild:rect];
}
//这里画精灵
-(void) DrawSpriteNode
{
SKTextureAtlas *atlas = [SKTextureAtlas atlasNamed:@"character"];
SKSpriteNode* node = (SKSpriteNode *)[SKSpriteNode spriteNodeWithTexture:[atlas textureNamed:@"testimage.png"]];
node.position = CGPointMake(self.anchorPoint.x, self.anchorPoint.y);
NSLog(@"node frame width x :%f",node.frame.size.width);
NSLog(@"node frame height y :%f",node.frame.size.height);
NSLog(@"node width y :%f",node.size.width);
NSLog(@"node height y :%f",node.size.height);
node.anchorPoint = CGPointMake(0.5, 0.5);
[self DrawRect: node];
[self addChild:node];
}