How do I make use of create-object function?

0 favourites
  • 6 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Hi,

    I used this function many times in C2, I'm not sure why I'm not able to make it work in C3. Probably I might have missed something.

    This is how it should work.

    Subscribe to Construct videos now

    When I add names, it should display them below by creating a new button but it is not happening.

    Can anyone help me with setting the create-object function? I have added the events but not sure why it is not creating a new button.

    Please let me know you need any further information.

    Thanks in advance.


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I must say, I don't understand your code.. Why do you need ButtonNameDisplayLoop variable? It's local and not static, so it will always equal 0 when you call this function.

    Also, if you need buttons to be created in a horizontal line with 104px intervals, you need to pick the last button (rightmost), and then add 104 to its x-coordinate. On your screenshot you don't pick any button instance, so the first instance will be used. If you need to create more than 2 buttons, this will become a problem.

    Then, when you are creating a new button, you have ButtonNameDisplayY+72 as X coordinate, is this a typo, shouldn't it be ButtonNameDisplayX+72?

    Finally, you don't need the last event (pick instance by UID), you can set text right after you create the button, in the same event.


    I suggest you carefully review your code, fix the issues, and use Debug Mode if there are still any problems.

  • dop2000 Thanks for your reply.

    Now, I have moved the local variables to global and corrected the typo. Still it doesn't work.

    To help you understand the code

    ButtonNameDisplayX is to record the 'X' position of the last button

    ButtonNameDisplayY is to record the 'Y' position of the last button

    ButtonNameDisplayLoop is to calculate the number of times the function is called

    In first instance

    -> ButtonNameDisplayLoop will be zero and it enables the hidden button (the first button is not created, it is already present on the screen, it is just made visible).

    -> ButtonNameDisplayX records the 'X' position of the button

    In second instance (when second name is added)

    -> Button should be created at ButtonNameDisplayX + 72 and ButtonNameDisplayY position but it doesn't happen

  • Your code is over-complicated. See this example:

  • dop2000 Thanks for the C3P, it works fine on it. I have implemented the same on my project but still it doesn't work.

    Subscribe to Construct videos now

    Not sure where I'm going wrong. :/

  • dop2000 I found issue. It is working now. Thanks alot.

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