Commit 22495953e9be03eb76ca6d14f4579b5d3fb62078

Authored by xiaoyu
1 parent d28ecdb0

打开多点触控,开启游戏时使用hud遮罩

ios/Podfile
@@ -33,6 +33,7 @@ target 'Runner' do @@ -33,6 +33,7 @@ target 'Runner' do
33 use_frameworks! 33 use_frameworks!
34 use_modular_headers! 34 use_modular_headers!
35 pod 'SingSoundSDK' 35 pod 'SingSoundSDK'
  36 + pod 'DMProgressHUD'
36 37
37 flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 38 flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
38 target 'RunnerTests' do 39 target 'RunnerTests' do
ios/Runner/Runner-Bridging-Header.h
@@ -4,4 +4,3 @@ @@ -4,4 +4,3 @@
4 4
5 #import "WowGameCocosManager.h" 5 #import "WowGameCocosManager.h"
6 6
7 -#import <WXApi.h>  
ios/Runner/Wowgame/Classes/game_animal/AniSettingsLayer.cpp
@@ -124,6 +124,8 @@ bool AniSettingsLayer::init(float width, float height, std::function&lt;void(int)&gt; @@ -124,6 +124,8 @@ bool AniSettingsLayer::init(float width, float height, std::function&lt;void(int)&gt;
124 // adjust the weird menu post-layout // quick fix 124 // adjust the weird menu post-layout // quick fix
125 menuCenter->setPositionY(webLinkButton->getBoundingBox().getMinY() - menuItemAbout->getBoundingBox().size.height - paddingTop); 125 menuCenter->setPositionY(webLinkButton->getBoundingBox().getMinY() - menuItemAbout->getBoundingBox().size.height - paddingTop);
126 126
  127 + menuCenter->setVisible(false);
  128 +
127 return true; 129 return true;
128 } 130 }
129 131
ios/Runner/Wowgame/Classes/game_food/SettingsLayer.cpp
@@ -144,6 +144,8 @@ bool SettingsLayer::init(float width, float height, std::function&lt;void(int)&gt; onL @@ -144,6 +144,8 @@ bool SettingsLayer::init(float width, float height, std::function&lt;void(int)&gt; onL
144 144
145 menuCenter->setPosition(lowerStuffContainer->getContentSize().width/2, lowerStuffContainer->getContentSize().height/2); 145 menuCenter->setPosition(lowerStuffContainer->getContentSize().width/2, lowerStuffContainer->getContentSize().height/2);
146 146
  147 + menuCenter->setVisible(false);
  148 +
147 wholeContainer->setContentSize(cocos2d::Size(getContentSize().width, upperStuffContainer->getContentSize().height + lowerStuffContainer->getContentSize().height + paddingBottom + paddingTop)); 149 wholeContainer->setContentSize(cocos2d::Size(getContentSize().width, upperStuffContainer->getContentSize().height + lowerStuffContainer->getContentSize().height + paddingBottom + paddingTop));
148 wholeContainer->setAnchorPoint(cocos2d::Vec2(0.5, 0.5)); 150 wholeContainer->setAnchorPoint(cocos2d::Vec2(0.5, 0.5));
149 wholeContainer->setPosition(width/2, height/2); 151 wholeContainer->setPosition(width/2, height/2);
ios/Runner/Wowgame/Classes/game_halloween/HSettingsLayer.cpp
@@ -99,6 +99,8 @@ bool HSettingsLayer::init(float width, float height, std::function&lt;void(int)&gt; on @@ -99,6 +99,8 @@ bool HSettingsLayer::init(float width, float height, std::function&lt;void(int)&gt; on
99 99
100 menuCenter->setPosition(lowerStuffContainer->getContentSize().width/2, lowerStuffContainer->getContentSize().height/2); 100 menuCenter->setPosition(lowerStuffContainer->getContentSize().width/2, lowerStuffContainer->getContentSize().height/2);
101 101
  102 + menuCenter->setVisible(false);
  103 +
102 wholeContainer->wrapContents(); 104 wholeContainer->wrapContents();
103 wholeContainer->setAnchorPoint(cocos2d::Vec2(0.5, 0.5)); 105 wholeContainer->setAnchorPoint(cocos2d::Vec2(0.5, 0.5));
104 wholeContainer->setPosition(width/2, height/2); 106 wholeContainer->setPosition(width/2, height/2);
ios/Runner/Wowgame/Classes/game_toy/ToySettingsLayer.cpp
@@ -109,6 +109,8 @@ bool ToySettingsLayer::init(float width, float height, std::function&lt;void(int)&gt; @@ -109,6 +109,8 @@ bool ToySettingsLayer::init(float width, float height, std::function&lt;void(int)&gt;
109 109
110 menuCenter->setPosition(lowerStuffContainer->getContentSize().width/2, lowerStuffContainer->getContentSize().height/2); 110 menuCenter->setPosition(lowerStuffContainer->getContentSize().width/2, lowerStuffContainer->getContentSize().height/2);
111 111
  112 + menuCenter->setVisible(false);
  113 +
112 wholeContainer->setContentSize(cocos2d::Size(getContentSize().width, upperStuffContainer->getContentSize().height + lowerStuffContainer->getContentSize().height + paddingTop)); 114 wholeContainer->setContentSize(cocos2d::Size(getContentSize().width, upperStuffContainer->getContentSize().height + lowerStuffContainer->getContentSize().height + paddingTop));
113 wholeContainer->setAnchorPoint(cocos2d::Vec2(0.5, 0.5)); 115 wholeContainer->setAnchorPoint(cocos2d::Vec2(0.5, 0.5));
114 wholeContainer->setPosition(width/2, height/2); 116 wholeContainer->setPosition(width/2, height/2);
ios/Runner/Wowgame/WowGameClasses/WowGameCocosManager.mm
@@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
10 #include "cocos2d.h" 10 #include "cocos2d.h"
11 11
12 #import "CocosAppDelegate.h" 12 #import "CocosAppDelegate.h"
  13 +#import <DMProgressHUD.h>
13 14
14 @interface WowGameCocosManager () { 15 @interface WowGameCocosManager () {
15 cocos2d::Application *_app; 16 cocos2d::Application *_app;
@@ -50,10 +51,24 @@ static CocosAppDelegate cocosAppDelegate; @@ -50,10 +51,24 @@ static CocosAppDelegate cocosAppDelegate;
50 [self.gameViewController dismissViewControllerAnimated:YES completion:nil]; 51 [self.gameViewController dismissViewControllerAnimated:YES completion:nil];
51 } 52 }
52 53
  54 +static DMProgressHUD *hud;
53 - (void)runGame:(NSInteger)gameid { 55 - (void)runGame:(NSInteger)gameid {
54 UIWindow *window = UIApplication.sharedApplication.delegate.window; 56 UIWindow *window = UIApplication.sharedApplication.delegate.window;
55 UIViewController *rootvc = window.rootViewController; 57 UIViewController *rootvc = window.rootViewController;
56 - if ([rootvc isKindOfClass:WowGameViewController.class]) { 58 +
  59 + hud = [DMProgressHUD showHUDAddedTo:window maskType:DMProgressHUDMaskTypeClear];
  60 + hud.loadingType = DMProgressHUDLoadingTypeIndicator;//默认
  61 + hud.text = @"Waiting...";
  62 +
  63 + if ([rootvc isKindOfClass:WowGameViewController.class] ||
  64 + [rootvc.presentedViewController isKindOfClass:WowGameViewController.class]) {
  65 + if ([NSThread isMainThread]) {
  66 + [hud dismiss];
  67 + } else {
  68 + dispatch_async(dispatch_get_main_queue(), ^{
  69 + [hud dismiss];
  70 + });
  71 + }
57 return; 72 return;
58 } 73 }
59 if (!self.gameViewController) { 74 if (!self.gameViewController) {
@@ -67,6 +82,13 @@ static CocosAppDelegate cocosAppDelegate; @@ -67,6 +82,13 @@ static CocosAppDelegate cocosAppDelegate;
67 } else { 82 } else {
68 cocos2d::Director::getInstance()->resume(); 83 cocos2d::Director::getInstance()->resume();
69 } 84 }
  85 + if ([NSThread isMainThread]) {
  86 + [hud dismiss];
  87 + } else {
  88 + dispatch_async(dispatch_get_main_queue(), ^{
  89 + [hud dismiss];
  90 + });
  91 + }
70 92
71 [rootvc presentViewController:self.gameViewController animated:YES completion:nil]; 93 [rootvc presentViewController:self.gameViewController animated:YES completion:nil];
72 94
ios/Runner/Wowgame/WowGameClasses/WowGameViewController.mm
@@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
28 numberOfSamples: cocos2d::GLViewImpl::_multisamplingCount ]; 28 numberOfSamples: cocos2d::GLViewImpl::_multisamplingCount ];
29 29
30 // Enable or disable multiple touches 30 // Enable or disable multiple touches
31 - [eaglView setMultipleTouchEnabled:NO]; 31 + [eaglView setMultipleTouchEnabled:YES];
32 32
33 // Set EAGLView as view of RootViewController 33 // Set EAGLView as view of RootViewController
34 self.view = eaglView; 34 self.view = eaglView;