Blame view

ios/Runner/Wowgame/WowGameClasses/WowGameViewController.mm 3.22 KB
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  //
  //  WowGameViewController.m
  //  Runner
  //
  //  Created by xiaoyu on 2024/4/16.
  //
  
  #import "WowGameViewController.h"
  #import "WowGameCocosManager.h"
  
  #import "cocos2d.h"
  #import "platform/ios/CCEAGLView-ios.h"
  
  @interface WowGameViewController ()
  
  @end
  
  @implementation WowGameViewController
  
  - (void)loadView {
      // Initialize the CCEAGLView
      CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [UIScreen mainScreen].bounds
                                           pixelFormat: (__bridge NSString *)cocos2d::GLViewImpl::_pixelFormat
                                           depthFormat: cocos2d::GLViewImpl::_depthFormat
                                    preserveBackbuffer: NO
                                            sharegroup: nil
                                         multiSampling: cocos2d::GLViewImpl::_multisamplingCount > 0 ? YES : NO
                                       numberOfSamples: cocos2d::GLViewImpl::_multisamplingCount ];
      
      // Enable or disable multiple touches
22495953   xiaoyu   打开多点触控,开启游戏时使用hud遮罩
31
      [eaglView setMultipleTouchEnabled:YES];
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
      
      // Set EAGLView as view of RootViewController
      self.view = eaglView;
  }
  
  - (void)viewDidLoad {
      [super viewDidLoad];
      // Do any additional setup after loading the view.
      
      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackgroundNotification) name:UIApplicationDidEnterBackgroundNotification object:nil];
      
      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillEnterForegroundNotification) name:UIApplicationWillEnterForegroundNotification object:nil];
  }
  
  - (void)applicationDidEnterBackgroundNotification {
  //    WowGameCocosManager.s
  }
  
  - (void)applicationWillEnterForegroundNotification {
      
  }
  
  - (void)viewWillAppear:(BOOL)animated {
      [super viewWillAppear:animated];
  }
  
  - (void)viewDidDisappear:(BOOL)animated {
      [super viewDidDisappear:animated];
  }
  
  // For ios6, use supportedInterfaceOrientations & shouldAutorotate instead
  #ifdef __IPHONE_6_0
  - (NSUInteger) supportedInterfaceOrientations{
      return UIInterfaceOrientationMaskLandscape;
  }
  #endif
  
  - (BOOL)shouldAutorotate {
      return YES;
  }
  
  - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
      [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
  
      auto glview = cocos2d::Director::getInstance()->getOpenGLView();
      if (glview){
          CCEAGLView *eaglview = (__bridge CCEAGLView *)glview->getEAGLView();
          if (eaglview) {
              CGSize s = CGSizeMake([eaglview getWidth], [eaglview getHeight]);
              cocos2d::Application::getInstance()->applicationScreenSizeChanged((int) s.width, (int) s.height);
          }
      }
  }
  
  //fix not hide status on ios7
  - (BOOL)prefersStatusBarHidden {
      return YES;
  }
  
  // Controls the application's preferred home indicator auto-hiding when this view controller is shown.
  - (BOOL)prefersHomeIndicatorAutoHidden {
      return YES;
  }
  
  - (void)didReceiveMemoryWarning {
      // Releases the view if it doesn't have a superview.
      [super didReceiveMemoryWarning];
  
      // Release any cached data, images, etc that aren't in use.
  }
  
  - (void)dealloc {
      [[NSNotificationCenter defaultCenter] removeObserver:self];
      NSLog(@"game view controller did dealloc");
  }
  
  @end