Discuss Scratch

Woofless04
Scratcher
100+ posts

Help with deleting clones/text sprite?

Okay so I'm making an RPG type game, and I've already made a text sprite that kind of works, you have to press space to continue with the next line of text.
However, if you press space before the text finishes it cuts off everything before the space key was pressed.
The script originally looked like this -
defineText:string1gotox:-192y:-131setctostring1setbto1repeatlengthofstring1createcloneofmyselfchangebby1changexby15setMovingto0waituntilkeyspacepressed?hidesetMovingto1deletethisclone
*Moving was just to stop the main character from moving.
Then the clone sprite looked like this -
whenIstartasacloneswitchcostumetoletterbofcplaysoundletterbofcshowwaituntilkeyspacepressed?deletethisclone

I have changed it in an attempt to fix it, so now it looks like this -
defineText:string1gotox:-192y:-131setato0setctostring1setbto1setMovingto0repeatuntilb=lengthofcsetatoletterbofcwait0.002secscreatecloneofmyselfchangebby1changexby15setbtob-1waituntilkeyspacepressed?andb=lengthofcwait0.2secshidesetato1deletethisclonefoo

And the clones -
whenIstartasaclonesetdtoaswitchcostumeto(a)playsound(a)showwhenIstartasacloneforevergotofrontwhenIstartasaclonewaituntila=1hidedeletethisclone

If you have any ideas I'll be glad to hear them!
Breck-
Scratcher
100+ posts

Help with deleting clones/text sprite?

How are you using the custom block? as in what triggers it?
Woofless04
Scratcher
100+ posts

Help with deleting clones/text sprite?

Breck- wrote:

How are you using the custom block? as in what triggers it?
Whenever you input something into string1, it should come up on the screen.
Here's a project with the scripts in it -
https://scratch.mit.edu/projects/188041331/
deck26
Scratcher
1000+ posts

Help with deleting clones/text sprite?

Because your clone script tells a clone to delete itself when space is pressed. Use a broadcast from the main script to tell the clones to delete themselves.
Woofless04
Scratcher
100+ posts

Help with deleting clones/text sprite?

deck26 wrote:

Because your clone script tells a clone to delete itself when space is pressed. Use a broadcast from the main script to tell the clones to delete themselves.
Okay I'll try that.

Powered by DjangoBB