[capx] Help with created object spawn another and pin

0 favourites
  • 5 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Every random (1, 2.5) secs the system spawns a box. This box starts just outside the top of layout and travels at 90 degrees.

    I'm trying to get this box to spawn a star once its created and pin the star to the box so it moves with the box.

    When the layout starts there are about 20 blue boxes, which have spawned the stars. Those stars move with the boxes just fine. But once the boxes get destroyed outside of layout and more boxes are created, they do not spawn the stars.

    I've ran the game in debug mode and can see the boxes and stars getting destroyed. Also, the boxes are being created like they should, but they are not spawning the stars.

    Any ideas? Any input is very much appreciated.

    capx example -- https://www.dropbox.com/s/md6dqjlexsty1gm/pinn%20to__.capx?dl=0

    2 different layouts with the reverse behaviors. Still will not pin together. Can someone explain why?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sounds like a situation where a Container would be easiest solution. If the Star is in a container with the box, they will always be created together and destroyed together.

  • pedroRocha Thanks for the reply.

    I thought of that, and it would be perfect. Problem is, the star is the only thing that should get destroyed.

  • Cant run your capx right now as I don't have the right version of C2. But maybe you need to add a "wait 0 seconds" somewhere, as in:

    • box on created | spawn star

    __________________ wait 0 seconds

    __________________ move star to box position

    __________________ pin

    Construct can't handle doing somethings with objects that were just created, so we need to do that wait thing.

    i dunno... hope it helps

  • pedroRocha thanks for the tip. Got it working.

    Buy if you add the system wait action to both event sheets, now the boxpin (blue sq) won't get destroyed. It stops at the bottom of the layout.

    And the starpin (blue star) on layout 1 gets destroyed outside of layout.

    I'm sure it has something to do with the pin behavior and the position of the object it is pinned to.

    Still trying to figure that one out.

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