I am making a space-invader style game that has clones of an alien sprite descend from the top of the screen. The user will press space to fire a bullet sprite (not a clone) at the alien clones. For some reason, when the bullet sprite gets to the alien clone, it goes straight through the alien clone and it the alien clone doesn't delete itself. This is what I have right now that's not working. How can I make the alien clones detect when they touch the bullet sprite and delete themselves when they do?
Can you share your project so we can see your code?
when i start as a clone
wait until <touching [bullet sprite V]?>
tell [bullet sprite V] to ({hide}@addInput) @addInput
delete this clone
and don't forget to tell [bullet sprite V] to {{hide} @addInput :: ring} @addInput
not if the bullet should keep going, but yeah.
Here's my link for the code! I added a yellow comment box on the part that seems to be giving me trouble.
Pls share it (click file, open, search planet defenders, click on the name, select share)
Oh, thanks! Hopefully this one works, if not let me know lol. the comment box should still be there under the "Aliens", where I think the mistake is! There are also a few comments under the "Sprite" explaining how things are supposed to work. (-:
https://snap.berkeley.edu/snap/snap.html#present:Username=184654&ProjectName=PLANET%20DEFENDERS
ah, i see the problem now. with the way it is right now, the aliens only check if they've been hit after they've stopped moving. you can fix this by separating the checks into another script, like so:
Ah, thank you! This fixed it! Here's a link of what it looks like now for anybody who has the same problem in the future-- Originally I had everything listed under the same "when I start as a clone" block, so I separated two chunks out like recommended above to get them to act at the same time.
https://snap.berkeley.edu/snap/snap.html#present:Username=184654&ProjectName=PLANET%20DEFENDERS
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.