Discuss Scratch

PuppyDragon624
Scratcher
2 posts

How do I make a character choosing system in my game?

Hi. I'm looking for help. It would be nice if you could.

Also I'm making it on my other account, KittyDragon624.

Last edited by PuppyDragon624 (April 13, 2023 23:41:07)

souleymane2
Scratcher
100+ posts

How do I make a character choosing system in my game?

Hey heres what i recommend for character choosing

First of all, create a characters sprite. As costumes make every button that you would need to select a character. Name the buttons .charname. So assuming you wanted a stickman character and a ninja character, id name the costume with the stickman button .stickman and the costume with the ninja .ninja

First we want to hide the main sprite like so:

when green flag clicked
hide

Afterwards, create a custom block like so:

when green flag clicked
hide


define clone (clonetype) at: (x) (y)
set [clonetype v] to (clonetype) // make sure clonetype is "for this sprite only"
go to x: (x) y: (y)
create clone of [myself v]

This will allow you to create as many clones as you want using this costum block. Going back to my example earlier we can use the block to create the buttons wherever we want on the screen like so:

when green flag clicked
hide
clone [ninja] at: (-100) (0)
clone [stickman] at: (100) (0)

define clone (clonetype) at: (x) (y)
set [clonetype v] to (clonetype)
go to x: (x) y: (y)
create clone of [myself v]

Now we want to make sure the clones will show and have the right costumes. This can be done very simply like so:

when green flag clicked
hide
clone [ninja] at: (-100) (0)
clone [stickman] at: (100) (0)

define clone (clonetype) at: (x) (y)
set [clonetype v] to (clonetype)
go to x: (x) y: (y)
create clone of [myself v]

when I start as a clone
show
(join [.] (clonetype)) // scratch has an issue where it dosnt allow me to put this join block in the switch costume one. Just place it in
switch costume to [ v]

If done correctly you should have sprites with the buttons you made for your characters inside of them. Now all we need to do, is allow the characters to be chosen using buttons:

when green flag clicked
hide
clone [ninja] at: (-100) (0)
clone [stickman] at: (100) (0)

define clone (clonetype) at: (x) (y)
set [clonetype v] to (clonetype)
go to x: (x) y: (y)
create clone of [myself v]

when I start as a clone
show
switch costume to [ v]
forever
if <touching [mousepointer v] ?> then
set [brightness v] effect to (25)
if <mouse down> then
set [chosenChar v] to (clonetype) // chosenChar has to be for every sprite
end
else
set [brightness v] effect to (0)
end
end

Finally we can delete the clones and send a message out to every sprite that the character has been chosen like this:


when green flag clicked
hide
clone [ninja] at: (-100) (0)
clone [stickman] at: (100) (0)

define clone (clonetype) at: (x) (y)
set [clonetype v] to (clonetype)
go to x: (x) y: (y)
create clone of [myself v]

when I start as a clone
show
switch costume to [ v]
forever
if <touching [mousepointer v] ?> then
set [brightness v] effect to (25)
if <mouse down> then
set [chosenChar v] to (clonetype) // chosenChar has to be for every sprite
broadcast [CharacterChosen! v]
end
else
set [brightness v] effect to (0)
end
end

when I receive [CharacterChosen! v]
delete this clone

And there you go! You should be set to create your characters.
Spentine
Scratcher
1000+ posts

How do I make a character choosing system in my game?

Before you make the character choosing system, make sure your game can handle different characters.
deck26
Scratcher
1000+ posts

How do I make a character choosing system in my game?

My first question would be whether the different characters are costumes of one sprite or different sprites.

The former saves you having to duplicate scripts and keep them in sync and can still be used if each character has several costumes. Choosing one character could be done by creating one clone of each to detect the user clicking to choose or you can make a ‘selection’ costume which shows all the options and just work out where the user clicked within the costume.

Different sprites is easy for selection but make sure all the scripts are stopped on any sprite not selected and they don't respond to broadcasts.

As you can probably tell I prefer the single sprite version.
PuppyDragon624
Scratcher
2 posts

How do I make a character choosing system in my game?

I'm doing one character, but you have to click on it to make it switch.

Last edited by PuppyDragon624 (April 26, 2023 15:17:10)

randomdude73636
Scratcher
7 posts

How do I make a character choosing system in my game?

If you need a simpler method, here i will use a mage character.

when this sprite clicked
broadcast [mage]
and for the character,
when I receive [mage]
switch costume to [mage]
create multiple costumes of different characters and for the buttons they will be different sprites

Last edited by randomdude73636 (May 1, 2023 07:48:35)

Eevee_poke_girl
Scratcher
3 posts

How do I make a character choosing system in my game?

PLS Help me too
kyla-2013
New Scratcher
9 posts

How do I make a character choosing system in my game?

hi im doing that thing where u do arrows to change each characters costume. and it is working, but i need a simple way to be able to go onto the previous costume easily using a diffrent arrow. Any form of answer will be great

Powered by DjangoBB