JXNewPackRainVc.m 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // JXNewPackRainVc.m
  3. // shiku_im
  4. //
  5. // Created by 123 on 2020/6/13.
  6. // Copyright © 2020 Reese. All rights reserved.
  7. //
  8. #import "JXNewPackRainVc.h"
  9. #import "LNNumberScrollAnimatedView.h"
  10. #import <AVFoundation/AVFoundation.h>
  11. @interface JXNewPackRainVc ()<AVAudioPlayerDelegate>
  12. @property (nonatomic ,strong) LNNumberScrollAnimatedView *socreTensDigitAnimation;
  13. @property (nonatomic ,strong) LNNumberScrollAnimatedView *socreDigitAnimation;
  14. @property (nonatomic ,strong) LNNumberScrollAnimatedView *socreAnimation;
  15. @property (nonatomic, strong) NSMutableArray *playerArr;
  16. @property (nonatomic, strong) AVAudioPlayer *numberPlayer;
  17. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *topViewLineHH;
  18. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *imageHHH;
  19. @end
  20. @implementation JXNewPackRainVc
  21. - (NSMutableArray *)playerArr
  22. {
  23. if (_playerArr == nil) {
  24. _playerArr = [[NSMutableArray alloc] init];
  25. }
  26. return _playerArr;
  27. }
  28. - (void)viewDidLoad {
  29. [super viewDidLoad];
  30. // Do any additional setup after loading the view, typically from a nib.
  31. self.view.backgroundColor = [UIColor whiteColor];
  32. [self defineNavBar:@"红包雨" andRinghtBtnImg:@""];
  33. UIImageView *topIMG = [[UIImageView alloc]initWithFrame:CGRectMake(0, JX_SCREEN_TOP,JX_SCREEN_WIDTH, JX_SCREEN_WIDTH)];
  34. topIMG.image=[UIImage imageNamed:@"mm_Lh"];
  35. [self.view addSubview:topIMG];
  36. //个位十位单独设置,可分别设定各自速度 //WithFrame:CGRectMake(100, 100, 152 , 172)
  37. LNNumberScrollAnimatedView *socreTensDigitAnimation = [[LNNumberScrollAnimatedView alloc] initWithFrame:CGRectMake((JX_SCREEN_WIDTH)/2-152/4, (JX_SCREEN_WIDTH)/2-172/4, 152/2 , 172/2)];
  38. [topIMG addSubview:socreTensDigitAnimation];
  39. socreTensDigitAnimation.density = 7;
  40. socreTensDigitAnimation.duration = 1.9;
  41. socreTensDigitAnimation.minLength = 1;
  42. [socreTensDigitAnimation setValue:@9];
  43. [socreTensDigitAnimation sizeToFit];
  44. socreTensDigitAnimation.isAscending = YES;
  45. socreTensDigitAnimation.durationOffset = 0.1;
  46. self.socreTensDigitAnimation = socreTensDigitAnimation;
  47. }
  48. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
  49. {
  50. for (int i = 0; i<19; i++) {
  51. [self performSelector:@selector(playSound) withObject:nil afterDelay:0.1];
  52. }
  53. [self.socreTensDigitAnimation setValue:[NSNumber numberWithInt:2]];
  54. [self.socreTensDigitAnimation startAnimation];
  55. [self.socreAnimation startAnimation];
  56. }
  57. #pragma mark - 播放音效
  58. - (void)playSound
  59. {
  60. NSURL *url = [[NSBundle mainBundle] URLForResource:@"number.wav" withExtension:nil];
  61. SystemSoundID soundID = 0;
  62. AudioServicesCreateSystemSoundID((__bridge CFURLRef)(url)
  63. , &soundID);
  64. AudioServicesPlayAlertSound (soundID);
  65. }
  66. - (void)didReceiveMemoryWarning {
  67. [super didReceiveMemoryWarning];
  68. // Dispose of any resources that can be recreated.
  69. }
  70. @end