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

0 favourites
  • 4 posts
From the Asset Store
It's here!
$4.95 USD
Creepy and nasty horror track. It's terrifying from the beginning till the end. Goosebumps guaranteed
  • 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.

  • 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

  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks to both of you, I eill try to learn more abput arrays and find if it solves my problems.

    Thanks!

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