asign variables by object creation order

Get help using Construct 2

Post » Sun Oct 28, 2012 7:31 pm

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.



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.
B
18
S
4
G
2
Posts: 77
Reputation: 1,588

Post » Mon Oct 29, 2012 3:44 pm

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.
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Mon Oct 29, 2012 7:15 pm

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

Ive 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 Ive 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.
B
18
S
4
G
2
Posts: 77
Reputation: 1,588

Post » Tue Oct 30, 2012 3:18 pm

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!keepee2012-10-30 15:18:55
B
28
S
8
G
1
Posts: 469
Reputation: 4,683


Return to How do I....?

Who is online

Users browsing this forum: DemantDigitalArt and 21 guests