How do I Copy/Clone Correctly

0 favourites
  • 5 posts
From the Asset Store
The Lift
$5 USD
Easy copy/paste lift function for 2D platformer type games
  • 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.

  • 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.

  • 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

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That is basically what we are both saying with instance variables. Checkout that term in the manual.

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