How do i make a character selection screen

Hi Guys, my name is Neel Dave and i was wondering how do i make a character selection screen, i have looked online and i couldn’t find any ways then i have a big brainwave and thought of using themes a boy/ girl theme which you could pick from, so i looked online and found nothing, so if someone could help me please reply

thanks Neel Dave

You could make a series of buttons with images on them. Put the buttons in a grid or on a scrollview (if you want a lot of them to scroll through). You could take a table of data, display 1 image that takes up almost a whole device screen based on 1 element of data and put in swipe detection to swipe through the characters with a single button at the bottom for selection and some arrows to browse through the characters rather than swiping.

Character Selection isn’t a technical problem. There are an infinite number of ways to make it work.

What do you want to see? How is it supposed to work? What do you start with? You need to design what you want before asking how to do it.

Hi, thanks for the reply, I’m trying to make an app which allows you to pick a character and play on with that character through out the adventure/story, so my game first starts with menu, then play button then it comes with a screen which should allow you to pick a character boy or girl. then from their, i want the one which was picked by the player to carry one playing the game with that character, how do i do that ? I’m confused on how i would code it from picking the character onwards.

I’ve attached some pictures showing it so far, so how do i code from picking the character to playing the game with the character which was selected at first.

thanks Neel Dave

This process of “picking a character” is really part of a larger question about something called “gamestate” or “client gamestate”. How do you track what is going on in the game at any given time, including offscreen status of objects and environment, previous choices, etc.

Different people recommend various approaches.

Generally, you need to be familiar with the following concepts, for starters:

serialization

deserialization

files (reading and writing)

databases

global variables

lua tables

Serialization is the ability to turn data into a format that you can write to a file or to a database or a single variable.

Deserialization is the ability to go the other way and convert a format into a complex object.

I recommend Json via the require(“json”) wherein you get  json.encode and json.decode

You have access to temporaryDirectory files and more via various Corona APIs.

Some libraries like (I’ve seen) Preferences.lua writes serialized values for you and pulls out deserialized data, but you can do it yourself however you like. Files/DB/Hardcoded Globals have different tradeoffs. I rely on DB+Globals

Corona gives you access to the sqlite db included on both iOS and Android. I believe Nook and Kindle have one as well, but I haven’t tested.

Lastly you should understand that Lua Tables { … } is the data structure of choice. It is for arrays and for hashmaps and for objects. So you are usually creating tables then serializing and deserializing them.

I like to use the storyboard module in main.lua like so:

s = require(“storyboard”)

then I create a global table:

-- Now I can put whatever I want in here. s.g = { character = nil, otherdata = nil, -- I have a list of levels I want to keep track of! listoflevels = { [1] = "Start", [2] = "Candyland", [3] = "Chutes and Ladders", [4] = "Mouse Trap", }, }

s.g.character = “boy”

Now I can reference s.g.character from anywhere.

Global variables are how I maintain client gamestate. Sometimes I write json.encoded data to the client Database and pull it out when the app starts up because changed data in a global variable does not persist/write automatically when the app shuts down.

You could make a series of buttons with images on them. Put the buttons in a grid or on a scrollview (if you want a lot of them to scroll through). You could take a table of data, display 1 image that takes up almost a whole device screen based on 1 element of data and put in swipe detection to swipe through the characters with a single button at the bottom for selection and some arrows to browse through the characters rather than swiping.

Character Selection isn’t a technical problem. There are an infinite number of ways to make it work.

What do you want to see? How is it supposed to work? What do you start with? You need to design what you want before asking how to do it.

Hi, thanks for the reply, I’m trying to make an app which allows you to pick a character and play on with that character through out the adventure/story, so my game first starts with menu, then play button then it comes with a screen which should allow you to pick a character boy or girl. then from their, i want the one which was picked by the player to carry one playing the game with that character, how do i do that ? I’m confused on how i would code it from picking the character onwards.

I’ve attached some pictures showing it so far, so how do i code from picking the character to playing the game with the character which was selected at first.

thanks Neel Dave

This process of “picking a character” is really part of a larger question about something called “gamestate” or “client gamestate”. How do you track what is going on in the game at any given time, including offscreen status of objects and environment, previous choices, etc.

Different people recommend various approaches.

Generally, you need to be familiar with the following concepts, for starters:

serialization

deserialization

files (reading and writing)

databases

global variables

lua tables

Serialization is the ability to turn data into a format that you can write to a file or to a database or a single variable.

Deserialization is the ability to go the other way and convert a format into a complex object.

I recommend Json via the require(“json”) wherein you get  json.encode and json.decode

You have access to temporaryDirectory files and more via various Corona APIs.

Some libraries like (I’ve seen) Preferences.lua writes serialized values for you and pulls out deserialized data, but you can do it yourself however you like. Files/DB/Hardcoded Globals have different tradeoffs. I rely on DB+Globals

Corona gives you access to the sqlite db included on both iOS and Android. I believe Nook and Kindle have one as well, but I haven’t tested.

Lastly you should understand that Lua Tables { … } is the data structure of choice. It is for arrays and for hashmaps and for objects. So you are usually creating tables then serializing and deserializing them.

I like to use the storyboard module in main.lua like so:

s = require(“storyboard”)

then I create a global table:

-- Now I can put whatever I want in here. s.g = { character = nil, otherdata = nil, -- I have a list of levels I want to keep track of! listoflevels = { [1] = "Start", [2] = "Candyland", [3] = "Chutes and Ladders", [4] = "Mouse Trap", }, }

s.g.character = “boy”

Now I can reference s.g.character from anywhere.

Global variables are how I maintain client gamestate. Sometimes I write json.encoded data to the client Database and pull it out when the app starts up because changed data in a global variable does not persist/write automatically when the app shuts down.