How do I get the same result from this function?

0 favourites
  • 4 posts
  • I was working on this function for creating a object called beast box which is a 40x40 square image that gets repeated 40 times. I'm using a loop and a array with a width of 10 and a height of 4 to achieve this.

    When I call the function the first time I get the results I want. As seen in image 2.png

    I want to destroy the boxes and recreate them each time the menu is opened. So I had the menu destroy the beast_box object when closed.

    The problem is when I open the menu a second time the boxes are created and stacked on top of each other 40 times. (see 3.png All in the top left corner instead of being spaced out in neat rows. What am I doing wrong here?

  • The problem is that beast_box.width and beast_box.height will return 0 when no beast_box object exists. Presumably the first time you have one beast_box outside the layout so it works then after you destroy them all it no longer works.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I put a create object line in the function and it fixed my issue! Thank you very much

  • You could also solve the problem by setting the position after creating the object:

    Create object beast_box at (0,0)

    Set position to ...

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