YOUPAIRCDDanmakuManager.m 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // YOUPAIRCDDanmakuManager.m
  3. // DanMuDemo
  4. //
  5. // Created by Sin on 16/9/26.
  6. // Copyright © 2016年 Sin. All rights reserved.
  7. //
  8. #import "YOUPAIRCDDanmakuManager.h"
  9. @interface YOUPAIRCDDanmakuManager ()
  10. @end
  11. @implementation YOUPAIRCDDanmakuManager
  12. + (instancetype)sharedManager {
  13. static YOUPAIRCDDanmakuManager *manger = nil;
  14. static dispatch_once_t onceToken;
  15. dispatch_once(&onceToken, ^{
  16. manger = [[self alloc]init];
  17. });
  18. return manger;
  19. }
  20. - (void)reset {
  21. self.danmakus = [[NSMutableArray alloc]init];
  22. self.subDanmakuInfos = [[NSMutableArray alloc]init];
  23. self.linesDict = [[NSMutableDictionary alloc]init];
  24. self.centerTopLinesDict = [[NSMutableDictionary alloc]init];
  25. self.centerBottomLinesDict = [[NSMutableDictionary alloc]init];
  26. self.currentDanmakuCache = [[NSMutableArray alloc]init];
  27. self.duration = 5;
  28. self.centerDuration = 2.5;
  29. self.specialDuration = 2.5;
  30. self.lineHeight = 25;
  31. self.maxShowLineCount = 15;
  32. self.maxCenterLineCount = 5;
  33. self.isAllowOverLoad = NO;
  34. self.isPlaying = YES;
  35. }
  36. - (instancetype)init
  37. {
  38. self = [super init];
  39. if (self) {
  40. [self reset];
  41. }
  42. return self;
  43. }
  44. - (void)setIsAllowOverLoad:(BOOL)isAllowOverLoad {
  45. //如果过量加载切换为缓存加载,那么需要将弹道清空,否则会一直碰撞
  46. if(_isAllowOverLoad && !isAllowOverLoad) {
  47. [self.linesDict removeAllObjects];
  48. }
  49. _isAllowOverLoad = isAllowOverLoad;
  50. }
  51. @end