2D Toolkit Forum
2D Toolkit => Support => Topic started by: mradebe_eti on October 08, 2013, 09:24:10 pm
-
Hi,
I need help with creating a level unlock scene with 2D Toolkit. I tried following the tutorial on the thread below, but it was not very helpful to me.
http://forum.unity3d.com/threads/146955-Unity-Level-Unlocking-System-Using-PlayerPrefs
I have attached a screenshot of my scene.
I have 9 levels. The game starts with 3 unlocked levels (shown as blinking animated sprites). After completing the 3 levels (in any order) I need the levels to change (now shown as static sprites with a blue sphere) and then unlock 3 more levels which change color when completed, before unlocking the final 3 levels and completing the game.
I have created all the sprites. Do I need to layer the different sprites on top of each other like in the above tutorial? Should I have a separate script for each level or one script which controls everything?
Any assistance with this is appreciated.
Thanks.
-
You can change a sprite by using SetSprite(...). Everything else pretty much depends on what you want, and how you're implementing everything else. If you're following a tutorial, I suggest following it, except for when you need to swtich sprites, use the function above.
-
Thanks for that.
Do I also need to place all the sprites I'm going to use in the hierarchy before I can use them? Or should I just reference them from their sprite collection?
-
Its up to you - it can be done either way. Personally I'd just place the sprites that need to be visible, and then swap them using SetSprite as necessary.
-
How do I actually reference the sprite?
Here is my code:
tk2dBaseSprite test1 = new tk2dSprite(); //instantiating sprite object
test1.SetSprite("Skill 1 Icon Uncleared A"); // giving it a name of the game object
test1.enabled = false; // disabling it so users cannot tap on it
Is this correct? If not, how can I access the sprite, set the sprite and disable the sprite? Or replace it with another sprite which is disabled?
-
If you need to reference the sprite, create a public tk2dSprite sprite, and drag a reference in in the unity inspector.