How do I Copy/Clone Correctly

Get help using Construct 2

Post » Sun Jan 04, 2015 4:26 pm

In my game I created: a SpikesShort, and a SpikesBase that has sine behavior for the spikes to pin to. The SpikesShort are pinned to the base at start of layout. At one point a spikeshort got deleted from its base in the layout, but when i ran the game the spikes appeared, pinned to its base and both moved correctly.

I was trying to find out why and which spikesshort it was (i liked the idea of not having to move and place the spikes exactly to its base if moving the base), but because of the number of spikes and bases it got confusing. So i deleted all of the spikes and bases, except 1, and started over again. Bad idea.

At first I just copied the 1st base then the spikes, but the copied spikes would move in unison with the 1st base. So i cloned the spikes. Problem is, the spikebase(s) wouldn't move. The 1st spikebase struggled to move, as if something is holding it back.

I tried pinning the 2nd spikebase to the 2nd spikesshort, but since the spikeshort doesn't have sine behavior they both wouldn't move.

On 1 layout i have 12 of spikebase(s) and spikesshort(s) that are pinned to one another. I was trying to keep the amount of those objects down.

Is there a better way to implement the amount of spikes and bases on a layout but have them move in unison with their corresponding pin? i.e: not having 12 different bases and their corresponding spikes (24 total) in the projects window.

Sorry about the length of the post, wanted to explain it as best as i could.
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Post » Sun Jan 04, 2015 6:00 pm

So what I would do is create an instance variable on both spikebase and spikesshort objects called something like "ID". Then place as many instances of each into the layout. Then set give each pair a matching ID i.e. spikebase and spikesshort with an instance variable called ID equal to 1, another pair you could set to 2, and so on.

Then add another condition to your events to compare that spikebase.ID is equal to spikesshort.ID. This ensures which two instances will interact. You can also use the pick instance event and specify the ID to ensure your actions are being applied to the correct instance.
ImageImageImageImageImage
B
19
S
5
G
1
Posts: 614
Reputation: 2,542

Post » Sun Jan 04, 2015 6:00 pm

do they overlap?

spikebase overlapping with base
for each base
for each spikebase
spikebase (is pinned)
->pin spikebase to base (or the other way around, did not really understood your game explanation)

to pick a corresponding partner

pick base
base.UID
=
spikebase.pin.pinnedUID

or


pick spikebase
base.UID
=
spikebase.pin.pinnedUID
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Mon Jan 05, 2015 5:28 pm

Sorry @sgn15 & @TheWyrm I'm not quite understanding your suggestions, but is it possible for me to give each SpikeShort and SpikeBase a corresponding number (SpikeShort_001 SpikeBase_001 and so on) so I can only have 1 event/action (instead of multiple events/actions or variables for each paired spike and base)?

So for example the event would be something like: Pin SpikeShort to corresponding SpikeBase (SpikeShort_001 to SpikeBase_001)

So when I add another SpikeShort & SpikeBase to a layout the event/action will automatically pin them together w/o having to add another event/action or instance variable.

I'm just not that informed on variables, even though I have read entries and posts on the subject. For some reason the logic escapes me.

Thank you both again for the help.
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Post » Mon Jan 05, 2015 6:58 pm

That is basically what we are both saying with instance variables. Checkout that term in the manual.
ImageImageImageImageImage
B
19
S
5
G
1
Posts: 614
Reputation: 2,542


Return to How do I....?

Who is online

Users browsing this forum: Davlin and 6 guests