zoukankan      html  css  js  c++  java
  • SpriteKit-(SKNode)

    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;
  • 相关阅读:
    Chrome插件开发,美化网页上的文件列表。chrome-extension,background
    Chrome插件开发,美化网页上的文件列表。chrome-extension,content-scripts
    ASP.NET MVC 常用扩展点:过滤器、模型绑定等
    Windows下Redis缓存服务器的使用 .NET StackExchange.Redis Redis Desktop Manager
    企业号微信支付 公众号支付 H5调起支付API示例代码 JSSDK C# .NET
    分享一个html+js+ashx+easyui+ado.net权限管理系统
    ASP.NET MVC Filters 4种默认过滤器的使用【附示例】
    ASP.NET MVC Controllers and Actions
    玩转控件:Fucking ERP之流程图
    玩转控件:对Dev的GridControl控件扩展
  • 原文地址:https://www.cnblogs.com/hxwj/p/5369040.html
Copyright © 2011-2022 走看看