5daad4bc
xiaoyu
游戏源码添加编译(现存问题:游戏内...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
//
// AniSettingsLayer.cpp
// Steve and Maggie Halloween
//
// Created by Katarzyna Kalinowska-Górska on 06/10/2019.
//
#include <stdio.h>
#include "AniSettingsLayer.h"
#include "AniMiscUtils.h"
#include "AniScalingUtils.h"
#include "AniStrings.h"
#include "AniSimpleButton.h"
#include "AniKKGLinearLayout.h"
|
68a4c50a
xiaoyu
Merge remote-trac...
|
15
|
#include "AniAlertUtils.h"
|
5daad4bc
xiaoyu
游戏源码添加编译(现存问题:游戏内...
|
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
|
AniSettingsLayer* AniSettingsLayer::create(float width, float height, std::function<void(int)> onLevelPickedCallback, std::function<void()> onTutorialResetPickedCallback){
AniSettingsLayer * view = new (std::nothrow) AniSettingsLayer();
if(view && view->init(width, height, onLevelPickedCallback, onTutorialResetPickedCallback))
{
view->autorelease();
return view;
}
CC_SAFE_DELETE(view);
return nullptr;
}
bool AniSettingsLayer::init(float width, float height, std::function<void(int)> onLevelPickedCallback, std::function<void()> onTutorialResetPickedCallback){
if(!cocos2d::LayerColor::initWithColor(cocos2d::Color4B(0,0,0,230), width, height)){
return false;
}
_isPresentingParentalGate = false;
_onLevelPicked = onLevelPickedCallback;
_onTutorialReset = onTutorialResetPickedCallback;
AniKKGLinearLayout* container = AniKKGLinearLayout::create(AniKKGLinearLayout::LayoutType::VERTICAL,
AniKKGLinearLayout::Alignment::ACENTER,
AniKKGLinearLayout::Gravity::GCENTER);
addChild(container);
auto paddingTop = 50*AniScalingUtils::scaleAspectFillToDesignIpadProSize();
std::vector<std::string> levelImagePaths = { "graphics/levels/level_1.png", "graphics/levels/level_2.png", "graphics/levels/level_3.png" };
_AniLevelPickerView = AniLevelPickerView::create(levelImagePaths, std::vector<std::string>());
container->addView(_AniLevelPickerView);
_AniLevelPickerView->addOnLevelChangedCallback([&](int pickedLevel){
AniMiscUtils::saveLastLevel(pickedLevel);
_onLevelPicked(pickedLevel);
_AniLevelPickerView->setEnabled(false);
});
_AniLevelPickerView->selectLevelIndex((int)AniMiscUtils::lastLevel(), false);
_AniLevelPickerView->setAnchorPoint(cocos2d::Vec2(1, 0.5));
auto menuItemColor = cocos2d::Color3B(140, 140, 140);
cocos2d::MenuItemFont::setFontSize(120*AniScalingUtils::getScaleForFont()); //TODO MAGIC NUMBER
cocos2d::MenuItemFont::setFontName("fonts/ComicSansMSBold.ttf");
auto webLinkButton = AniSimpleButton::create();
container->addView(webLinkButton);
|
68a4c50a
xiaoyu
Merge remote-trac...
|
62
|
webLinkButton->setVisible(false);
|
5daad4bc
xiaoyu
游戏源码添加编译(现存问题:游戏内...
|
63
64
65
66
67
68
69
70
71
72
73
|
auto buttonTexturePath = "settings_buttons/steve_maggie.png";
webLinkButton->loadTextures(buttonTexturePath, buttonTexturePath, buttonTexturePath);
webLinkButton->setOnTouchEndedCallback([&, webLinkButton](std::string name, cocos2d::ui::Widget::TouchEventType eventType){
presentParentalGate([&](){
hideParentalGate();
cocos2d::Application::getInstance()->openURL("https://www.steveandmaggie.com"); //TODO hardcoded
}, [&](){
hideParentalGate();
});
});
|
68a4c50a
xiaoyu
Merge remote-trac...
|
74
75
|
|
5daad4bc
xiaoyu
游戏源码添加编译(现存问题:游戏内...
|
76
77
78
79
80
81
|
auto replayTutorialButton = AniSimpleButton::create();
addChild(replayTutorialButton);
auto repTutButtonTexturePath = "settings_buttons/play_preview_again.png";
replayTutorialButton->loadTextures(repTutButtonTexturePath, repTutButtonTexturePath, repTutButtonTexturePath);
replayTutorialButton->setScale(1.5f);
replayTutorialButton->setOriginalScale(1.5f);
|
68a4c50a
xiaoyu
Merge remote-trac...
|
82
83
84
85
|
auto pos_x = getContentSize().width-paddingTop-replayTutorialButton->getContentSize().width/2*1.5;
auto pos_y = getContentSize().height - paddingTop - replayTutorialButton->getContentSize().height*1.5/2;
replayTutorialButton->setPosition(cocos2d::Point(pos_x - 400 ,pos_y));
|
5daad4bc
xiaoyu
游戏源码添加编译(现存问题:游戏内...
|
86
87
88
|
replayTutorialButton->setOnTouchEndedCallback([&, replayTutorialButton](std::string name, cocos2d::ui::Widget::TouchEventType eventType){
_onTutorialReset();
});
|
68a4c50a
xiaoyu
Merge remote-trac...
|
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
auto appExitButton = AniSimpleButton::create();
addChild(appExitButton);
auto exitButtonTexturePath = "buttons/graphics/button_x.png";
appExitButton->loadTextures(exitButtonTexturePath, exitButtonTexturePath, exitButtonTexturePath);
appExitButton->setScale(1.5f);
appExitButton->setOriginalScale(1.5f);
appExitButton->setPosition(cocos2d::Point(getContentSize().width-paddingTop-appExitButton->getContentSize().width/2*1.5, pos_y));
appExitButton->setOnTouchEndedCallback([&, appExitButton](std::string name, cocos2d::ui::Widget::TouchEventType eventType){
AniAlertUtils::showAppCloseConfirmDialog([&](){
});
});
|
5daad4bc
xiaoyu
游戏源码添加编译(现存问题:游戏内...
|
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
auto menuPadding = 30*AniScalingUtils::scaleAspectFillToDesignIpadProSize();//TODO magic number
auto menuItemAbout = cocos2d::MenuItemFont::create("Terms of Use", CC_CALLBACK_1(AniSettingsLayer::aboutMenuButtonTapped, this));
auto menuItemPrivacyPolicy = cocos2d::MenuItemFont::create("Privacy Policy", CC_CALLBACK_1(AniSettingsLayer::privacyPolicyMenuButtonTapped, this));
auto menuCenter = cocos2d::Menu::create(menuItemAbout,menuItemPrivacyPolicy, NULL);
menuCenter->setContentSize(cocos2d::Size(MAX(menuItemAbout->getBoundingBox().size.width, menuItemPrivacyPolicy->getBoundingBox().size.width), menuItemAbout->getBoundingBox().size.height + menuItemPrivacyPolicy->getBoundingBox().size.height + 3*menuPadding));
menuCenter->setColor(menuItemColor);
menuCenter->alignItemsVerticallyWithPadding(menuPadding);
container->addView(menuCenter);//addChild(menuContainer, 3);
container->setInterViewMargin(paddingTop);
container->setCascadeOpacityEnabled(true);
container->wrapContents();
container->setPosition(getContentSize()/2);
container->setAnchorPoint(cocos2d::Point::ONE/2);
// adjust the weird menu post-layout // quick fix
menuCenter->setPositionY(webLinkButton->getBoundingBox().getMinY() - menuItemAbout->getBoundingBox().size.height - paddingTop);
|
22495953
xiaoyu
打开多点触控,开启游戏时使用hud遮罩
|
127
128
|
menuCenter->setVisible(false);
|
5daad4bc
xiaoyu
游戏源码添加编译(现存问题:游戏内...
|
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
return true;
}
void AniSettingsLayer::prepareForShowing(){
_AniLevelPickerView->selectLevelIndex((int)(AniMiscUtils::lastLevel()), false);
_AniLevelPickerView->setEnabled(true);
}
void AniSettingsLayer::aboutMenuButtonTapped(cocos2d::Ref* pSender){
presentParentalGate([&](){
hideParentalGate();
// cocos2d::Application::getInstance()->openURL(AniStrings::LINK_TERMS_OF_SERVICE);
cocos2d::Application::getInstance()->openURL("https://www.wattsenglish.com/steve-and-maggie-halloween/terms-of-use.html");
}, [&](){
hideParentalGate();
});
}
void AniSettingsLayer::privacyPolicyMenuButtonTapped(cocos2d::Ref* pSender){
presentParentalGate([&](){
hideParentalGate();
// cocos2d::Application::getInstance()->openURL(AniStrings::LINK_PRIVACY_POLICY);
cocos2d::Application::getInstance()->openURL("https://www.wattsenglish.com/steve-and-maggie-halloween/principles-of-personal-data-processing.html");
}, [&](){
hideParentalGate();
});
}
|