Change Families

0 favourites
  • 11 posts
  • Hi guys!

    Just wondering if there's a way for an item to change families during runtime.

    Say for example I want a circle to move around the screen and bump into another circle... the player would then lose control of the first, and start controlling the second. I could do this with 1 or two, but say I want to be able to do this with hundreds of circles. I would have a code that reads:

    If family.control touches family.noControl then change family.control to family.noControl and change family.noControl to family.control.

    Hmm... confused myself there. In any case. Anybody got an idea on whether this is possible, and if so, care to share how?

    I can figure out how to have the objects take control of one another like a zombie mode (touch gives player control over additional objects until you're controlling all 100), but I do not know how to have it so you only control 1 at a time.

  • Also, another quick question... how does families instance variables work? I can't seem to set any...

  • create a boolean 'controlled' in your circle object with default false except for the one you want to control at start of layout

    And then if circle collide with circle, toggle 'controlled'

  • Thanks Yann, but that doesn't seem to work with families. If I have lots of different items all in the same family, I want to have the code:

    If family collide with family, toggle 'controlled'

    but it doesn't look like it works just yet. I would have thought I'd see all of the variables that appear within the sprites in the family.

  • You dont need to use families.

    If you have a instance boolean called controlled then compare the boolean when arrow is down ect then if the boolean is set to false then you cannot controll it, And set the boolean to the other one true..

  • Thanks for replying smitchell!

    I'm talking about potentially hundreds of different objects. Is it possible to set it up this way? Will I have to set up events for every single item?

    If sprite1.boolean1 = true - activate control

    If sprite2.boolean1 = true - activate control


    Can families have variables? The option is there, but it's always inaccessible.

  • I don't know about your game but I'm pretty sure you can put all your potentially hundreds of different objects in one only sprite.

    But to be sure it would be good to explain a bit more about your game.

    Also variable for families... Ash is probably working on it. Families are pretty new.

  • I see... families also doesn't work with physics.

    I wanted to set it up so if an object touches another one, it would swap control to that one... but instead of the 'move forward' that is currently set up, it would use forces with physics.

    Am I going to have to wait a bit longer for the additional feature?

  • Again, why don't you put all your object in different animation frame of one only sprite and use a bolean to switch control on and off ?

  • I'm not sure how that would work... some of the items I need to control will be 'chained', attached or linked in some way to other objects. I would have to have an event setting the animation frame at start, wouldn't I?

    Suppose it could work... but again I'd have a lot of events which I'm trying to cut down on.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can set the initial frame in property, and to chain different instance... It's probably not exactly what you want, but in this idea I did a rop example a while ago


    But still without much detail about your game we can't really say that it's the best solution for you.

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