Expression to select object instead of selecting from list

0 favourites
From the Asset Store
A set of retro 16-Bit Neon UI elements to make your menus pop!
  • Hello,

    Construct 2 is a great program and I know it's impossible to please everyone, but this little feature could save hundreds of "lines" of code...

    Say, if instead of the menu that appears when you are selecting an object, you could instead select it by an expression?

    What I'm trying to do is:

    I'm trying to create at runtime a chain that is made of blocks that goes from point A to B and they're all instances of the same object. They also are meant to be joint by the physics behavior.

    How do I accomplish this? I want to make a code that is more reusable than creating the joints one by one.

  • If I understand your problem correctly, what you need to do is to put them all in to one or couple of families ( depending on what types of objects are they ) and just select those families.

  • I thought about families, but it would not prove to be the best solution.

    You see, think about a chain. This chain will go from point A to B.

    What I'm trying to do is, by loops, creating the links at runtime by just passing the position of A and B and bound each one of those by a joint.

    So the first will be bound to the second, while the second will be bound to the first and the third, and so on...

    The code would look something like this:

    While Chain.Index > 0 do:

    Chain(ObjectsCount) Create physics joint to Object(ObjectsCount+1)

    Add 1 to ObjectsCount

    But my attempts so far have proven fruitless, no matter how I try to approach it.

  • Can i have a look at your capx then if you made it in r163. You could pm it to me.

  • Sadly, I have already saved over the cap with a more raw approach(linking each one by an event...)

    I couldn`t make it work because there was no such selector, but anyway, I can recreate it and post it here so everyone can learn.

    But there`s no need for hiding the code.

    I have now the last beta r167.2

    Oh, and of course, thanks for at least try.

    EDIT: Here it goes, the cap made in r167.2

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • But i can't open it I'm afraid because I don't have the latest beta! Maybe make a screenshot then?

  • While I'm downloading and porting the code to the 163, I made this sshot:

    http://s8.postimg.org/wt1enjzph/lamp.jpg

    The code is not finished so I didn't bother to actually make the spawning of chains to stop once it reaches the top.

  • ok, I'll wait.

  • I just changed the saved version parameter in the xml and now it's opening fine in 163.

    Here it goes

  • I'm not sure what you're trying to achieve here tbh. Could try and explain it in step by step form?

  • Using the capx as an example:

    I want that just by putting the lamp in any place of the layout, the code would work to create the wires till the top of the screen.

    To create it till the top is possible as I managed to do, but to make the revolute joints follow in place has proven an impossible task till now.

  • I've managed to span and hook fios. Now got to set up few things and will post the capx

    EDIT@ Sorry man, but I can't get it to work :/ I'll try few more times

  • hey no problem. I appreciate your effort.

    There should be a way to do this... I thought about arrays but couldn't implement anything. Because it all comes down to the selectors.

    As I said earlier, if we could make the selectors more flexible with an expression, just like there is in other languages, this would be easier.

    I'm thinking of venturing myself into pluguin creation to see if I can inplement something. But that's for another time.

  • hey no problem. I appreciate your effort.

    There should be a way to do this... I thought about arrays but couldn't implement anything. Because it all comes down to the selectors.

    As I said earlier, if we could make the selectors more flexible with an expression, just like there is in other languages, this would be easier.

    I'm thinking of venturing myself into pluguin creation to see if I can inplement something. But that's for another time.

    well it seams u can only connect two objects together, or all have to be different. dunno.

  • Here are a couple of examples I made before. See if they're any help...

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