Saving The Score

8 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€65.44
List Price:  €93.49
You save:  €28.05
£56.04
List Price:  £80.06
You save:  £24.02
CA$95.74
List Price:  CA$136.79
You save:  CA$41.04
A$107.11
List Price:  A$153.03
You save:  A$45.91
S$95.36
List Price:  S$136.24
You save:  S$40.87
HK$547.90
List Price:  HK$782.75
You save:  HK$234.85
CHF 64.03
List Price:  CHF 91.47
You save:  CHF 27.44
NOK kr772.60
List Price:  NOK kr1,103.76
You save:  NOK kr331.16
DKK kr487.88
List Price:  DKK kr697.01
You save:  DKK kr209.12
NZ$117.84
List Price:  NZ$168.36
You save:  NZ$50.51
د.إ257.06
List Price:  د.إ367.25
You save:  د.إ110.18
৳7,700.43
List Price:  ৳11,001.09
You save:  ৳3,300.65
₹5,837.33
List Price:  ₹8,339.41
You save:  ₹2,502.07
RM333.81
List Price:  RM476.90
You save:  RM143.08
₦92,489.99
List Price:  ₦132,134.22
You save:  ₦39,644.23
₨19,474.37
List Price:  ₨27,821.72
You save:  ₨8,347.35
฿2,588.61
List Price:  ฿3,698.17
You save:  ฿1,109.56
₺2,275.23
List Price:  ₺3,250.47
You save:  ₺975.23
B$358.08
List Price:  B$511.57
You save:  B$153.48
R1,312.98
List Price:  R1,875.77
You save:  R562.78
Лв127.91
List Price:  Лв182.73
You save:  Лв54.82
₩96,452.39
List Price:  ₩137,795.03
You save:  ₩41,342.64
₪267.73
List Price:  ₪382.49
You save:  ₪114.75
₱4,034.64
List Price:  ₱5,764.02
You save:  ₱1,729.38
¥11,065.06
List Price:  ¥15,807.91
You save:  ¥4,742.85
MX$1,201.03
List Price:  MX$1,715.83
You save:  MX$514.80
QR255.05
List Price:  QR364.38
You save:  QR109.32
P965.79
List Price:  P1,379.76
You save:  P413.97
KSh9,296.24
List Price:  KSh13,280.92
You save:  KSh3,984.67
E£3,349.82
List Price:  E£4,785.67
You save:  E£1,435.84
ብር3,985.10
List Price:  ብር5,693.24
You save:  ብር1,708.14
Kz58,375.85
List Price:  Kz83,397.65
You save:  Kz25,021.80
CLP$66,375.71
List Price:  CLP$94,826.51
You save:  CLP$28,450.80
CN¥507.11
List Price:  CN¥724.48
You save:  CN¥217.36
RD$4,113.13
List Price:  RD$5,876.15
You save:  RD$1,763.02
DA9,392.53
List Price:  DA13,418.47
You save:  DA4,025.94
FJ$158.35
List Price:  FJ$226.22
You save:  FJ$67.87
Q544.06
List Price:  Q777.27
You save:  Q233.20
GY$14,678.83
List Price:  GY$20,970.66
You save:  GY$6,291.82
ISK kr9,837.79
List Price:  ISK kr14,054.59
You save:  ISK kr4,216.80
DH708.72
List Price:  DH1,012.51
You save:  DH303.78
L1,246.75
List Price:  L1,781.16
You save:  L534.40
ден4,025.16
List Price:  ден5,750.48
You save:  ден1,725.31
MOP$565.76
List Price:  MOP$808.27
You save:  MOP$242.50
N$1,340.22
List Price:  N$1,914.68
You save:  N$574.46
C$2,582.07
List Price:  C$3,688.83
You save:  C$1,106.76
रु9,353.99
List Price:  रु13,363.42
You save:  रु4,009.42
S/263.57
List Price:  S/376.55
You save:  S/112.97
K270.82
List Price:  K386.91
You save:  K116.08
SAR262.50
List Price:  SAR375.01
You save:  SAR112.51
ZK1,859.31
List Price:  ZK2,656.27
You save:  ZK796.96
L325.94
List Price:  L465.65
You save:  L139.71
Kč1,644.39
List Price:  Kč2,349.23
You save:  Kč704.84
Ft25,720.62
List Price:  Ft36,745.32
You save:  Ft11,024.70
SEK kr762.14
List Price:  SEK kr1,088.81
You save:  SEK kr326.67
ARS$61,174.36
List Price:  ARS$87,395.69
You save:  ARS$26,221.33
Bs486.59
List Price:  Bs695.16
You save:  Bs208.56
COP$277,528.94
List Price:  COP$396,486.91
You save:  COP$118,957.97
₡35,172.98
List Price:  ₡50,249.28
You save:  ₡15,076.29
L1,732.56
List Price:  L2,475.19
You save:  L742.63
₲520,857.74
List Price:  ₲744,114.38
You save:  ₲223,256.64
$U2,703.34
List Price:  $U3,862.08
You save:  $U1,158.74
zł282.38
List Price:  zł403.41
You save:  zł121.03
Already have an account? Log In

