Discuss Scratch

Dabkatt_furrygamer
Scratcher
4 posts

Hello, I was just wondering how to make a character select screen.

So i'm making an online game where you can choose a character and have a custom name. I always seem to have trouble with the characters being chosen. I can't figure out a code. Any help?

(also if you could help with custom names above characters that would be neat)

Last edited by Dabkatt_furrygamer (Sept. 30, 2020 15:16:14)

TechPandaPro
Scratcher
99 posts

Hello, I was just wondering how to make a character select screen.

Is the character in the same pose throughout the whole game? If so, you can do something like this for every character:
whenthisspriteclicked with "this sprite" being the button that selects the characterswitchcostumetoGiraffe Or whatever costume it is

This is a very generalized solution and will only work for certain purposes and in certain situations. If it doesn't fit your project the way you want, just say so.

Hope this helps!
TechPandaPro
GlueGourmand
Scratcher
100+ posts

Hello, I was just wondering how to make a character select screen.

Let's split your question into the two parts… how do I do a character select screen, and how do I implement custom names?

The character select screen is the less challenging part. Make a global variable tracking which character is selected, and clear or reset it to default when the script starts. Show the relevant sprites, and listen for either a click in a specific area or a key to be pressed. When one of these actions occurs, update global variable and launch the actual gameplay. If you want a simple example of sprite based menus, check out the demonstration here: https://scratch.mit.edu/projects/430392139/ Note that this is only a prototype, but it should give an example of how to do menu based selection of characters, levels, etc.

The custom character names is more challenging. Part of the challenge is from encoding and decoding the name data using one of your (precious) 10 cloud variables. Part of the challenge is preventing abuse of the name system. If you allow entirely user entered names for your game, consider what words might be entered by a malicious player. Censored examples include KillAll*********, UseMore*******, and **********. You cannot stop this from happening, especially wh3n p30ple g3t cr34tive. One easy solution is to have a list of names for the player to choose. They don't get a ‘fully custom’ name, but they get some choice. At the same time, you solve every problem listed in this paragraph.

I'm in the middle of a game with the same issue, and for names I'll be allowing only usernames and preselected names defined by me. Keep us posted on the project and on your progress.

Happy (Ethical) Hacking,
–GG

Powered by DjangoBB