How do I identify an object by it's instace variables?

Get help using Construct 2

Post » Sun Dec 13, 2015 2:44 pm

Hi to everyone! I've recently started a new project that clearly exceeds my knowledge of the program, so i'm going to need a lot of help. Through this I expect getting to understand better the basics of the program and be able to solve my own problems.

Here is my doubt:
How can I identify an object by a certain instance variable?
I mean, I have an object with two instance variables, positionX and positionY, an a grid formed by squares, each of which have two instance variables, positonX and positionY.
How can I make that the object appears on the square that have the same vallues at positionX and positionY that the sprite have?
Can I do something like: "set X to square(positionx=Sprite.positionx).x" ?
Yes, I've tried this and of course didn't worked.


Thanks in advance.

Image
B
4
Posts: 6
Reputation: 247

Post » Sun Dec 13, 2015 3:01 pm

Have you tried using arrays for this? You could always define the positions in a 2d array, then you could always have the sprites set to whatever position was stored in the array, that way whenever the array changes, so does the characters position: https://www.scirra.com/manual/108/array
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,248

Post » Sun Dec 13, 2015 3:11 pm

I'm not sure that I understood what your after, but:

System | For each Square
Square | InstanceVariableX = Girl.InstanceVariableX
Square | InstanceVariabley = Girl.InstanceVariabley
do -> Girl | Set position to Square (image point 0)

Tried to make it look like it does in Construct2
Arrays are awesome, but if your having trouble now... I wouldn't send you off to learn arrays even though they are ultimately better and easier to use
B
7
S
1
Posts: 43
Reputation: 513

Post » Sun Dec 13, 2015 4:52 pm

Thanks to both of you, I eill try to learn more abput arrays and find if it solves my problems.
Thanks!
B
4
Posts: 6
Reputation: 247


Return to How do I....?

Who is online

Users browsing this forum: ilyaTyl, mindragon73 and 11 guests