Moving Sprites between Maps

Hey Dyson,

Is it possible to move sprites over between maps? For instance, I have a map used as a staging area as players join the game. Their sprites are loaded, configured etc. When the game starts, I load a new map into MTE where the actual game is going to be played. Unfortunately all the sprites are removed when a new map is loaded.

I have an array of my sprite objects but again when a map is loaded, the previous maps’s objects are removed leaving my array useless. calling mte.removeSprite() will destroy the object as well. How can I remove the object from the map, so i can reinsert it back into the newly loaded map?

Hope that makes sense.

Thanks.

-John

Hello John,

Hmm, I have pretty much trapped all the sprites in the current map, haven’t I? What you’re trying to do isn’t possible without a simple modifications to the engine. I’ll get a solution whipped up for Friday’s update. What I’m going to do is add another argument to removeSprite() giving people the option not to destroy the object. You’d then call the function and simply move the sprite into a non-managed group (like the Stage) before removing your map.

Sounds good. Thanks!

As of today’s update the new syntax for removeSprite is removeSprite(sprite, destroyObject). If you set destroyObject to false, MTE will insert the object into the Corona Stage and remove internal references to it. The destroyObject argument is optional; it’s default value is true.

Thanks Dyson! Thanks again!

Hello John,

Hmm, I have pretty much trapped all the sprites in the current map, haven’t I? What you’re trying to do isn’t possible without a simple modifications to the engine. I’ll get a solution whipped up for Friday’s update. What I’m going to do is add another argument to removeSprite() giving people the option not to destroy the object. You’d then call the function and simply move the sprite into a non-managed group (like the Stage) before removing your map.

Sounds good. Thanks!

As of today’s update the new syntax for removeSprite is removeSprite(sprite, destroyObject). If you set destroyObject to false, MTE will insert the object into the Corona Stage and remove internal references to it. The destroyObject argument is optional; it’s default value is true.

Thanks Dyson! Thanks again!