Swap data between two objects of the same type?

0 favourites
  • 3 posts
From the Asset Store
Full game Construct 2 capx code source to post on Google Play
  • I have managed to do this - but it's very laborious.

    If 2 objects of the same type collide, I want them to swap their angles - simple enough. (Obviously I have to use a holding variable when I swap them.)

    The problem is getting the data out of the appropriate picked object - you can't do it without picking them specifically. I ended up with something like this:

    <img src="https://dl.dropbox.com/u/104684620/Capture.JPG" border="0" />

    Maybe that doesn't look so bad, but if I want to scale it to be a little more complex than that then it quickly becomes and unreadable mess with everything copied into unreadable variables.

    Ideally I would be able to do:

    tempAngle = ant[0].angle

    ant[0].angle = ant[1].angle

    ant[1].angle = tempAngle

    Is there any way with the picking to get more elegant code like this?

  • If you make a family containing only the ant, you can try the collision between the family and the ant, then you can pick them separately

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Nice. Thanks.

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