Clone a nested sprite?

How do I clone a nested sprite in a script? When I create a clone of myself from within the script of either the anchor or the part, it seems not to create a clone of the combined object (but just the one object). Is there a secret way I don't know? Thank you!

I've not tried it but you might have to clone each sprite and then assemble the combined parts into the wanted clone.

It'd be an interesting exercise to give it a go that way anyway, even if there is an easier way :slight_smile:

It says here that cloning the anchor will automatically also clone the parts. If that doesn't happen for you, please post the project.

Sorry. Here is a sample.

There is a nested sprite there. If you click the code, shouldn't it clone the entire nested sprite?
Thanks for your help.

Is there a way two combine two sprites as a nested sprite using only code blocks as part of a script? Thank you for your help.

Yes. Just check the my submenu in the set var block.

Just set the anchor to the sprite you want

... after positioning the part sprite where you want it relative to the anchor. And depending on the application, you might want to set the part's rotation center to the place where it attaches to the anchor.

Ah. The problem is that the part is being cloned, but the new one is hiding behind its anchor. If you change the code to

then you'll see the cloned part.

Arguably this is a bug, and the layering of the clone of a complex sprite should reflect the layering of the original. I'll report that...

I understand. Thank you. It does work OK when you do it with the mouse. Just when you do it in the program the layers aren't right. Maybe I can do it like you say here.

I am making a little keyboard for my Morse code project. It uses key pressed, not ask, so phone keyboards never pop up. I want for people to be able to play it on their phones. So I was thinking I could make one key outline and then do a loop that clones it 26 times and makes the letter labels for the keys from letter costumes in nested sprites and puts them at the right coordinates.

By the way, has somebody already done a good keyboard that you know about? I couldn't find one when I searched. Thank you all for the help.

I like this. Thank you. I like your user name too. It's one of my favorite movies.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.