SpriteKit-(SKNode)
2024-08-21 06:14:58
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;
最新文章
- 原生JS投票特效
- delphi实现的RTMP播放
- wex5 教程 之 图文讲解 登陆,注册,页面跳转
- location.reload()加载时有弹出框
- struts2 笔记03 异常支持、防止页面刷新和后退、方法验证
- 忘记 oracle11g 的 sys 密码的处理
- include<;stdio.h>; 和include<;iostream.h>;的区别
- 使用node js 操作 Mysql 数据库
- POJ 3169 Layout (差分约束)
- POJ 1502 MPI Maelstrom (最短路)
- 关于FileOutputStream的问题
- ppss
- 关于JAVA面向对象基础整理以及个人的理解(适合初学者阅读)
- angularjs 实现排序功能
- Java 9 揭秘(2. 模块化系统)
- Gym 100952E&;&;2015 HIAST Collegiate Programming Contest E. Arrange Teams【DFS+剪枝】
- FJUT16级第一周寒假作业题解J题
- Python面向对象——基本继承
- tarjan——cogs 1298 通讯问题
- Netty中解码基于分隔符的协议和基于长度的协议