Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to sense costume?
- Jitterdog
- Scratcher
2 posts
How to sense costume?
Hey guys, I was trying to make a game where a background changes dependent on the costume given to a certain sprite. The costume given to the sprite is on a variable however. Is there anything I can create that does something along the lines of:
1. Senses when the sprite is clicked
2.Senses what costume the other sprite is in
3. Changes to a certain background according to the costume of the other sprite?
Help is greatly appreciated.
1. Senses when the sprite is clicked
2.Senses what costume the other sprite is in
3. Changes to a certain background according to the costume of the other sprite?
Help is greatly appreciated.
- FrankieJrJr
- Scratcher
100+ posts
How to sense costume?
Player Or Sprites:
Background:
I hope this helps. Sorry if its doesn't. If you have any question please ask me and I will be happy to answer.
when green flag clicked
switch costume to (pick random (1) to (3))
set [Back_Drop] to (costume #)
Background:
when green flag clicked
forever
switch backdrop to (Back_Drop)
end
I hope this helps. Sorry if its doesn't. If you have any question please ask me and I will be happy to answer.
- Scratch-Minion
- Scratcher
1000+ posts
How to sense costume?
You can only detect a sprite being clicked within that sprite.
We can store the number of the costume set in a variable, I have used “New Costume Num” below.
Then broadcast a message to the background,
where you can set the background to the corresponding costume/background number.
Inside the sprite script:
Then in the background script:
Finally fixed, sorry about my editing troubles
We can store the number of the costume set in a variable, I have used “New Costume Num” below.
Then broadcast a message to the background,
where you can set the background to the corresponding costume/background number.
Inside the sprite script:
when this sprite clicked
switch costume to [my costume v]
set [New Costume Num v] to (costume #)
broadcast [Costume Changed v]
Then in the background script:
when I receive [Costume Changed v]
switch backdrop to (New Costume Num)
Finally fixed, sorry about my editing troubles
Last edited by Scratch-Minion (May 19, 2016 03:43:00)
- deck26
- Scratcher
1000+ posts
How to sense costume?
The sensing block will give you the name or number of the costume
Normally a sprite won't see itself in the second dropdown list but if you go to another sprite you can get what you want and then copy it across to the sprite that needs to detect its own costume.
([costume# v] of [spritename v])
Normally a sprite won't see itself in the second dropdown list but if you go to another sprite you can get what you want and then copy it across to the sprite that needs to detect its own costume.
- Jitterdog
- Scratcher
2 posts
How to sense costume?
Player Or Sprites:when green flag clicked
switch costume to (pick random (1) to (3))
set [Back_Drop] to (costume #)
Background:when green flag clicked
forever
switch backdrop to (Back_Drop)
end
I hope this helps. Sorry if its doesn't. If you have any question please ask me and I will be happy to answer.
Thanks a bunchles!
- GameLightDevelopment
- Scratcher
1 post
How to sense costume?
please help it is now 2020 and certain blocks do not exists so please help me
i want to know how when my life bar is is at 0% it is game over.
help please.
i want to know how when my life bar is is at 0% it is game over.
help please.
- imfh
- Scratcher
1000+ posts
How to sense costume?
Please create your own topic rather than posting on one that is more than 3 years old. You can create a topic by pressing the blue “New Topic” button at the top right of the please help it is now 2020 and certain blocks do not exists so please help me Help With Scripts page. Make sure to share your project and link to get the best help.
i want to know how when my life bar is is at 0% it is game over.
help please.
You will probably want to have your health bar sprite check which costume it has whenever the health goes down. For example:
when I receive [Lose Health v]
next costume
if <(costume [name v] :: looks)=[0%]> then
broadcast [Game Over v]
end
Scratch to Pygame converter: https://scratch.mit.edu/discuss/topic/600562/
- SA1392020b
- New to Scratch
1 post
How to sense costume?
You can do this: please help it is now 2020 and certain blocks do not exists so please help me
i want to know how when my life bar is is at 0% it is game over.
help please.
when green flag clicked
forever
if <(Lives) = [0]>then
broadcast [0 lives v]
end
when I receive [0 lives v]
say [Game over]
stop [all v]
Last edited by SA1392020b (March 12, 2020 03:21:17)
- Falcon0327
- Scratcher
71 posts
How to sense costume?
Hey guys, I was trying to make a game where a background changes dependent on the costume given to a certain sprite. The costume given to the sprite is on a variable however. Is there anything I can create that does something along the lines of:
1. Senses when the sprite is clicked
2.Senses what costume the other sprite is in
3. Changes to a certain background according to the costume of the other sprite?
Help is greatly appreciated.
How about this block:
([costume # v] of [Sprite1 v])
- Discussion Forums
- » Help with Scripts
- » How to sense costume?