SKSpriteNode(精靈節(jié)點)
精靈節(jié)點充石,是一個2D紋理節(jié)點,在指定矩形區(qū)域內(nèi)快速顯示圖像霞玄。SKNode的子類骤铃。處理圖像和顏色的節(jié)點。
從圖像文件名創(chuàng)建精靈
- (instancetype)initWithImageNamed:(NSString *)name;//使用圖像文件初始化紋理精靈坷剧。
+ (instancetype)spriteNodeWithImageNamed:(NSString *)name normalMapped:(BOOL)generateNormalMap;//使用圖像文件初始化紋理精靈惰爬,可選擇添加法線貼圖來模擬 3D 照明。
從紋理創(chuàng)建精靈
- (instancetype)initWithTexture:(nullable SKTexture *)texture;//使用現(xiàn)有紋理對象初始化紋理精靈惫企。
- (instancetype)initWithTexture:(nullable SKTexture *)texture color:(SKColor *)color size:(CGSize)size;//用顏色和指定的邊界初始化精靈撕瞧。
- (instancetype)initWithColor:(SKColor *)color size:(CGSize)size;//用顏色和指定的邊界初始化精靈。
+ (instancetype)spriteNodeWithImageNamed:(NSString *)name;//使用圖像文件初始化紋理精靈狞尔。
+ (instancetype)spriteNodeWithTexture:(nullable SKTexture *)texture;//使用現(xiàn)有紋理對象初始化紋理精靈丛版。
+ (instancetype)spriteNodeWithTexture:(nullable SKTexture *)texture size:(CGSize)size;//使用現(xiàn)有的紋理對象初始化紋理精靈,但具有指定的大小偏序。
+ (instancetype)spriteNodeWithTexture:(nullable SKTexture *)texture normalMap:(nullable SKTexture *)normalMap;//使用法線貼圖初始化紋理精靈以模擬 3D 照明硼婿。
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder;//從存檔初始化精靈。
設(shè)置精靈的大小和位置
@property (nonatomic) CGSize size;//精靈的尺寸禽车,以點為單位寇漫。
- (void)scaleToSize:(CGSize)size;//大小縮放
@property (nonatomic) CGPoint anchorPoint;//用于在精靈中選擇映射到其父坐標(biāo)空間中的“位置”的位置。0.0-1.0
在九個部分縮放精靈
@property (nonatomic) CGRect centerRect;//拉伸紋理殉摔。拉伸采用9部分算法州胳。
給精靈著色
@property (nonatomic, retain) SKColor *color;//精靈的基本顏色。
@property (nonatomic) CGFloat colorBlendFactor;//控制紋理和精靈顏色之間的混合逸月。有效值的范圍是從0.0到(包括)1.0栓撞。
點亮精靈
@property (nonatomic) uint32_t lightingBitMask;//表示被一組使用重疊照明類別的燈照亮。使用此蒙版將類別設(shè)置為非零的值的燈將會給這個精靈添加光線。
@property (nonatomic) uint32_t shadowCastBitMask;//定義哪些燈光為精靈添加陰影的蒙版瓤湘。
@property (nonatomic) uint32_t shadowedBitMask;//定義此精靈遮擋哪些燈光的遮罩瓢颅。
@property (nonatomic, retain, nullable) SKTexture *normalTexture;//指定精靈的法線貼圖的紋理。這只會在精靈被至少一盞燈點亮?xí)r使用弛说。
向精靈添加自定義著色器
@property (nonatomic, retain, nullable) SKShader *shader;//定義執(zhí)行自定義每像素繪圖或著色的代碼的文本文件挽懦。
@property (nonatomic, nonnull, copy) NSDictionary<NSString *, SKAttributeValue *> *attributeValues;//與節(jié)點的附加著色器關(guān)聯(lián)的每個屬性的值。
- (void)setValue:(SKAttributeValue*)value forAttributeNamed:(nonnull NSString *)key;//設(shè)置附加著色器的屬性值木人。
- (nullable SKAttributeValue*)valueForAttributeNamed:(nonnull NSString *)key;//設(shè)置著色器屬性的值信柿。
SKLabelNode(使用指定的字體顯示文本標(biāo)簽)
+ (instancetype)labelNodeWithText:(nullable NSString *)text;//利用文字初始化
+ (instancetype)labelNodeWithAttributedText:(nullable NSAttributedString *)attributedText;//利用富文本初始化
+ (instancetype)labelNodeWithFontNamed:(nullable NSString *)fontName;//使用指定字體初始化一個新的標(biāo)簽對象。
- (instancetype)initWithFontNamed:(nullable NSString *)fontName;使用指定字體初始化一個新的標(biāo)簽對象醒第。
@property (nonatomic) SKLabelVerticalAlignmentMode verticalAlignmentMode;//節(jié)點內(nèi)文本的垂直位置渔嚷。
@property (nonatomic) SKLabelHorizontalAlignmentMode horizontalAlignmentMode;//節(jié)點內(nèi)文本的水平位置。
@property(nonatomic) NSInteger numberOfLines;//行數(shù)
@property(nonatomic) NSLineBreakMode lineBreakMode;//確定多行的換行模式稠曼。
@property(nonatomic) CGFloat preferredMaxLayoutWidth;//用于確定多行標(biāo)簽的布局寬度形病。
@property (nonatomic, copy, nullable) NSString *fontName;//字體
@property (nonatomic, copy, nullable) NSString *text;//文字
@property (nonatomic, copy, nullable) NSAttributedString *attributedText;//富文本
@property (nonatomic) CGFloat fontSize;//文字大小
@property (nonatomic, retain, nullable) SKColor *fontColor;//文字顏色
@property (nonatomic) CGFloat colorBlendFactor;//描述顏色如何與字體顏色混合。
@property (nonatomic, retain, nullable) SKColor *color;//用于動畫的字體顏色的替代方案霞幅。
@property (nonatomic) SKBlendMode blendMode;//用于將標(biāo)簽繪制到父級幀緩沖區(qū)的混合模式窒朋。
SKShapeNode(使用指定的路徑繪制或填充形狀)
從路徑創(chuàng)建形狀
+ (instancetype)shapeNodeWithPath:(CGPathRef)path;//從 Core Graphics 路徑創(chuàng)建形狀節(jié)點。
+ (instancetype)shapeNodeWithPath:(CGPathRef)path centered:(BOOL)centered;//從核心圖形路徑創(chuàng)建一個形狀節(jié)點蝗岖,以它的位置為中心侥猩。
從矩形創(chuàng)建形狀
+ (instancetype)shapeNodeWithRect:(CGRect)rect;//創(chuàng)建具有矩形路徑的形狀節(jié)點。
+ (instancetype)shapeNodeWithRectOfSize:(CGSize)size;//創(chuàng)建一個形狀節(jié)點抵赢,其矩形路徑以節(jié)點的原點為中心欺劳。
+ (instancetype)shapeNodeWithRect:(CGRect)rect cornerRadius:(CGFloat)cornerRadius;//創(chuàng)建一個帶有圓角矩形路徑的形狀。
+ (instancetype)shapeNodeWithRectOfSize:(CGSize)size cornerRadius:(CGFloat)cornerRadius;//創(chuàng)建一個帶有以節(jié)點位置為中心的圓角矩形路徑的形狀铅鲤。
創(chuàng)建圓形
+ (instancetype)shapeNodeWithCircleOfRadius:(CGFloat)radius;//創(chuàng)建一個形狀節(jié)點划提,其圓形路徑以節(jié)點的原點為中心。
創(chuàng)建橢圓形狀
+ (instancetype)shapeNodeWithEllipseInRect:(CGRect)rect;//創(chuàng)建一個形狀節(jié)點邢享,其橢圓路徑以節(jié)點的原點為中心鹏往。
+ (instancetype)shapeNodeWithEllipseOfSize:(CGSize)size;//使用填充指定矩形的橢圓路徑創(chuàng)建形狀節(jié)點。
從一組點創(chuàng)建一個形狀
+ (instancetype)shapeNodeWithPoints:(CGPoint *)points count:(size_t)numPoints;//從一系列點創(chuàng)建一個形狀節(jié)點骇塘。
+ (instancetype)shapeNodeWithSplinePoints:(CGPoint *)points count:(size_t)numPoints;//從一系列點創(chuàng)建一個形狀節(jié)點伊履。(拐點平滑)
填充形狀
@property (nonatomic, retain) SKColor *fillColor;//填充顏色
@property (nonatomic, retain, nullable) SKTexture *fillTexture;//用于填充形狀的紋理。
邊緣形狀
@property (nonatomic) CGFloat lineWidth;//邊緣寬度
@property (nonatomic, retain) SKColor *strokeColor;//邊緣顏色
@property (nonatomic, retain, nullable) SKTexture *strokeTexture;//用于描邊形狀的紋理款违。
@property (nonatomic) CGFloat glowWidth;//從描邊線向外延伸的光暈唐瀑。
@property (nonatomic) CGLineCap lineCap;//用于渲染形狀節(jié)點描邊部分端點的樣式。
@property (nonatomic) CGLineJoin lineJoin;渲染形狀節(jié)點的描邊部分時使用的連接類型插爹。
@property (nonatomic) CGFloat miterLimit;//使用斜接連接樣式描邊線時使用的斜接限制哄辣。
@property (nonatomic, getter = isAntialiased) BOOL antialiased;//用于確定繪制時是否平滑描邊路徑请梢。
配置 Alpha 混合
@property (nonatomic) SKBlendMode blendMode;//用于將標(biāo)簽繪制到父級幀緩沖區(qū)的混合模式。
控制或動畫描邊長度
@property (nonatomic, readonly) CGFloat lineLength;//如果要描邊力穗,節(jié)點的路徑長度
自定義描邊或填充繪圖
@property (nonatomic, retain, nullable) SKShader *strokeShader;//用于確定形狀節(jié)點描邊部分顏色的自定義著色器毅弧。
@property (nonatomic, retain, nullable) SKShader *fillShader;//用于確定形狀節(jié)點填充部分的顏色的自定義著色器。
@property (nonatomic, nonnull, copy) NSDictionary<NSString *, SKAttributeValue *> *attributeValues;//與節(jié)點的附加著色器關(guān)聯(lián)的每個屬性的值当窗。
- (nullable SKAttributeValue*)valueForAttributeNamed:(nonnull NSString *)key;//著色器屬性的值够坐。
- (void)setValue:(SKAttributeValue*)value forAttributeNamed:(nonnull NSString *)key;//設(shè)置附加著色器的屬性值。
SKVideoNode(視頻節(jié)點超全,提供視頻播放支持)
初始化方法
- (instancetype)initWithVideoFileNamed:(NSString *)videoFile;
+ (SKVideoNode *)videoNodeWithFileNamed:(NSString *)videoFile;//根據(jù)視屏文件初始化咆霜。
- (instancetype)initWithAVPlayer:(AVPlayer*)player;
+ (SKVideoNode *)videoNodeWithAVPlayer:(AVPlayer*)player;//根據(jù)現(xiàn)有播放器初始化邓馒。
- (instancetype)initWithURL:(NSURL *)url;
+ (SKVideoNode *)videoNodeWithURL:(NSURL *)videoURL;//根據(jù)URL初始化嘶朱。
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder;//告訴您何時初始化從存檔創(chuàng)建的視頻節(jié)點。
其他
- (void)play;//播放
- (void)pause;//暫停
@property (nonatomic) CGSize size;//尺寸
@property (nonatomic) CGPoint anchorPoint;//精靈中對應(yīng)于節(jié)點位置的點光酣。
SKEmitterNode(粒子發(fā)射器節(jié)點疏遏,提供粒子效果支持)
SKCropNode(裁剪組件,使用遮罩裁剪其內(nèi)部的子節(jié)點)
SKEffectNode(使用幀緩沖效果渲染節(jié)點結(jié)果救军,用于生成某一時刻的屏幕快照)
@property (nonatomic, retain, nullable) CIFilter *filter;//要應(yīng)用的核心圖像過濾器财异。
@property (nonatomic) BOOL shouldCenterFilter;//用于確定效果節(jié)點是否自動設(shè)置濾鏡的圖像中心。
@property (nonatomic) BOOL shouldEnableEffects;//用于確定效果節(jié)點是否在繪制其子項時對其應(yīng)用過濾器唱遭。
@property (nonatomic) BOOL shouldRasterize;//指示是否應(yīng)緩存渲染子節(jié)點的結(jié)果戳寸。
@property (nonatomic) SKBlendMode blendMode;//用于將節(jié)點的內(nèi)容繪制到其父級的幀緩沖區(qū)的混合模式。
@property (nonatomic, retain, nullable) SKShader *shader;//當(dāng)效果節(jié)點混合到父級的幀緩沖區(qū)時調(diào)用的自定義著色器拷泽。
@property (nonatomic, nonnull, copy) NSDictionary<NSString *, SKAttributeValue *> *attributeValues;//與節(jié)點的附加著色器關(guān)聯(lián)的每個屬性的值疫鹊。
- (nullable SKAttributeValue*)valueForAttributeNamed:(nonnull NSString *)key;//獲取著色器屬性的值。
- (void)setValue:(SKAttributeValue*)value forAttributeNamed:(nonnull NSString *)key;//設(shè)置附加著色器的屬性值司致。