Hello Guest

Author Topic: Help with Level Unlock System  (Read 6256 times)

mradebe_eti

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 26
    • View Profile
Help with Level Unlock System
« 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.



unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Help with Level Unlock System
« Reply #1 on: October 08, 2013, 10:10:53 pm »
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.

mradebe_eti

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Help with Level Unlock System
« Reply #2 on: October 10, 2013, 09:56:40 pm »
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?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Help with Level Unlock System
« Reply #3 on: October 10, 2013, 10:52:20 pm »
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.

mradebe_eti

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Help with Level Unlock System
« Reply #4 on: November 14, 2013, 03:47:00 am »
How do I actually reference the sprite?

Here is my code:

Code: [Select]

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?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Help with Level Unlock System
« Reply #5 on: November 14, 2013, 02:08:02 pm »
If you need to reference the sprite, create a public tk2dSprite sprite, and drag a reference in in the unity inspector.