Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Hii! So a question
- kuku_the_cockatiel
-
Scratcher
35 posts
Hii! So a question
Soo I did this and half of it worked and half of it i didn't understand… How will the game know which character has been selected?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.
- deck26
-
Scratcher
1000+ posts
Hii! So a question
Soo I did this and half of it worked and half of it i didn't understand… How will the game know which character has been selected?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

