SKNode(及其子类)的布局是以 position 跟 anchorPoint(子类含有) 相结合
不适用于SKLableNode
#import <SpriteKit/SpriteKit.h>
@interface SKNode (Frame)
@property (nonatomic, readonly) CGFloat sk_left;
@property (nonatomic, readonly) CGFloat sk_right;
@property (nonatomic, readonly) CGFloat sk_top;
@property (nonatomic, readonly) CGFloat sk_bottom;
@property (nonatomic, readonly) CGFloat sk_width;
@property (nonatomic, readonly) CGFloat sk_height;
@property (nonatomic, readonly) CGFloat sk_posX;
@property (nonatomic, readonly) CGFloat sk_posY;
@end
#import "SKNode+Frame.h"
@implementation SKNode (Frame)
- (CGFloat)sk_left
{
return self.frame.origin.x;
}
- (CGFloat)sk_right
{
return self.frame.origin.x + self.frame.size.width;
}
- (CGFloat)sk_top
{
return self.frame.origin.y + self.frame.size.height;
}
- (CGFloat)sk_bottom
{
return self.frame.origin.y;
}
- (CGFloat)sk_width
{
return self.frame.size.width;
}
- (CGFloat)sk_height
{
return self.frame.size.height;
}
- (CGFloat)sk_posX
{
return self.position.x;
}
- (CGFloat)sk_posY
{
return self.position.y;
}
@end