asign variables by object creation order

0 favourites
  • 4 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hi all,

    I want to asign variables to my objects based on the order in which they are created. I have tried using their z-index and have written the code shown below but it's not working. I have created the text boxes to test it and at the moment the orangeshape always comes up as shape2. I don't know why this is happening.

    <img src="https://dl.dropbox.com/u/101200636/code-screenshot.jpg" border="0" />

    The "orangeshape" is a member of the "mainshapes" family. I have set a boolean family instance variable of 'shape1' and shape2' to false to begin with. Please can anyone tell me where I am going wrong?

    Thank you for reading this and for any help you can give.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Could use a bit more context to help you better..

    Is there a text object created for each orangeshape?

    If so, are they referring to the correct instance? You can make sure by adding another line such as Set text to orangeshape.X and see if it corresponds

    Or try flipping the order of the "Is shape1"/"Is shape2" events to see if the last event is merely overwriting the previous event. That's what it looks like.

    But what are you needing this for? It's likely there is probably an easier way to achieve it.

  • Hi keepee

    Thanks for your reply, and I would be really grateful for your help as I am really stuck.

    I am trying to create a shape matching game. I have 2 groups of matching shapes which I have placed in families. 2 shapes from the first group are selected at random and placed on the screen at random angles. The player then needs to select 2 shapes from the second groups to match these shapes and angles within a time limit.

    I need to work out a way to check that:

    1.     The player only selects 2 shapes

    2.     These shapes match the 2 shapes on the screen

    3.     They match the angles of the 2 shapes on the screen

    I�ve been working on this for some time. The solutions I have come up with so far have achieved some of the things I want but the events I�ve created seem rather over complicated to me and I think you were correct that there is probably a better way.

    Unfortunately, I am still very new to C2 and programming concepts, and it was the best solution I could find with my limited knowledge.

    P.S.

    I created the text boxes just to check if my variables where being assigned correctly as I thought these variables would help me reference each shape so I could run my checks. These are not part of the game.

    Thanks again for any help you can give me.

  • Hi, sorry but If you upload your .capx file somewhere, I'll see if I can modify it and repost.

    It'll be a lot easier to see what exactly the problem involves!

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