Discuss Scratch

bsrour
New Scratcher
5 posts

sprite is sensing while hidden

Hi, could someone please look at my game and help me figure out how to make my diver not sense the sharks while hidden? The objective is that once the diver picks up a certain amount of cans then another shark will appear. My issue is that the hide button doesn't help with sensing and my diver still loses lives while the shark is hidden. Thank you!

Here is a link to my project:
https://scratch.mit.edu/projects/288492250/editor/
ajsya
Scratcher
1000+ posts

sprite is sensing while hidden

I don't see any problems. I think it's a good game.
asterlily
Scratcher
47 posts

sprite is sensing while hidden

not possible…what IS possible though is adjusting your ‘if touching color’ script to only function if they're in the costume Diver2, simply make another costume with no sprite then before hiding your sprite let it switch to that costume, once you do the code will detect its not the costume it should be sensing with…here's how your code will need to look:

when green flag clicked
hide variable [Lives]
set [Lives] to [5]
forever
if <(costume #)= [Diver2]> then
if <touching [ColorGray] ?> then
broadcast [Uh Oh]
change [Lives] by (-1)
end

end
end

Last edited by asterlily (April 14, 2019 02:55:47)

deck26
Scratcher
1000+ posts

sprite is sensing while hidden

A sprite will not be sensed when hidden but will still sense other unhidden objects. Using the costume or a variable to tell you when the diver is hidden is a sensible option.
codeman1044
Scratcher
1000+ posts

sprite is sensing while hidden

deck26 wrote:

A sprite will not be sensed when hidden but will still sense other unhidden objects. Using the costume or a variable to tell you when the diver is hidden is a sensible option.
Another option is to set the diver's ghost effect to 100. It will make them completely invisible, but they can still interact with other sprites, unlike the hide block. When you want to show the diver, set it's ghost effect to 0. That way, you wouldn't need a variable to detect when the diver is hidden.
deck26
Scratcher
1000+ posts

sprite is sensing while hidden

codeman1044 wrote:

deck26 wrote:

A sprite will not be sensed when hidden but will still sense other unhidden objects. Using the costume or a variable to tell you when the diver is hidden is a sensible option.
Another option is to set the diver's ghost effect to 100. It will make them completely invisible, but they can still interact with other sprites, unlike the hide block. When you want to show the diver, set it's ghost effect to 0. That way, you wouldn't need a variable to detect when the diver is hidden.
There's no way of reading the sprite's ghost effect though so you still need a variable to know when it is hidden.
codeman1044
Scratcher
1000+ posts

sprite is sensing while hidden

That is true… so I guess the script would look like this:

when I receive [hide v]
set [ghost v] effect to (100)
set [hidden v] to (1)

when I receive [show v]
set [ghost v] effect to (0)
set [hidden v] to (0)

Powered by DjangoBB