[MUSIC PLAYING]
CHRIS FOLEY: Hello.
Welcome to the Google Games Developer Summit.
And today, I will be talking a bit
about the practical considerations for developing
games for foldable devices.
My name is Chris Foley.
I'm a developer relations engineer with the Android Games
Developer Relations Team.
And before we get started, let me talk a little bit
about myself.
I've been in the game industry for quite a while,
over 20 years now.
I started out in console development,
and then I moved onto making PC games,
and then, eventually, mobile development.
And I have been working with mobile developers
for about the last 10 years or so.
Today, I wanted to talk to you about folding phones.
Now, if you're a game developer, you've
probably seen folding phones out there and said,
that's pretty neat.
But I think there's a lot of opportunities offered
by folding phones that I think would
be very interesting to a game developer.
So let's go into that a bit.
First of all, what are foldable devices, if you
haven't paid attention to them?
Well, devices with folding screens
first arrived on the market in 2018.
There was the Royole FlexPai, I think
was the name of the device.
The proposition is simple--
more screen real estate in the same size device
that you can just stick in your pocket.
At first, there were just a few devices.
And they were promising, but they were still
just the initial attempt.
But these days, we're beginning to see
more and more manufacturers come out with devices
using this form factor.
What can foldable phones do?
Why are they becoming more popular?
So the obvious thing is that they have two different types
of displays.
And the biggest one is the immersive, the large display,
versus an immediate, a small screen
display that comes right out of your pocket
is immediately available.
You can have shifting displays on the fly so that you have,
say, a game on one display.
You close it, it pops up on the other display.
Or it moves between displays.
All that tech is technically within what foldables can do.
You can have multiple combinations
of displays maybe all going at the same time.
Foldable displays, since you have that large real estate,
also give you the opportunity for things like multitasking,
for folded states such as having the open,
closed, or even half open states--
as you can see here on the right--
or split screens, where you have one app on one side and one
app doing on the other side.
And from the app's point of view,
it just looks like another display.
For this talk today, I want to talk about game design
considerations.
And here is why foldables are interesting for game
developers.
In my mind, it's because they open up
new opportunities for game design for developers
to take advantage of.
Now, I mentioned before that I worked in the console space
for a long time.
Now, in consoles, new generations of devices
were always really exciting and really
these new generations for consoles
were what drove the industry forward at the time.
And a big reason for that was because of new hardware
capabilities.
There was the addition of internet capability
at the time.
Of course, every generation comes with better graphics,
with more capable processors.
You also had the addition of controller feedback
so that you could actually get feedback
and feel something if you actually
did something in the game.
And then, microphones and headsets, of course,
also brought in a whole new aspect of gaming.
And these were all ways that let game developers create
ways for players to play games that they had never
done before.
Let me bring back to folding phones.
Now, I mentioned before that the most obvious advantage
that folding devices have, of course,
is the ability for a multiple size of displays
for the players to use.
So here's an example.
These are screenshots from a game,
and I will show a demo in a bit, but here's some screenshots.
On the left, you have a large immersive display.
You can see it's panoramic.
It's very pretty.
You have a nice cityscape.
It gives you full access to the screen.
I think the screen is about 2,200 pixels on a side here.
It's really pretty.
And it really gives you a lot of real estate for a developer
to really explore with.
And it's here, I am showing the whole game.
Now, on the right side is the same game.
But I have it here running on the folded aspect
of the phone which is approximately about
half the size that you can see on one dimension.
The other dimension is roughly the same length.
And you can see it's the same game.
And this one was what I call more immediate.
While the tablet is better if you're on a plane,
or if you're on a chair, if you're sitting where you have
both hands, where you can relax, the more immediate,
the folded version, is better if, say,
you only have one available.
So you have one hand on a strap on the subway.
Or, say, you just want to use one hand on your phone,
or you're on the go.
You're moving around.
You don't want to have the larger device out.
So that's the opportunity here.
Now, as you can see in my screenshots here,
we're going to get into the second consideration.
So if you see, if we're using a game with one hand,
you notice that my folding one--
here on the right--
I have these UI elements, these little arrows.
And I think you can barely--
maybe you can't even see them there.
And so I put the arrows on either side
of the screen, which is not a good decision if I wanted
to use this with one hand.
So this we'll get into a little bit
later about the types of considerations
that you need to make.
Another opportunity for game developers
for using foldable phones are new types of player engagement.
So for example, on the left, here
is a high score board in my game.
And high score boards are very popular with players.
They drive engagement.
People like to compete for them.
They're very interesting.
The problem is here, that on this display
with a folding phone, you just close the phone,
and that goes away.
But you now have a second screen available on the front.
So here's the opportunity.
When the player folds the device and the main screen goes away,
you could show the same game on the front of the screen
and maybe even have it in a different manner.
For example, suppose you had a racing
game on the large screen.
Then you fold it, and up comes a high score screen
on the outside.
So that a player can pull it out of their phone
and immediately see who is on the high score-- maybe
there's forums.
They can have chat.
They can have messages from the game.
So the point of this is that a folding device
adds the number of touchpoints that the player has
with your game.
And every touchpoint that the player has with your game
increases the likelihood that they will continue to play.
So you can take advantage of that
and come up with even more ideas.
What would you want to have a player look at your game--
if they could just take it out of the phone--
different from just playing the game normally?
And I think putting some thought into that might come up
with some neat ideas.
Another way that folding phones can really
advantage the game developer are new types of gameplay.
So instead of just adapting your existing games
or gameplay to a new format and figure
out how you can get it to try a new screen,
how about come up with a completely new type of game?
And I just mocked up the idea here.
But the minute I saw a phone in the half folded position--
this one, where the phone is in half folded there--
I immediately thought that this would
be perfect for some sort of head-to-head play.
If you can think back to the original Battleship game, where
you have two players, and they have the folded
device, and the folded thing, and they'd be marching,
you know, you sunk my Battleship.
It would be the same type of thing here.
Here, I would have a head-to-head racing game.
You could have your UI split up to have,
say, the top part of the phone be the game and the bottom part
be your controls.
Like, imagine my racing game here
if I had, say, racing controls down at the bottom,
or if it was an arcade game, I could put the joystick down
on the bottom half of the screen.
And it would be almost a way of turning the flat device
and really turning into more of an arcade type of machine.
So there's some new ideas for a game developer
on what you could do with this.
But what's it take?
What does it take for a game to support folding screens?
There's good news and there's bad news.
The good news is that folding phones
are represented by the OS as a configuration change.
And configuration changes are really nothing new
to an Android developer.
In fact, there's a very familiar configuration change,
which is switching between landscape and portrait.
Now, the bad news is that your game probably
doesn't support it yet.
So the reason why is that most game engines do not
support configuration changes such as switching
between landscape and portrait out of the box.
And most game developers haven't really been requiring that.
Because it does incur extra overhead
to support the two aspect ratios.
There are some extra code changes
that we're getting into.
But you'll see that most games do not support it.
Because when you try it on a folding device today, when
you change the display, the phone
might ask you if you want to restart,
as that's the typical behavior when a configuration
change is not supported.
So how do you add support?
Well, there are four easy steps for adding foldable support
to your game.
The first is to update your Android Manifest to support
configuration changes.
The second part is to handle those configuration changes
in code.
Now, as I mentioned before, most game engines
will not support configuration changes right out of the box.
It's not difficult. You usually just need
to add a module or something, or maybe write
a wrapper around some of the relevant Android code.
But it is something that you may have to add.
The third part is to save your UI state.
Now, this isn't strictly necessary
but it's a best practice.
Because during configuration change,
even going from landscape to folding,
or landscape to portrait, or switching
between screens on your phone, there
could always be something wrong.
Maybe the phone restarts.
Maybe the app crashes.
There could be something that goes on.
So it's just best if your UI is something
that is in a state that would need to be saved.
You should save your UI state before making the configuration
change.
And the last part--
and I threw this here at the end.
Because this is the most important although,
in reality, it's also the most time-intensive task.
And that is to make the game resizable, adding a dynamic
and resizable UI.
So let me talk a little bit about what
this looks like in code.
So the first step was to support configuration changes
in your Manifest.
Now, on here, I have a little sample.
This is actually from the game I've put together.
It's very simple.
You've seen this before.
Because, by default, Android destroys and restarts
the activity on a configuration change.
So you want to declare the activity element
in your Manifest, representing the configuration
change you want to support to prevent that restart.
And the most commonly used values that you'll see in this
will be orientation, which prevents
a restart on an orientation change from landscape
to portrait, screenSize, which does the same but for APIs
larger than 13 or post Android 3.2, screenLayout,
which is a configuration change triggered by foldable phones
and Chromebooks.
And then, another commonly used one--
although I don't use it here-- is keyboardHidden for keyboard
availability changes.
For my game, I wasn't using the keyboard.
It's not something I really wanted to ping.
So I don't pay attention to it.
And let me now show you what I'm talking about.
So here's my game that I put together.
It's a little racing game.
You can see, here you are moving into the distance, the city.
And I have a couple of UI elements here.
So I have these arrows that you can do to drive left or right--
like that.
And after adding some configuration changes
into the manifest, it made it so that I
can take my game, which is here running on the larger screen.
I fold it, and voila.
It's now playing on the secondary screen.
Now, you will notice one thing, though,
which is that the aspect ratios of these two screens
are not the same.
And Godot, which is the engine I was using here,
is able to handle that, no problem.
It's scaling the viewport appropriately
for the right size.
But that means my aspect ratios are not right.
And this gets into what is kind of the big change that you need
to make, which is supporting different screen
sizes, supporting different aspect ratios.
To really support foldables, you need
to be able to support your multiple screen sizes.
In your activity, you need to tell the Android
that it's a resizable activity so you
can support multi-window mode.
There are also some extra flags that you
can add for declaring your maximum and minimum aspect
ratio, which may be useful.
Say that you're happy to have the game modify its UI,
but maybe not infinitely so.
So, for example, you could set your maximum aspect ratio to 1
to force portrait mode in your game even if they have,
say, a widescreen display if your game has been
optimized for portrait mode.
So it's a little tip there.
Now I made some changes into my game as well.
Now one further thing you need to do
to support foldable devices is supporting the configuration
changes in code.
And as I mentioned earlier, you can save and restore
game states, which is best practices.
Supporting the layout changes as dimension changes,
though, is the major thing that you
need to do here-- and other UI changes as well.
And, really, dynamically changing your UI
or supporting different layouts is something
that you need to put a lot of design effort into.
And this is really where I spend a lot of time on my game.
So one thing that I do on my game
is, I actually check the screen size with every single frame.
So instead of setting up a listener
to check for explicit configuration changes,
I actually just do it on the fly.
And here, I have an example here from my code,
showing an example of dynamic scaling orientation.
Every frame, I look at the display width and height
that it's currently rendering to.
If it's larger than 0.6 for width divided by height,
then I declare that to be landscape orientation.
And I have to scale some parts of my UI differently.
Now, in portrait orientation, you see I have--
if it's in portrait mode, then I scale
by a different amount, which I've decided
is best for a portrait type of display.
Show a little bit about what that looks like here.
Here, again, another version of the game.
I changed the car to blue here.
And, once again, there it is on the main screen.
And then, this time, I close it.
Now, here, you'll notice that I've made some changes
to my aspect ratios here.
The car on the bottom, particularly, you'll see is--
it looks a lot smaller, but it's actually now the right aspect
ratio.
It doesn't look like a giant, squished blob.
I've changed some of the aspect ratios on there.
So this was all done on the fly.
And watch, I can even open it up, and flip it around.
And there we are, back to the original game.
So we can flip back and forth.
Because I'm just supporting all this
and dynamically changing how I render,
how I scale my UI elements on the fly.
Now, the last thing that I wanted to do
was to take my game and not just support two screens,
but I was unhappy about this.
So in fact, I also added the ability-- and Godot
made this really easy.
And as I said, different engines handle this differently.
Godot actually handles the landscape-portrait change
very easily.
And so as a result, I took my game.
I made a third version that supports
all everything that could possibly
do to go with the screen.
And here we are, back to the red car.
And show that we change.
We have the aspect ratios.
I think I made the car a little bit bigger
in this one to make it a little bit more visible.
But even better, it now supports,
even, portrait mode on the tiny display.
Now, you notice here, I've dynamically
resized all my UI elements.
The arrows on the left are now much bigger.
The car is much larger.
You can see the scaling of the background
has changed a little bit.
I actually put some thought into it
so that when we were in portrait mode,
I actually hide a lot of the grass
on either side to make sure that you can actually
see more of what I see as the gameplay, which
is the car in the middle of it.
And so, as you can see, I can flip around
and support all sorts of different aspect ratios.
In conclusion, talking a little bit about games
on foldable devices.
What is it that you need to do to support them?
And foldable devices offer the opportunity
for new games and gameplay.
And for a game developer, it's kind of a brand new, open field
to try out new designs.
Support for folding devices is actually quite easy
to add to your game.
It may be not provided by default.
You might have to add a little bit of code.
But it's actually not very difficult.
Flexible UIs and layouts require design and tech.
And those can be more effort.
And especially if you're working on your tools for your artists
or coming up with new ways to automatically
layout or to build the game, build or integrate new assets.
But that technology can be reused,
which will be important as we move into the future
where there are more foldable devices.
For mobile phones, we'll probably
have more and more displays.
There are other devices out there
that are maybe of different form factors
that we have not seen yet.
And this flexible technology will definitely have benefits.
And then, lastly, again, look at foldables as the chance
to explore games on a brand new form factor, brand
new hardware, and really maybe be the first one
to invent something brand-new for the world of games.
For more information, you can go to the link here
to learn about games on foldables.
I hope you enjoy the rest of the GDS Conference.
Again, my name is Chris Foley.
I'm a DevRel engineer with the Android Games Developer
Relations Team.
And thank you for watching.
[MUSIC PLAYING]