can someone help me im trying to change my variable by 1 when my sprite is on a different costume.What scripts should I use
Offline
<when green flag clicked>First of all I only know how to do it with global variables, but anyways: If you havent changed the names of the costumes, they should be like "costume1", "costume2", etc:
so you can clearly see the Costume #. Next, there is a little block in Looks ( I think the type of block is a reporter)that says Costume #.
So here is an example of the blocks you'd need for an alien game or something where every time you hit a spacecraft you get 10 pts. This would be a script for the spacecraft, which would have 2 costumes, a regular costume and a blown-up one:
[blocks]<when green flag clicked>[/blocks]
[blocks],<if><<(costume # <=> 2 )[/blocks]
[blocks]<change{variable}by( 10[/blocks]
[blocks]<end>[/blocks]
(This MAY not look good, it's my 1st time using blocks in the forum.)
You get the idea. When green flag clicked, if costume # = 2, change score by 10.
Which means:if it is in its blown-up costume, you get 10 pts.
Hope this helps!
Offline
Wait... Why does it say "when green flag clicked" at the beginning of my last post...
I never put one there!
Offline
Variables are Scratch's way of remembering different numbers, digits, values or key combos for a while. Basically, if you set variable A to on, then it'll stay as "on" until it is changed. This is useful for C blocks (like If ___), and making Scratch be able to ask multiple questions, and save answers to all those questions, not just the first one.
Offline
A variable is just what it sounds like. It varies.
For the example, let's name the variable "Score."
Let's pretend that you are making a maze game. Whenever you get to the next level, you want to get 10 points.
You do this:
change [score v] by (1)The possibilities for using variables are infinite. What I would recommend is to look at the example projects that use variables and look at how they use them.
Offline
Aarone32 wrote:
Is there a site where I can find some php programming tutorials?...I guess there are a lot more useful information about variable to be found there too.
Thanks
please post here if someone finds such a resource
w3schools
Offline
User52 wrote:
Hey i saw this topic and thought i could post my question here. i cant post a topic yet idk why. anyway, i'm making a pokemon simulator with advance damage calculation, but when i tst it, part of the equation turns red. i thought it could be because i dont have parentheses () but i dont know how to add them. help please?
maybe you divided by 0.
Offline
hey guys
i was wondering... how do you make a time variable?
please answer soon and dont make the answer to complex!
xoxo love you all!
jasmine
Offline
Hello, I am still new to Scratch. In Tech class, we have to create a game called "MadLibs."
I am not sure if we are able to put the variables in places that suits us best. For example, I have some 'fill-ins' that I want the variables to stay in place. But, whenever I open this game the next day, the variables will be out of place.
This is the game: http://scratch.mit.edu/projects/Cheese-Dragon/2494777
It is not finished. Thanks for hearing me out. And if you can help, thank you very much!
Offline
well if your making a game you think this,
<scratchblocks>
when gf clicked
forever
wait until <touching [? v]>
change [lives v] by [-1]
end
</scratchblocks>
no its like this.
when gf clicked forever wait until <touching [? v]> change [lives v] by [-1] repeat (5) times show wait (.2) hide end when gf clicked wait until <(lives) = (0) hide stop allvariables are bridges that connect scripts.
Offline
Forgive me if this has been answered already, I'm new Scratch and to this site.
I know you can get variables to stay where you've put them if you make them visible. The problem is they then show up on the opening screen. Please can someone tell me if there is a way round this?
Offline