[capx] Help with created object spawn another and pin

Get help using Construct 2

Post » Wed Oct 19, 2016 12:48 am

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?
Last edited by jeffige on Wed Oct 19, 2016 2:07 am, edited 1 time in total.
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Post » Wed Oct 19, 2016 1:12 am

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.
B
11
S
4
Posts: 20
Reputation: 898

Post » Wed Oct 19, 2016 2:09 am

@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.
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Post » Wed Oct 19, 2016 3:46 am

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
B
11
S
4
Posts: 20
Reputation: 898

Post » Wed Oct 19, 2016 1:40 pm

@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.
B
38
S
18
G
19
Posts: 664
Reputation: 14,107


Return to How do I....?

Who is online

Users browsing this forum: FabianB and 13 guests