1.初始化
+ (instancetype)node; + (nullable instancetype)nodeWithFileNamed:(NSString*)filename;
2.返回边界边框
- (CGRect)calculateAccumulatedFrame;
3.坐标
//节点的父节点的位置坐标系统 @property (nonatomic) CGPoint position; //z值的节点(用于排序)。负z是”到“屏幕,正面屏幕的z是“出去”。更大的zPosition将面前的一个较小的zPosition排序。 @property (nonatomic) CGFloat zPosition; //绕z轴旋转(弧度) @property (nonatomic) CGFloat zRotation; //x比例 @property (nonatomic) CGFloat xScale; //y比例 @property (nonatomic) CGFloat yScale;
4.一些属性
//速度 @property (nonatomic) CGFloat speed; //透明度 @property (nonatomic) CGFloat alpha; //控制节点的行为是否更新或暂停 @property (nonatomic, getter = isPaused) BOOL paused //是否隐藏 @property (nonatomic, getter = isHidden) BOOL hidden; //控制节点是否接收触摸事件 @property (nonatomic, getter=isUserInteractionEnabled) BOOL userInteractionEnabled; //父节点 @property (nonatomic, readonly, nullable) SKNode *parent; //子节点 @property (nonatomic, readonly) NSArray<SKNode*> *children; //节点名称 @property (nonatomic, copy, nullable) NSString *name; //节点所在的场景 @property (nonatomic, readonly, nullable) SKScene* scene; //物理身体连接的节点,同步,旋转,和地位 @property (nonatomic, retain, nullable) SKPhysicsBody *physicsBody; //一个可选的字典,可用于您自己的数据存储在一个节点。默认为零。 @property (nonatomic, retain, nullable) NSMutableDictionary *userData; //运动学约束,用于解决本土知识 @property (nonatomic, copy, nullable) SKReachConstraints *reachConstraints; //可选的一系列SKConstraints和物理约束是评估每一帧后操作。节点的转换将被改变,以满足约束条件。 @property (nonatomic, copy, nullable) NSArray<SKConstraint*> *constraints;
5.设置x,y的大小
- (void)setScale:(CGFloat)scale;
6.添加删除,移动,遍历精灵
- (void)addChild:(SKNode *)node; - (void)insertChild:(SKNode *)node atIndex:(NSInteger)index; - (void)removeChildrenInArray:(NSArray<SKNode*> *)nodes; - (void)removeAllChildren; - (void)removeFromParent; - (void)moveToParent:(SKNode *)parent; - (nullable SKNode *)childNodeWithName:(NSString *)name; - (void)enumerateChildNodesWithName:(NSString *)name usingBlock:(void (^)(SKNode *node, BOOL *stop))block;
7.如果有父节点
- (BOOL)inParentHierarchy:(SKNode *)parent;
8.运行动作,获取动作,移除动作
- (void)runAction:(SKAction *)action; - (void)runAction:(SKAction *)action completion:(void (^)())block; - (void)runAction:(SKAction *)action withKey:(NSString *)key; - (BOOL)hasActions; - (nullable SKAction *)actionForKey:(NSString *)key; - (void)removeActionForKey:(NSString *)key; - (void)removeAllActions;
9.填写坐标返回上面的精灵
- (BOOL)containsPoint:(CGPoint)p; - (SKNode *)nodeAtPoint:(CGPoint)p; - (NSArray<SKNode*> *)nodesAtPoint:(CGPoint)p;
10.移动精灵
- (CGPoint)convertPoint:(CGPoint)point fromNode:(SKNode *)node; - (CGPoint)convertPoint:(CGPoint)point toNode:(SKNode *)node;
11.插入精灵
- (BOOL)intersectsNode:(SKNode *)node;
12.两个精灵是否相同
- (BOOL)isEqualToNode:(SKNode *)node;
13.GKPolygonObstacle
/* Returns an array of GKPolygonObstacles from a group of SKSpriteNode‘s textures in scene space. For use with GPObstacleGraph in GameplayKit */ + (NSArray<GKPolygonObstacle*> *)obstaclesFromSpriteTextures:(NSArray<SKNode*>*)sprites accuracy:(float)accuracy; /* Returns an array of GKPolygonObstacles from a group of SKNode‘s transformed bounds in scene space. For use with GPObstacleGraph in GameplayKit */ + (NSArray<GKPolygonObstacle*> *)obstaclesFromNodeBounds:(NSArray<SKNode*>*)nodes; /* Returns an array of GKPolygonObstacles from a group of SKNode‘s physics bodies in scene space. For use with GPObstacleGraph in GameplayKit */ + (NSArray<GKPolygonObstacle*> *)obstaclesFromNodePhysicsBodies:(NSArray<SKNode*>*)nodes;
14,获取触碰精灵的位置
- (CGPoint)locationInNode:(SKNode *)node;
时间: 2024-11-05 18:28:27