Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Hii! So a question
- kuku_the_cockatiel
-
Scratcher
35 posts
Hii! So a question
SOoo I'm making a rpg dungeon type game and I am trying to made a character selection screen but i'm not sure how. I've tried following youtube tutorials but I was really confused…
- MasterofTheBrick
-
Scratcher
1000+ posts
Hii! So a question
There are many different design concepts for selection menus. Iit would be helpful if you could direct us to a particular selection screen that you got inspiration from or you are trying to follow.
Each character in the selection pane should be a sprite. Use the “wait until clicked on” blocks to detect which character the player had chosen.
Each character in the selection pane should be a sprite. Use the “wait until clicked on” blocks to detect which character the player had chosen.
wait until <mouse down?>
if <touching [mouse pointer v] ?> then
this character was chosen ::grey
else
another character was chosen :: grey
end
Last edited by MasterofTheBrick (June 25, 2021 08:41:38)
- kuku_the_cockatiel
-
Scratcher
35 posts
Hii! So a question
There are many different design concepts for selection menus. Iit would be helpful if you could direct us to a particular selection screen that you got inspiration from or you are trying to follow.I am really just going for a simple selection screen. And ty for the code i'll try it!
Each character in the selection pane should be a sprite. Use the “wait until clicked on” blocks to detect which character the player had chosen.wait until <mouse down?>
if <touching [mouse pointer v] ?> then
this character was chosen ::grey
else
another character was chosen :: grey
end
- kuku_the_cockatiel
-
Scratcher
35 posts
Hii! So a question
There are many different design concepts for selection menus. Iit would be helpful if you could direct us to a particular selection screen that you got inspiration from or you are trying to follow.and what's the this character was chosen block? Sorry for all these questions I'm a new scratcher and this is my second game and third project.
Each character in the selection pane should be a sprite. Use the “wait until clicked on” blocks to detect which character the player had chosen.wait until <mouse down?>
if <touching [mouse pointer v] ?> then
this character was chosen ::grey
else
another character was chosen :: grey
end
- deck26
-
Scratcher
1000+ posts
Hii! So a question
But if the choice of character is essentially between costumes for a single sprite you can use cloning or stamping to select one. That at least saves duplicating code for different sprites. Still possible to have a group of costumes for each one for basic animation.
Here's an example https://scratch.mit.edu/projects/41719938/
Here's an example https://scratch.mit.edu/projects/41719938/
- kuku_the_cockatiel
-
Scratcher
35 posts
Hii! So a question
But if the choice of character is essentially between costumes for a single sprite you can use cloning or stamping to select one. That at least saves duplicating code for different sprites. Still possible to have a group of costumes for each one for basic animation.But each sprite has movement costumes.
Here's an example https://scratch.mit.edu/projects/41719938/
- MasterofTheBrick
-
Scratcher
1000+ posts
Hii! So a question
Then initiate the movement using variables.
if <(avatar) = [1]> then
Movement for avatar 1 ::grey
else
if <(avatar) = [2]> then
Movement for avatar 2 ::grey
else
And so on :: grey
end
end
Last edited by MasterofTheBrick (June 25, 2021 09:08:25)
- MasterofTheBrick
-
Scratcher
1000+ posts
Hii! So a question
But if the choice of character is essentially between costumes for a single sprite you can use cloning or stamping to select one. That at least saves duplicating code for different sprites. Still possible to have a group of costumes for each one for basic animation.
Here's an example https://scratch.mit.edu/projects/41719938/
Yes, didn’t think of that sooner. Thanks for bringing it up.
- deck26
-
Scratcher
1000+ posts
Hii! So a question
How many? If the code is otherwise the same it's easier to keep it all in one sprite rather then duplicate which would mean every change having to be copied multiple times.But if the choice of character is essentially between costumes for a single sprite you can use cloning or stamping to select one. That at least saves duplicating code for different sprites. Still possible to have a group of costumes for each one for basic animation.But each sprite has movement costumes.
Here's an example https://scratch.mit.edu/projects/41719938/
It's not hard to work with a range of costumes - eg if you have 10 costumes per character you can easily set a variable to 0 or 10 or 20 etc and use that as an adjustment. So switch to costume ‘myvar’ + 5 would give costume 5 or 15 or 25 or whatever.
Or you can use costume names so you can cat-walk1, cat-walk2 and dog-walk1, dog-walk2 etc.
- kuku_the_cockatiel
-
Scratcher
35 posts
Hii! So a question
Each character has 9 costumesHow many? If the code is otherwise the same it's easier to keep it all in one sprite rather then duplicate which would mean every change having to be copied multiple times.But if the choice of character is essentially between costumes for a single sprite you can use cloning or stamping to select one. That at least saves duplicating code for different sprites. Still possible to have a group of costumes for each one for basic animation.But each sprite has movement costumes.
Here's an example https://scratch.mit.edu/projects/41719938/
It's not hard to work with a range of costumes - eg if you have 10 costumes per character you can easily set a variable to 0 or 10 or 20 etc and use that as an adjustment. So switch to costume ‘myvar’ + 5 would give costume 5 or 15 or 25 or whatever.
Or you can use costume names so you can cat-walk1, cat-walk2 and dog-walk1, dog-walk2 etc.
- deck26
-
Scratcher
1000+ posts
Hii! So a question
So do you understand what I'm suggesting?Each character has 9 costumesHow many? If the code is otherwise the same it's easier to keep it all in one sprite rather then duplicate which would mean every change having to be copied multiple times.But if the choice of character is essentially between costumes for a single sprite you can use cloning or stamping to select one. That at least saves duplicating code for different sprites. Still possible to have a group of costumes for each one for basic animation.But each sprite has movement costumes.
Here's an example https://scratch.mit.edu/projects/41719938/
It's not hard to work with a range of costumes - eg if you have 10 costumes per character you can easily set a variable to 0 or 10 or 20 etc and use that as an adjustment. So switch to costume ‘myvar’ + 5 would give costume 5 or 15 or 25 or whatever.
Or you can use costume names so you can cat-walk1, cat-walk2 and dog-walk1, dog-walk2 etc.
- kuku_the_cockatiel
-
Scratcher
35 posts
Hii! So a question
not really…So do you understand what I'm suggesting?Each character has 9 costumesHow many? If the code is otherwise the same it's easier to keep it all in one sprite rather then duplicate which would mean every change having to be copied multiple times.But if the choice of character is essentially between costumes for a single sprite you can use cloning or stamping to select one. That at least saves duplicating code for different sprites. Still possible to have a group of costumes for each one for basic animation.But each sprite has movement costumes.
Here's an example https://scratch.mit.edu/projects/41719938/
It's not hard to work with a range of costumes - eg if you have 10 costumes per character you can easily set a variable to 0 or 10 or 20 etc and use that as an adjustment. So switch to costume ‘myvar’ + 5 would give costume 5 or 15 or 25 or whatever.
Or you can use costume names so you can cat-walk1, cat-walk2 and dog-walk1, dog-walk2 etc.
- deck26
-
Scratcher
1000+ posts
Hii! So a question
What would the costume names be for one character? Let's say walk1, walk2, walk3, run1, run2, run3 and so on.
Prepend the character name os if you can choose between ‘cat’ and ‘dog’ you'd have costumes named
catwalk1, catwalk2 …. dogwalk1, dogwalk2 … and so on.
So you set variable ‘charname’ to ‘cat’ or ‘dog’ and you can then use
You can still use next costume if necessary, just make sure you loop round within the current range. So if your 9 dog costumes were numbered 10 to 18 you want to avoid next costume taking you to costume 19. That's also easy enough. If the var ‘range-start’ is set to 1, 10, 19 etc according to the character you can replace next costume with
This may sound copmplicated but it only affects your costume changes - use custom blocks if handling costume changes in multiple places. Believe me, it is easier than having to correctly update multiple copies of scripts across multiple sprites.
Prepend the character name os if you can choose between ‘cat’ and ‘dog’ you'd have costumes named
catwalk1, catwalk2 …. dogwalk1, dogwalk2 … and so on.
So you set variable ‘charname’ to ‘cat’ or ‘dog’ and you can then use
switch costume to (join (charname) [wa;lk1]) // etc
You can still use next costume if necessary, just make sure you loop round within the current range. So if your 9 dog costumes were numbered 10 to 18 you want to avoid next costume taking you to costume 19. That's also easy enough. If the var ‘range-start’ is set to 1, 10, 19 etc according to the character you can replace next costume with
switch costume to ((range-start) + ((costume#) mod [9]))
This may sound copmplicated but it only affects your costume changes - use custom blocks if handling costume changes in multiple places. Believe me, it is easier than having to correctly update multiple copies of scripts across multiple sprites.
- MasterofTheBrick
-
Scratcher
1000+ posts
Hii! So a question
Ninja'd again
I think this is what deck-26 is trying to say:
I think this is what deck-26 is trying to say:
set [avatar v] to [scratchcat] //this is an example character
set [counter v] to [1]
repeat (number of costumes for one avatar's movement cycle ::grey)
switch costume to (join (avatar) (counter)) //this would switch the costume to scratchcat1
change [counter v] by (1) //the next costume would be scratchcat2
end
Last edited by MasterofTheBrick (June 25, 2021 09:42:43)
- kuku_the_cockatiel
-
Scratcher
35 posts
Hii! So a question
What would the costume names be for one character? Let's say walk1, walk2, walk3, run1, run2, run3 and so on.I understand it now but I dont want to change the costumes I just want a simple select screem. Sorry if I misunderstood. If you want to see how I'm trying to make a select screen, here is the project: https://scratch.mit.edu/projects/547873203/
Prepend the character name os if you can choose between ‘cat’ and ‘dog’ you'd have costumes named
catwalk1, catwalk2 …. dogwalk1, dogwalk2 … and so on.
So you set variable ‘charname’ to ‘cat’ or ‘dog’ and you can then useswitch costume to (join (charname) [wa;lk1]) // etc
You can still use next costume if necessary, just make sure you loop round within the current range. So if your 9 dog costumes were numbered 10 to 18 you want to avoid next costume taking you to costume 19. That's also easy enough. If the var ‘range-start’ is set to 1, 10, 19 etc according to the character you can replace next costume withswitch costume to ((range-start) + ((costume#) mod [9]))
This may sound copmplicated but it only affects your costume changes - use custom blocks if handling costume changes in multiple places. Believe me, it is easier than having to correctly update multiple copies of scripts across multiple sprites.
- kuku_the_cockatiel
-
Scratcher
35 posts
Hii! So a question
Ninja'd againooh but is there any way to make it without all the costumes of all the characters in 1 sprite?
I think this is what deck-26 is trying to say:set [avatar v] to [scratchcat] //this is an example character
set [counter v] to [1]
repeat (number of costumes for one avatar's movement cycle ::grey)
switch costume to (join (avatar) (counter)) //this would switch the costume to scratchcat1
change [counter v] by (1) //the next costume would be scratchcat2
end
- MasterofTheBrick
-
Scratcher
1000+ posts
Hii! So a question
I understand it now but I dont want to change the costumes I just want a simple select screem. Sorry if I misunderstood. If you want to see how I'm trying to make a select screen, here is the project: https://scratch.mit.edu/projects/547873203/
Then what problems are you facing now? All you have to add in is the mouse down? detector and you're fine.
- deck26
-
Scratcher
1000+ posts
Hii! So a question
I understand it now but I dont want to change the costumes I just want a simple select screem. Sorry if I misunderstood. If you want to see how I'm trying to make a select screen, here is the project: https://scratch.mit.edu/projects/547873203/
You can do that simply by broadcasting to show all 3 sprites. When one is clicked you set a variable to that name and broadcast to hide the others - the broadcast receiver hides the sprite if the variable doesn't match that sprite's name. That's all easy enough.
Still think you'll regret this though if the scripts are going to be identical for the three characters. You detect a bug and you'll have to change it in 3 places. Make a minor mistake in one and you might not notice until much later - unless you test everything 3 times or repeatedly delete scritps and copy them between sprites (just another chance to forget to do so or get something wrong like having duplicate scripts).
Even if the scripts vary slightly it would be better to code for the differences - eg if they move at different speeds use a variable for the speed; if one character has some special ability use if blocks.
- MasterofTheBrick
-
Scratcher
1000+ posts
Hii! So a question
Ninja'd againooh but is there any way to make it without all the costumes of all the characters in 1 sprite?
I think this is what deck-26 is trying to say:snip ::grey
The purpose of this code is so that all of the costumes are in 1 sprite, hence making the project more efficient.
- kuku_the_cockatiel
-
Scratcher
35 posts
Hii! So a question
Ok thanks! If this does create any problems I'll use the other code you suggested!I understand it now but I dont want to change the costumes I just want a simple select screem. Sorry if I misunderstood. If you want to see how I'm trying to make a select screen, here is the project: https://scratch.mit.edu/projects/547873203/
You can do that simply by broadcasting to show all 3 sprites. When one is clicked you set a variable to that name and broadcast to hide the others - the broadcast receiver hides the sprite if the variable doesn't match that sprite's name. That's all easy enough.
Still think you'll regret this though if the scripts are going to be identical for the three characters. You detect a bug and you'll have to change it in 3 places. Make a minor mistake in one and you might not notice until much later - unless you test everything 3 times or repeatedly delete scritps and copy them between sprites (just another chance to forget to do so or get something wrong like having duplicate scripts).
Even if the scripts vary slightly it would be better to code for the differences - eg if they move at different speeds use a variable for the speed; if one character has some special ability use if blocks.
- Discussion Forums
- » Help with Scripts
-
» Hii! So a question


