Using the 'other.variable'

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

    Fresh out of the package in the Construct community, I have one very basic question:

    Here is an example, in a point & clic style game:

    I have 2 layouts. When the player clics on a specific object in the first layouts, the second layout is loaded. The second layout's name is store in the clicked object instance variables. This instance variable is called "target".

    I'm using an event with the "Mouse" object to detect when the player clic on the specific object "obj_test"

    So, in the event sheet, I have a simple condition:

    Mouse | On Left button Clicked on obj_test

    Then, the action looks like: Go to layout XXXXXX.target

    The problem is... what can I use instead of XXX to call the clicked object?

    I need something similar to self.variable but for the other object, the object I'm clicking. In game maker, I'd use other.variable (in a collision test, for example)

    Thanks a lot!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Events pick/select instances.

    When your mouse - Left button clicked occurs, it selects/pick the clicked instance in the SOL (selected object list).

    From there, an action on the object type (in your case obj_test) will have effect only on the picked instances of that object type.

    In this case, the single obj_test instance clicked is the one you will use as reference.

    So your action go to layout (by name) is obj_test.target

    This will automaticly go to the layout which names is stored in the clicked instance of obj_test.

    I hope it answers your question.

  • Thanks for the link and the answer!

    Having a bit of practice on Game maker, the condition/action system is pretty familiar. I have run a test using "obj_test.target" in my expression and it's working fine.

    However, what if I want to have the same condition/action for several objects with different names, do I need to change the condition and use each "button_name.target" or can I use some kind of "clicked_button.target" expression, without specifying the button name? That's the kind of stuff I could do with the other.target in game maker.

    This way, I could have the same set of condition action for all buttons.

    Thanks!

  • Either use family and a family variable (but you need at least a standard licence I think)

    or

    • put all your object in different animation frame of the same object
    • set the animation speed to 0
    • and change the initial frame (in property panel) for each of your instance in the layout.

    That's the technique used before family got implemented... I still use it in some cases though.

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