Skip to content

Commit e97c88a

Browse files
committed
Merge branch 'demo-dev' of https://github.com/firebase/quickstart-cpp into upstream/demo-dev
2 parents bccf52b + 4ee541b commit e97c88a

File tree

5 files changed

+101
-17
lines changed

5 files changed

+101
-17
lines changed

demos/TicTacToe/game_resources/Classes/main_menu_scene.cc

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ void MainMenuScene::InitializeFirebase() {
171171
// 5. Adds the logout button.
172172
void MainMenuScene::InitializeGameMenuLayer() {
173173
// Label to display the users record.
174-
user_record_label_ = Label::createWithSystemFont("", "Arial", 24);
174+
user_record_label_ =
175+
Label::createWithTTF("", "fonts/GoogleSans-Regular.ttf", 24);
175176
user_record_label_->setAlignment(TextHAlignment::RIGHT);
176177
user_record_label_->setTextColor(Color4B::WHITE);
177178
user_record_label_->setPosition(Vec2(500, 600));
@@ -180,7 +181,8 @@ void MainMenuScene::InitializeGameMenuLayer() {
180181
// Creates the join_text_field.
181182
auto join_text_field_position = Size(480, 95);
182183
auto join_text_field_size = Size(180, 80);
183-
auto join_text_field = TextField::create("code", "Arial", 48);
184+
auto join_text_field =
185+
TextField::create("code", "fonts/GoogleSans-Regular.ttf", 48);
184186
join_text_field->setPosition(join_text_field_position);
185187
join_text_field->setTouchSize(join_text_field_size);
186188
join_text_field->setTouchAreaEnabled(true);
@@ -309,13 +311,15 @@ void MainMenuScene::InitializeSignUpLayer() {
309311
this->addChild(sign_up_background_, /*layer_index=*/10);
310312

311313
// Creates the layer title label: sign up.
312-
auto layer_title = Label::createWithSystemFont("sign up", "Arial", 48);
314+
auto layer_title =
315+
Label::createWithTTF("sign up", "fonts/GoogleSans-Regular.ttf", 48);
313316
layer_title->setAnchorPoint(Vec2(.5, .5));
314317
layer_title->setPosition(Vec2(300, 475));
315318
sign_up_background_->addChild(layer_title);
316319

317320
// Label to output sign up errors.
318-
sign_up_error_label_ = Label::createWithSystemFont("", "Arial", 24);
321+
sign_up_error_label_ =
322+
Label::createWithTTF("", "fonts/GoogleSans-Regular.ttf", 24);
319323
sign_up_error_label_->setTextColor(Color4B::RED);
320324
sign_up_error_label_->setPosition(Vec2(300, 425));
321325
sign_up_background_->addChild(sign_up_error_label_);
@@ -324,7 +328,8 @@ void MainMenuScene::InitializeSignUpLayer() {
324328
const auto id_font_size = 28;
325329
const auto id_position = Size(300, 375);
326330
const auto id_size = Size(450, id_font_size * 1.75);
327-
sign_up_id_ = TextField::create("email", "Arial", id_font_size);
331+
sign_up_id_ =
332+
TextField::create("email", "fonts/GoogleSans-Regular.ttf", id_font_size);
328333
sign_up_id_->setPosition(id_position);
329334
sign_up_id_->setTouchAreaEnabled(true);
330335
sign_up_id_->setTouchSize(id_size);
@@ -355,8 +360,8 @@ void MainMenuScene::InitializeSignUpLayer() {
355360
const auto password_font_size = 28;
356361
const auto password_position = Size(300, 300);
357362
const auto password_size = Size(450, password_font_size * 1.75);
358-
sign_up_password_ =
359-
TextField::create("password", "Arial", password_font_size);
363+
sign_up_password_ = TextField::create(
364+
"password", "fonts/GoogleSans-Regular.ttf", password_font_size);
360365
sign_up_password_->setPosition(password_position);
361366
sign_up_password_->setTouchAreaEnabled(true);
362367
sign_up_password_->setTouchSize(password_size);
@@ -392,8 +397,9 @@ void MainMenuScene::InitializeSignUpLayer() {
392397
const auto password_confirm_position = Size(300, 225);
393398
const auto password_confirm_size =
394399
Size(450, password_confirm_font_size * 1.75);
395-
sign_up_password_confirm_ = TextField::create("confirm password", "Arial",
396-
password_confirm_font_size);
400+
sign_up_password_confirm_ =
401+
TextField::create("confirm password", "fonts/GoogleSans-Regular.ttf",
402+
password_confirm_font_size);
397403
sign_up_password_confirm_->setPosition(password_confirm_position);
398404
sign_up_password_confirm_->setTouchAreaEnabled(true);
399405
sign_up_password_confirm_->setTouchSize(password_confirm_size);
@@ -499,13 +505,15 @@ void MainMenuScene::InitializeLoginLayer() {
499505
this->addChild(login_background_, /*layer_index=*/10);
500506

501507
// Creates the layer title label: login.
502-
auto layer_title = Label::createWithSystemFont("Login", "Arial", 48);
508+
auto layer_title =
509+
Label::createWithTTF("Login", "fonts/GoogleSans-Regular.ttf", 48);
503510
layer_title->setAnchorPoint(Vec2(.5, .5));
504511
layer_title->setPosition(Vec2(300, 475));
505512
login_background_->addChild(layer_title);
506513

507514
// Label to output login errors.
508-
login_error_label_ = Label::createWithSystemFont("", "Arial", 24);
515+
login_error_label_ =
516+
Label::createWithTTF("", "fonts/GoogleSans-Regular.ttf", 24);
509517
login_error_label_->setTextColor(Color4B::RED);
510518
login_error_label_->setPosition(Vec2(300, 425));
511519
login_background_->addChild(login_error_label_);
@@ -514,7 +522,8 @@ void MainMenuScene::InitializeLoginLayer() {
514522
const auto id_font_size = 28;
515523
const auto id_position = Size(300, 375);
516524
const auto id_size = Size(450, id_font_size * 1.75);
517-
login_id_ = TextField::create("email", "Arial", id_font_size);
525+
login_id_ =
526+
TextField::create("email", "fonts/GoogleSans-Regular.ttf", id_font_size);
518527
login_id_->setPosition(id_position);
519528
login_id_->setTouchAreaEnabled(true);
520529
login_id_->setTouchSize(id_size);
@@ -545,7 +554,8 @@ void MainMenuScene::InitializeLoginLayer() {
545554
const auto password_font_size = 28;
546555
const auto password_position = Size(300, 300);
547556
const auto password_size = Size(450, password_font_size * 1.75);
548-
login_password_ = TextField::create("password", "Arial", password_font_size);
557+
login_password_ = TextField::create(
558+
"password", "fonts/GoogleSans-Regular.ttf", password_font_size);
549559
login_password_->setPosition(password_position);
550560
login_password_->setTouchAreaEnabled(true);
551561
login_password_->setTouchSize(password_size);
@@ -645,7 +655,8 @@ void MainMenuScene::InitializeAuthenticationLayer() {
645655
this->addChild(auth_background_, /*layer_index=*/10);
646656

647657
// Creates the layer title label: authentication.
648-
auto layer_title = Label::createWithSystemFont("authentication", "Arial", 48);
658+
auto layer_title = Label::createWithTTF("authentication",
659+
"fonts/GoogleSans-Regular.ttf", 48);
649660
layer_title->setPosition(Vec2(300, 550));
650661
auth_background_->addChild(layer_title);
651662

demos/TicTacToe/game_resources/Classes/tic_tac_toe_layer.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,14 +338,16 @@ void TicTacToeLayer::InitializeBoard() {
338338
// TODO(grantpostma@): Modify these numbers to be based on the extern window
339339
// size & label size dimensions.
340340
cocos2d::Label* game_uid_label =
341-
Label::createWithSystemFont(join_game_uid_, "Arial", 30);
341+
Label::createWithTTF(join_game_uid_, "fonts/GoogleSans-Regular.ttf", 30);
342342
game_uid_label->setPosition(Vec2(40, 20));
343343
board_sprite_->addChild(game_uid_label, /*layer_index=*/1);
344-
waiting_label_ = Label::createWithSystemFont("waiting", "Arial", 30);
344+
waiting_label_ =
345+
Label::createWithTTF("waiting", "fonts/GoogleSans-Regular.ttf", 30);
345346
waiting_label_->setPosition(Vec2(530, 20));
346347

347348
board_sprite_->addChild(waiting_label_, /*layer_index=*/1);
348-
game_over_label_ = Label::createWithSystemFont("", "Arial", 80);
349+
game_over_label_ =
350+
Label::createWithTTF("", "fonts/GoogleSans-Regular.ttf", 80);
349351
game_over_label_->setPosition(Vec2(300, 300));
350352
board_sprite_->addChild(game_over_label_, /*layer_index=*/1);
351353

Binary file not shown.
-760 KB
Binary file not shown.

demos/TicTacToe/readme.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
Firebase Cocos2d-x TicTacToe Sample
2+
==========================
3+
4+
Desktop cocos2d-x sample using Firebase Real-Time Database and Firebase Authentication.
5+
6+
Introduction
7+
------------
8+
9+
- [Read more about Firebase](https://firebase.google.com/docs)
10+
11+
Prerequisites
12+
-------------
13+
- [Cmake](https://cmake.org/download/) (Minimum 3.6)
14+
15+
- [Python 2.7](https://www.python.org/download/releases/2.7/)
16+
17+
- The latest version [of Cocos2d-x](https://cocos2d-x.org/download) (cocos environment variable must be added to PATH)
18+
19+
- [Firebase CPP SDK](https://cocos2d-x.org/download) (Must be add to path under FIREBASE_CPP_SDK_DIR)
20+
21+
- Windows: ([Visual Studio 2019](https://visualstudio.microsoft.com/downloads/))
22+
23+
Getting Started
24+
---------------
25+
26+
- Clone the firebase cpp quickstart GitHub repo.
27+
```
28+
git clone https://github.com/firebase/quickstart-cpp.git
29+
```
30+
31+
### Windows
32+
- Follow the steps in
33+
[Set up your app in Firebase console](https://firebase.google.com/docs/cpp/setup?platform=android#desktop-workflow).
34+
35+
- Place the google-services.json you just acquired in the demos/TicTacToe/google_services/ directory.
36+
37+
- Navigate to the directory that you just cloned, step into demos/TicTacToe/ and run the setup script.
38+
```
39+
python setup_demo.py
40+
```
41+
42+
- To debug with Visual Studio 2019, copy the google-services.json file into the tic_tac_toe_demo/build/ directory. Then open the .sln in that same directory in Visual Studio.
43+
44+
### How To Play
45+
46+
- After you have successfully run the setup_demo.py script, you can then launch the game by running the run_demo.py script. In order to test the multiplayer functionality, open up another terminal and launch a second instant of the game by running the run_demo.py script again.
47+
```
48+
python run_demo.py
49+
```
50+
51+
- Using the sign-up button or login button will link your record (Wins-Losses-Ties) to your account. The skip login button will not save your record between sessions.
52+
53+
- From the main menu screen, you can either create a game or join using a game code (displayed in the top-left corner of the game board). If you are running this demo yourself, have on instance create the game and join with your second game instance.
54+
55+
- After finishing the game, you will notice the record will update on the main menu to reflect the result of your most recent game.
56+
57+
Support
58+
-------
59+
60+
https://firebase.google.com/support/
61+
62+
License
63+
-------
64+
65+
Copyright 2020 Google, Inc.
66+
67+
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
68+
69+
http://www.apache.org/licenses/LICENSE-2.0
70+
71+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License..

0 commit comments

Comments
 (0)