help me

  • I have 10 different objects,

    I made another object which is the "Light up", i copied and paste it 10 times, each one has a unique UID.

    if i click object #1, then it lights up, but when you click object #2 it lights and object #1 still stays light up.

    What i want is, when i click object #1, it lights up, and when I click object #2 it should light up, but then object #1 light up should be invisible.

    i know how you can do it when the light up is 10 different objects, i want to know how can you do it when its same light up object but each one has a unique uid.

    here is a picture

    forgot to mention, Sprite1048 represents "Light up Object"

    Sprite984 is object #1

    and Sprite981 is object #2

  • This is the most horrific Construct code I've seen in my life! You have over a thousand sprites and you don't name them? You have 150K+ instances and you pick them by hard-coded UID? I will have nightmares about this screenshot..

    I can see one definite mistake - you are trying to pick a different instance with a different UID in a sub-event. You can't do this. If you need to pick another instance, you first need to add "System Pick All" condition.

    Sprite pick by UID=1 : Sprite set Visible
    
    	System Pick All Sprite
    	Sprite pick by UID=2 : Sprite set Invisible
    
  • I know my code is horrific,

    I am fixing it,

    Yes i have over a thousand sprites, texts, and buttons, but thanks to people on this forum i dont need this many buttons, texts, and sprites.

    So its getting a lot less.

    And thank you very much for your help, it worked!

    and yeah i should really name my sprites lol, i myself is getting confused.

    <3

  • I bet if you return to this code in a week, you will not be able to remember what all these sprites and UIDs mean.

    This is not how you should program in Construct! Use families, containers, instance variables. Don't use Pick by UID, it's rarely a good idea, and definitely a very-very bad idea in your case.

  • Now I understand why Pick by UID is a bad idea xD

    what other ways is there? create families ? variables ?

  • You need to learn a bit about how things work, in order to understand what you need. Read about instances, instance variables, families, containers.

    Study the game templates that are included with Construct - Kiwi Story, Pop Lab etc. They demonstrate the best programming practices.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • the pick by uid works for one layout only, and i have multiple layouts. I want it to work for more than one layout.

    did a test on construct 3, I will read about instances, instance variables, families, and containers now :)

  • Yeah, this looks much better, but you should also give your objects proper names.

  • Sadly it doesn't work lol,

    if i click on Sprite2, (its frame is set to 0) it should make another object visible which is the "Light up"

    if click on sprite2, (frame is set to 1) it makes another object visible, and destroys the other one.

    i click frame 0 first, then frame 1, it works, but when i click frame 0 again, frame 1's light up object stays visible and it doesn't go destroy

  • Run the game in Debug Mode and check all instances and instance variables after every click.

  • Just did now, and it seems like every time i click frame 0 it keeps adding more and more objects, but if i click frame 1, objects count shows 3, which is what it suppose to show, but if click frame 0, it adds, 4, 5, 6 objects and so on

  • Lol found the problem, it was the instance variables

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)