Hi Scratchers,
My script is basically a video game called "Revenge of the Nerds," where you dodge a football player and get more points depending on how long you survive. However, I recently decided to add a character selection screen allowing you to choose different "nerds" instead of being limited to the one default sprite. I also added a start screen. Basically, there is a sprite that says "Click anywhere to play," and when the stage is clicked, the game proceeds to the character selection screen. However, i am unsure how to make my characters appear on the character selection screen. Is there a code block that says "When ____, show?" (In this case the blank being when the stage is clicked. I know there is a "When Stage Clicked" block, but it is impossible to put that onto scripts for sprites, I am only able to use it on script for the stage itself. If I duplicate that block onto a sprite's script, then it automatically changes to "When SpriteX is clicked" Is there anyway to make these characters appear after I click the stage and proceed to the loading screen?
Offline
No matter where you click, you'll be clicking on the screen, so you could use:
when gf clicked hide wait until <not <mouse down?>> wait until <mouse down?> show stage selection scriptI hope that this helps!
Offline
ErnieParke wrote:
No matter where you click, you'll be clicking on the screen, so you could use:
when gf clicked hide wait until <not <mouse down?>> wait until <mouse down?> show stage selection scriptI hope that this helps!
Thanks a lot Ernie, that got them to appear. So now, when a sprite gets clicked, do I have to copy all of my code from the default "Nerd" onto that sprite in order for it to work? Or is there a shortcut that lets that one code suffice for all of the sprites, depending on which is chosen? There's no way for me to click on one sprite, and something happens for another...or is there? (If that were the case, I would simply go to my default sprite and put "If <insert sprite here> is clicked, switch to costumex." Is this possible?
Offline
Yes, this is possible using variables, or you could use several operators, though the variable method is simpler. Just tell me if you want to see it the other way.
Anyway, use this script in the sprite that you click:
set [costume v] to (1) repeat until (done?) if <(touching [mouse-pointer v]?) and (mouse down?)> change [costume v] by (1) wait until <not (mouse down?)> end endAnd then use this in the sprite that's supposed to change costumes:
repeat until (done?) switch to costume (costume) end
Last edited by ErnieParke (2012-10-10 20:20:46)
Offline
Imagine that each different nerd option has a number assigned to him. In your main "nerd" sprite (which should contain all your gameplay scripts), make a costume for each nerd. Using the "select nerd" screen, set the value of a variable (let's call it "NerdType") to the number associated with the appropriate nerd. Then, in the sprite, include this block inside one of your forever loops:
switch to costume (NerdType)
Last edited by amcerbu (2012-10-10 21:41:41)
Offline
ErnieParke wrote:
Yes, this is possible using variables, or you could use several operators, though the variable method is simpler. Just tell me if you want to see it the other way.
Anyway, use this script in the sprite that you click:set [costume v] to (1) repeat until (done?) if <(touching [mouse-pointer v]?) and (mouse down?)> change [costume v] by (1) wait until <not (mouse down?)> end endAnd then use this in the sprite that's supposed to change costumes:repeat until (done?) switch to costume (costume) end
What exactly is the "done" block?
Offline
Vonologic wrote:
ErnieParke wrote:
Yes, this is possible using variables, or you could use several operators, though the variable method is simpler. Just tell me if you want to see it the other way.
Anyway, use this script in the sprite that you click:set [costume v] to (1) repeat until (done?) if <(touching [mouse-pointer v]?) and (mouse down?)> change [costume v] by (1) wait until <not (mouse down?)> end endAnd then use this in the sprite that's supposed to change costumes:repeat until (done?) switch to costume (costume) endWhat exactly is the "done" block?
The "done" block is whatever you use to determine when you're done selecting a costume.
Last edited by ErnieParke (2012-10-10 22:09:17)
Offline
Oh, ok. Well I reuploaded my game, and I decided to make "done" be if NerdType (or costume) is greater than 0. Now I just need to make the other costumes hide, and the stage change after the NerdType had changed. I think I know how to make the other sprites hide, but how exactly do I make the background change after the nerdtype is changed? I would really appreciate it if someone downloaded the code and viewed it via Scratch, as it's a bit sloppy
Offline