STSpriteKit 0.4.0

STSpriteKit 0.4.0

测试已测试
Lang语言 Obj-CObjective C
许可 MIT
发布最新发布2014年12月

iSofTom维护。



  • 作者
  • iSofTom

SpriteKit 辅助工具和扩展。

视差效果

STParallaxNode 是一个节点,可以以高度定制的方式创建视差效果。

  • 它处理水平方向和垂直方向(但一次只处理一个)。
  • 你可以在视差节点上添加任意多个层级。
  • 你可以控制视差节点随时间变化的速度。
  • 每个层级都有其自己的速度因子。
  • 一个层级可以显示一个子节点。该子节点将在必要时被复制,也可能会在两次操作中按键一次。
  • 一个层级可显示多个子节点。拾取策略可以是循环(在数组顺序中)或随机。
  • 一个层级可以用不同的值来定位其子节点,包括从范围中随机选择的一个。
  • 层级的每个子节点之间的距离可以配置为从范围中随机选择的一个值。

控件

两个子类:STControlNode 和 STControlSprite 允许在你的节点上添加一些控制方法。

STControlNode

这些方法允许在检测到 touchUp 事件时发出警告。

- (void)setTouchUpTarget:(id)target action:(SEL)action;
- (void)setTouchUpBlock:(dispatch_block_t)touchUpBlock;

这些方法允许在检测到 touchDown 事件时发出警告。

- (void)setTouchDownTarget:(id)target action:(SEL)action;
- (void)setTouchDownBlock:(dispatch_block_t)touchDownBlock;

STControlSprite

这些方法允许在检测到 touchUpInside 事件时发出警告。

- (void)setTouchUpInsideTarget:(id)target action:(SEL)action;
- (void)setTouchUpInsideBlock:(dispatch_block_t)touchUpInsideBlock;

这些方法允许在检测到 touchUpOutside 事件时发出警告。

- (void)setTouchUpOutsideTarget:(id)target action:(SEL)action;
- (void)setTouchUpOutsideBlock:(dispatch_block_t)touchUpOutsideBlock;

这些方法允许在检测到 touchDown 事件时发出警告。

- (void)setTouchDownTarget:(id)target action:(SEL)action;
- (void)setTouchDownBlock:(dispatch_block_t)touchDownBlock;

发射器

这些方法允许轻松解档发射器资源。

+ (SKEmitterNode*)emitterWithResourceNamed:(NSString*)resourceName;
+ (SKEmitterNode*)emitterWithResourceNamed:(NSString*)resourceName inBundle:(NSBundle*)bundle;

动作

这个类别添加了一些运行动作的便利方法。

- (void)runActionsSequence:(NSArray*)actions;
- (void)runActionsSequenceForever:(NSArray*)actions;
- (void)runActionsGroup:(NSArray*)actions;
- (void)runActionsGroupForever:(NSArray*)actions;
- (void)runAction:(SKAction*)action afterDelay:(NSTimeInterval)delay;

SKScene

提出对 SKScene 的 nodeAtPoint: 方法的替代算法,以便将触摸传递到指定的节点,考虑到其 userInteractionEnabled 值。换句话说:如果节点的 userInteractionEnabled 值为 NO,则触摸将转发到下面的节点。

工具

增加了一些易于操作 CGPoint 和 CGSize 的功能。

使用方法

要将此组件包含到你的项目中,我建议你使用 Cocoapods

  • pod "STSpriteKit" 添加到您的 Podfile。