Hello Guest

Author Topic: TK2D Button Reloading Scenes while Reusing GameObjects  (Read 5018 times)

daklab

  • Newbie
  • *
  • Posts: 12
    • View Profile
    • Daklab - Experiments, Projects, Designs, Tips, and Tutorials Related to Creative Coding
TK2D Button Reloading Scenes while Reusing GameObjects
« on: June 27, 2012, 06:25:59 am »
I've got a TK2D button working in a mobile testing environment. The button triggers the reloading of 1 of 2 scenes that I've included in the build (Build Settings > Scenes In Build). What I'm trying to achieve is to (in the most efficient way as my target is mobile) load new scenes/levels but reuse ALL the objects in the previous scene only to position them differently (and not display some of them). I'm aware of "DontDestroyOnLoad" for objects but how does the next scene know to use these objects that were marked "DontDestroyOnLoad"?

I'm thinking it may be better to instantiate all my objects in pools and simply reposition them based on an external file when a new scene/level is "loaded"/selected. I just don't want to go that route if the same thing can be achieved using the built in Application.LoadLevel functionality. Any thoughts on the best way to achieve this?
Braindrop Labs - Games. Apps. Coded Art. www.braindroplabs.com

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: TK2D Button Reloading Scenes while Reusing GameObjects
« Reply #1 on: June 27, 2012, 01:32:25 pm »
If you're loading scenes, and you need the objects in different locations, perhaps just treating them as different objects would be best. You can make the atlas persistent by creating a sprite in the scene far away somewhere and invisible to the main view, and marking as Don'tDestroyOnLoad. The largest overhead will be loading the atlas, and if it is already present, setting up a few sprites will take no time all.

Not to mention, the workflow will be a lot smoother like this.