Discuss Scratch

Bang_Mega_Xtreme
Scratcher
10 posts

Projectiles aren't deleting themselves

I have a projectile sprite that creates clones that shoots to the left (3 times at one go), and the clones should delete themselves (disappear) when they hit the left side of the screen. However, the clones are not deleting themselves when they reach the left edge. The line of code in my sprite is currently like this:

when backdrop switches to [backdrop 29]
forever
wait (pick random (5) to (7)) secs
repeat (3)
create clone of [myself]
wait (1) secs
end
end

when I start as a clone
go to x: (196) y: (pick random (-180) to (180))
repeat until <(x position) < [-239]>
change x by (-5)
end
delete this clone

Can anyone help to fix my problem? Thanks.
RokCoder
Scratcher
1000+ posts

Projectiles aren't deleting themselves

Depending on the size of the costume and the position of the costume's origin, it's possible that the x position never gets that small. Tick the x position box for the sprite so that you can see the value and run the movement script on the main sprite. That way you'll see what's happening with the x position and most likely discover the cause of the bug.


Scratch dabbling for fun…

Bang_Mega_Xtreme
Scratcher
10 posts

Projectiles aren't deleting themselves

RokCoder wrote:

Depending on the size of the costume and the position of the costume's origin, it's possible that the x position never gets that small. Tick the x position box for the sprite so that you can see the value and run the movement script on the main sprite. That way you'll see what's happening with the x position and most likely discover the cause of the bug.

Thank you! I have tried to fix it using your idea (making it delete itself when its x position is less than -230 instead of -239) and it worked!

Powered by DjangoBB