Discuss Scratch

BloonsTD6_
Scratcher
6 posts

The enemy in my game wont show up when i clone it and make the command do a show script, please tell me why

This is what im doing for the enemy

when green flag clicked
wait (pick random (5) to (9) secs
create clone of [myself]
when I start as a clone
go to x: (221) y: (-37)
show
repeat until <(x position) > [-240]>
change x by (-5)
end
hide
wait (pick random (3) to (5) secs
create clone of [myself]
delete this clone

is there any problems? :/

Last edited by BloonsTD6_ (Oct. 30, 2021 11:09:49)

awesome-llama
Scratcher
1000+ posts

The enemy in my game wont show up when i clone it and make the command do a show script, please tell me why

when green flag clicked
wait (pick random (5) to (9)) secs
create clone of [myself v]
when I start as a clone
go to x: (221) y: (-37)
show
repeat until <(x position) > [-240]>
change x by (-5)
end
hide
wait (pick random (3) to (5)) secs
create clone of [myself v]
delete this clone
The script should work, but there could be other things causing it. Check that they do have a costume, they are at the correct size, and are in the correct layer. A way to check if clones are on screen and showing is to use the say blocks. I like to use this trick a lot to get data out of currently existing clones. If you still can't get it to work, share the project you are working on so we can see the rest of what you've got and are able to test changes for ourselves.

Last edited by awesome-llama (Oct. 30, 2021 12:38:51)

BloonsTD6_
Scratcher
6 posts

The enemy in my game wont show up when i clone it and make the command do a show script, please tell me why

Oh ok. thank you so much, and I have shared it so you can test it, and I've figured out some scripts that do work but just tell me if there is a way to shorten some code or the code broke, and if I may ask please tell me how I can make a clone disappear when touching the edge then wait 3-5 or whatever seconds then make another clone?

Last edited by BloonsTD6_ (Oct. 30, 2021 13:51:20)

awesome-llama
Scratcher
1000+ posts

The enemy in my game wont show up when i clone it and make the command do a show script, please tell me why

BloonsTD6_ wrote:

Oh ok. thank you so much, and I have shared it so you can test it, and I've figured out some scripts that do work but just tell me if there is a way to shorten some code or the code broke, and if I may ask please tell me how I can make a clone disappear when touching the edge then wait 3-5 or whatever seconds then make another clone?
The scripts at the moment are fine, I don't see anything that can be shortened further yet except it seems you can remove some wait 0 seconds blocks.
To make the clone disappear you have to modify the repeat until because it currently doesn't work correctly. Try a repeat until (x position) < -240. The left edge of the stage is at -240.
There is one other thing to fix. The clones aren't actually being deleted. It is good practise to delete clones once they are no longer needed. What I recommend is instead of the hide block for the clone, just delete it.
The script should look like this after all changes:



BloonsTD6_
Scratcher
6 posts

The enemy in my game wont show up when i clone it and make the command do a show script, please tell me why

awesome-llama wrote:

BloonsTD6_ wrote:

Oh ok. thank you so much, and I have shared it so you can test it, and I've figured out some scripts that do work but just tell me if there is a way to shorten some code or the code broke, and if I may ask please tell me how I can make a clone disappear when touching the edge then wait 3-5 or whatever seconds then make another clone?
The scripts at the moment are fine, I don't see anything that can be shortened further yet except it seems you can remove some wait 0 seconds blocks.
To make the clone disappear you have to modify the repeat until because it currently doesn't work correctly. Try a repeat until (x position) < -240. The left edge of the stage is at -240.
There is one other thing to fix. The clones aren't actually being deleted. It is good practise to delete clones once they are no longer needed. What I recommend is instead of the hide block for the clone, just delete it.
The script should look like this after all changes:




Thanks a lot for that

Powered by DjangoBB