How do I fuse two objects of the same type? <SOLVED>

0 favourites
  • 7 posts
From the Asset Store
Footsteps SFX Two contains 450 sounds of steps and jumps on different surfaces.
  • I´ve got one sprite; its size, speed and hp is measured through its animation frame directly, so don´t worry about any of that. I want to make it so when this sprite overlaps other of its kind, both get compared to each other and the one with the biggest or equal animation sprite gets added the number of the other´s animation frame (if the biggest´s animation frame is smaller than 8, if its animation frame is 8 nothing will happen). In the end the smallest of the two will be deleted.


    ·Sprite (frame=0) + Sprite (frame=0) = Sprite (frame=1)

    ·Sprite (frame=1) + Sprite (frame=2) = Sprite (frame=3) etc...

    I know it sounds simple, and I think it is, but I´ve been thinking for a while, and even though code I made kind of works I know it´s not the correct way of approaching it...

    Any help would be greatly appreciated.

  • This is one of those cases you use "system pick nth instance"

    From the top of my head it would be something like this:

    I'd add a global variable Exchange

    enemy is overlapping enemy

    system set Exchange to 0

    -- system pick nth instance = 1

    -- system trigger once

    system set Exchange to enemy.animationframe

    enemy destroy

    -- system pick nth instance = 0

    -- system trigger once

    system add enemy.animationframe to Exchange

    system set enemy.animationfram to Exchange

  • Ah forgot adding an extra event/condition to set Exchange back to 8 if it's higher than that..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Nope, now it doesn´t work at all :I

  • You could change the is overlapping with on collision and remove the trigger once..

    This example works, just drag and drop the sprites: ... rames.capx

  • Could it be that in your example the initial animationframe is 0, while for this to work properly it should be 1?

  • EDIT: Absolute facepalm, the initial frame was set to 0, I was setting the initial frame of a sprite with same appearance, I deeply apologise

    Thanks for everything, man, it now works sorry for being dumb

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