Transcript

Hello, welcome to the 16th tutorial in the cocoa studio, the c++ series. In this part we'll be looking at save the score. We'll be continuing on as usual from the previous part of the series. If you don't have the source code for that, don't worry, there'll be a link in the description to the source code. Okay, we can play a game that allows us to earn points and display the score on the game. Obviously, it doesn't check out so score against the previous score, and doesn't provide any saving functionality which the original Flappy Bird does.

Fortunately, saving simple information such as a high score, it's really easy. In our game, I've seen a CBP job before we print out the scores. We will love the previous high school so basically now in the game, I was in that game scene. Yeah, literally here just before this will be checking. We'll load up the previous school. First we will create a user default variable that allows us to read and write data from the storage area, this is the work for iOS and Android.

We don't have to say why iOS do this and Android do this, try and get this direct trade. We just use this bit of code, like sprites, pretty much. So we're going to use float. And it's going to call it depth equals user default color comma shared view the default it's known in that it is deprecated. I believe the non deprecated version in get instance. There we go.

You will narrow it with the old school Buffy to like this. We will just have zero water or ice go equals F get integer for key I'm going to use a default value or aka if you can't find default value will just return the value that will specify which will be zero. And for this, we're going to look at the ind for high school. This isn't shared between application so your application will have a separate area for storing data. So if you have high score and you have another application called essays, getting get data from high school, it will be unique, which is pretty cool. So for the default value locks, zero, semicolon.

Now we will check if our current score is higher than the high school and if it is the high school will be updated and saved. So don't do pace. Gold is greater than high school. We will say High School and that equals score. def. Set into the 4k.

And for this we just put High School make sure it's the same as this. What we could do actually Amelie Our next task for you is actually abstract this into a hash define that way you can easily change it if you need to do the sort of stuff which really make use of definitions. Same with paths as well like this, this plug in and leave that for you. And for the valley that we're going to save with a poor High School semicolon. I'm finding listening to end user default file we need to flush it so let's do d f. flourish run into this when you're finished with it, it can create a new one and nothing stopping you from do that. Finally, we'll create a high score label similar to what we've done here.

To display the high score basically 700 underscore underscore string. class to temp, voice go to posts go to equal underscore underscore string colon colon create with format format when to put percent or a high score semi colon, auto high school label equals label. Tt create and without going to create with temp, boys school, get C string and for the Font Name we're going to do the same appear so that is formed for slash mark out TT here. And now for the side we're going to be visible foid dot height score form size. Luckily what we've done here so it's dynamic a, the size looks good on different screen sizes aka retina non retina for example. And now what we're going to do is do High School labor Set color.

This is just so we can distinguish the regular school and the high school two color three, a yellow and a high school label. Set vision point the board up with the point seven five plus origin got it for the wildland the visible size dot height divided by two or three. Why? And what we've done here here we positioned in 25% among you position the high school labor now set foot center long so it's been the high school I mean, the current school level will be on the left Costco labor will be on the right turn. Now the last thing to do is add This label of a child the layers of high school label. Actually, you know what I will do that no particular reason why I'm doing this Tom's gonna call this high school floppy.

Again, there's literally no reason why I am. It's just something that I've found like doing and I will click play. Once you run which we had to play again, when we get some school if it's greater than our current high school or our previous High School, it will load it, save it and it will display the scores accordingly. So this is loading. Let's just wait for a moment. Sorry about that.

Okay, here we go. The playbook So let's score a point or another point, and then that's done on purpose, we get to two, if we click retry, and it's going to die without actually scoring a point I think zero to the previous go ahead and say but now in the Maquis beat my score to seven This is get free and I'll probably die after that. And then you can see that he will update the score. Get for one there we go is updated the score and score our current score. That is it for this tutorial in the next part could we are almost done with this game. Got one nothing to do and that is to add orders at the moment.

It's very dry. Obviously there's no signs going up. I sometimes will have make it a lot better. But that's for the next part of the series. If you have any questions, feel free to message us at support at sonar systems. Dakota, UK the email will be in the description.

Can comment on this video with direct messages via YouTube, or the recording for source code will also be the description and as usual, thanks for watching and I hope you have a great day.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.