Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/insfgg99x/usaction
类似SpriteKit的SKAction,你可以在UIKit上使用USAction,用法同SpriteKit的SKAction
https://github.com/insfgg99x/usaction
Last synced: about 2 months ago
JSON representation
类似SpriteKit的SKAction,你可以在UIKit上使用USAction,用法同SpriteKit的SKAction
- Host: GitHub
- URL: https://github.com/insfgg99x/usaction
- Owner: Insfgg99x
- License: mit
- Created: 2018-09-19T08:14:41.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-19T08:34:17.000Z (over 6 years ago)
- Last Synced: 2024-10-30T03:42:20.566Z (about 2 months ago)
- Language: Objective-C
- Size: 569 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# USAction
类似SpriteKit的SKAction,你可以在UIKit上使用USAction,用法同SpriteKit的SKAction![](/src/drop.gif)
## 使用
### run
```swift
+ (instancetype)run:(void(^)(void))handler;
USAction *action = [USAction run:^{
//do something
}];
```### move
```swift
+ (instancetype)moveTo:(CGPoint)point duration:(NSTimeInterval)interval;
USAction *move = [USAction moveTo:CGPointZero duration:0.5];
```
### wait
```swift
+ (instancetype)wait:(NSTimeInterval)interval;
USAction *wait = [USAction wait:0.2];
```
### sequence
```swift
+ (instancetype)sequence:(NSArray *)actions;
USAction *sequence = [USAction sequence:@[action1, action2, action3]];
```
### repeat
```swift
+ (instancetype)repeat:(USAction *)action count:(NSInteger)count;
USAction *repeat = [USAction repeat:sequence count:25];
```### repeatForEver
```swift
+ (instancetype)repeatForEver:(USAction *)action;
USAction *repeat = [USAction repeatForEver:sequence];
```
### 嵌套示例
```swift
- (void)viewDidLoad {
[super viewDidLoad];USAction *add = [USAction run:^{
[self addNewNode];
}];
USAction *wait = [USAction wait:0.2];
USAction *sequence = [USAction sequence:@[add, wait]];
USAction *repeat = [USAction repeatForEver:sequence];
[self.view run:repeat];
}
- (void)addNewNode {
UIView *node = [self dropNode];
[self.view addSubview:node];
USAction *move = [USAction moveTo:CGPointMake(arc4random_uniform((int)self.view.bounds.size.width) + 1, self.view.bounds.size.height + 40) duration:4 + (arc4random_uniform(100) + 1)/ 100.f];
USAction *remove = [USAction run:^{
[node removeFromSuperview];
}];
USAction *combine = [USAction sequence:@[move, remove]];
[node run:combine];
}
- (UIView *)dropNode {
UIImageView *node = [[UIImageView alloc] initWithFrame:CGRectMake(arc4random_uniform((int)self.view.bounds.size.width) + 1, -40, 40, 40)];
node.image = [UIImage imageNamed:@"miss"];
return node;
}
```## 安装
```
pod repo update
pod 'USAction'
```