Discuss Scratch

coder9902htm4a0
Scratcher
51 posts

How do I make a sprite hide when it is touched by another sprite

I actually know how to do this, but I can't get it to work without having to have the target sprite move. Could I please have some help with this?
Pinkypinky33
Scratcher
30 posts

How do I make a sprite hide when it is touched by another sprite

I need to know too so anyone out there who knows, please tell Coder!!
drmcw
Scratcher
1000+ posts

How do I make a sprite hide when it is touched by another sprite

You may need to explain your problem more. You probably already have a forever block containing an if touching then hide stack. As it stands that solves your problem as you've described it. So either the problem is you need to detect all sprites instead of the one in which case you'll need to use as many or operators as you have different sprites e.g. if touching sprite1 or touching sprite2 or touching sprite3 etc. OR your problem is that you have an if touching then hide else show in which case when the sprite hides then it's no longer touching so shows then hides then shows which gives a flickery sprite. The best way to solve that is not use hide and show but use the ghost effect.
dracae
Scratcher
1000+ posts

How do I make a sprite hide when it is touched by another sprite

As drmcw is implying, the easiest way for us to help you is if you posted what you have.
Different methods work better or worse, depending on your scripts.
So, a link to your project would help!
Thanks!
coder9902htm4a0
Scratcher
51 posts

How do I make a sprite hide when it is touched by another sprite

Ok, so lets say what i want is for a knife that is flying around a room to touch a stationary ghost and cause the ghost to hide. Does that make more sense? And so for some reason I can't make that happen without having to make the ghost spin around or something, so ya

Last edited by coder9902htm4a0 (May 28, 2013 13:07:45)

CustomEpicness
Scratcher
30 posts

How do I make a sprite hide when it is touched by another sprite

forever
if <touching (Whatever the name of the knife is)>
hide
Put this in the script of the ghost.
JayZX535
Scratcher
62 posts

How do I make a sprite hide when it is touched by another sprite

Program this under the code for the ghost:

When green flag clicked:
Forever
If <touching knife>
Hide

Hope this helps!
-Jay
coder9902htm4a0
Scratcher
51 posts

How do I make a sprite hide when it is touched by another sprite

That worked thanks!
JayZX535
Scratcher
62 posts

How do I make a sprite hide when it is touched by another sprite

coder9902htm4a0 wrote:

That worked thanks!
Glad to help
mwiedmann
Scratcher
100+ posts

How do I make a sprite hide when it is touched by another sprite

Does your knife disappear when it hits the ghost, or does it keep going?

The reason I ask is that you may run into a problem where the knife disappears before the ghost detects the collision. For instance, if you had an asteroids game, and you want the laser and the asteroid to disappear when they touch, you could have “if touching” blocks on both of them. The problem is that whichever one runs first will hide (or delete if it is a clone) and the other will keep going because there will be no collision.

A method I usually use is to have all collision detection on the knife/laser/bullet (whatever). When it detects a collision, have it do a “broadcast ‘knife collision’ and wait”. Each of the asteroids/ghosts (whatever) will have a “when I receive ‘knife collision’”. In this block, check for a collision with the knife and hide, show an explosion, whatever. When the broadcast is complete, control goes back to the knife (because we used broadcast and wait), and now the knife/laser/bullet can safely be hidden or destroyed (if clone).

This method is good because you don't have a bunch of “forever” loops looking for collisions on all of your sprites. Those loops and collision checks waste a LOT of CPU cycles and can slow your programs down if you have a lot of sprites/clones on the screen.
crasyday
Scratcher
2 posts

How do I make a sprite hide when it is touched by another sprite

I need a little help how can i make a moving sprite hide when touched by a different (moving) sprite. could you also tell me were i could find those scripts(I'm new ).
drmcw
Scratcher
1000+ posts

How do I make a sprite hide when it is touched by another sprite

in the moving sprite
whenclickedforeveriftouchingother spritethenhide
The colour of the blocks should show you which block category they come from if you don't know where they are.

Last edited by drmcw (Nov. 9, 2013 15:26:41)

crasyday
Scratcher
2 posts

How do I make a sprite hide when it is touched by another sprite

Thank really helpful
gcbt10
New Scratcher
1 post

How do I make a sprite hide when it is touched by another sprite

How do you get the sprite to show up again (repeat) the script over and over again so the same thing happens. I am trying to create a game to move something across the screen and when it touches different (Repeating) sprites, then it hides and the sprites reappear and the same thing happens again until another action is performed.
rfjr
New Scratcher
2 posts

How do I make a sprite hide when it is touched by another sprite

I am having a similar problem. I have tried the suggestions here but am not having any luck. They are both moving but one of them is controlled by the keyboard, I dont think this should make a difference but I am not sure why it is not working. It did work on another non-moving sprite however but I need it to work with the Sprite the user is controlling. Any suggestions?
chancepinckney
New Scratcher
1 post

How do I make a sprite hide when it is touched by another sprite

Can I put two spirits on the same screen and they interact?
TheOatBaron
New Scratcher
41 posts

How do I make a sprite hide when it is touched by another sprite

@3 above posts

Create your own topic, you have a much better chance of a response
star9806
New Scratcher
3 posts

How do I make a sprite hide when it is touched by another sprite

so I want to make it that when a Pikachu sprite touches a thunder stone sprite Pikachu will hide and riachu will show but im not sure how to do it… any help?
Resolvedmanx015
Scratcher
64 posts

How do I make a sprite hide when it is touched by another sprite

Lets say you want x to disappear once it touches y
________________
use an if then block.make it say- [If touching then]
hide
hope this helps☺
Quesocorn
Scratcher
2 posts

How do I make a sprite hide when it is touched by another sprite

star9806, you should try something like this:
whenclickedswitchcostumetopikachu costumeforeveriftouchingthunder stone?thenswitchcostumetoraichu costume

Powered by DjangoBB