Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
coderZsq committed Sep 14, 2020
1 parent 5c32a97 commit bef6c4c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 0 additions & 2 deletions SQNumbers/SQNumbers/SQSceneView.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ NS_ASSUME_NONNULL_BEGIN

@interface SQSceneView : UIView

@property (nonatomic, assign) NSUInteger capacity;

- (void)renderToCanvas:(UIView *)superView;

@end
Expand Down
22 changes: 20 additions & 2 deletions SQNumbers/SQNumbers/SQSceneView.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,23 @@
// Copyright © 2020 朱双泉. All rights reserved.
//

#import "SceneDelegate.h"
#import "SQSceneView.h"
#import "SQSpriteView.h"

@interface SQSceneView ()

@property (nonatomic, assign) NSInteger currnetLevel;

@end

@implementation SQSceneView

- (void)renderToCanvas:(UIView *)superView {
[superView addSubview:self];

NSInteger capacity = self.capacity ? self.capacity : 5;
self.currnetLevel += 1;
NSInteger capacity = arc4random_uniform(5) + 1;
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:capacity];

UIView *containerView = [UIView new];
Expand Down Expand Up @@ -63,7 +71,17 @@ - (void)renderToCanvas:(UIView *)superView {
}
}
if (successed) {
NSLog(@"游戏通关");
UIAlertController *altvc = [UIAlertController alertControllerWithTitle:@"闯关成功" message:[NSString stringWithFormat:@"恭喜你通过第%li关, 请进入第%li", self.currnetLevel, self.currnetLevel + 1] preferredStyle:UIAlertControllerStyleAlert];
[altvc addAction:[UIAlertAction actionWithTitle:@"好的" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
for (UIView *view in self.subviews) {
[view removeFromSuperview];
}
[self renderToCanvas:superView];
}]];
NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects];
UIWindowScene *windowScene = (UIWindowScene *)array.firstObject;
SceneDelegate *delegate = (SceneDelegate *)windowScene.delegate;
[delegate.window.rootViewController presentViewController:altvc animated:YES completion:nil];
}
};

Expand Down
1 change: 0 additions & 1 deletion SQNumbers/SQNumbers/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ - (void)viewDidLoad {

SQSceneView *sceneView = [SQSceneView new];
sceneView.frame = self.view.bounds;
sceneView.capacity = arc4random() % 6;
[sceneView renderToCanvas:self.view];

}
Expand Down

0 comments on commit bef6c4c

Please sign in to comment.