Complex arrays

0 favourites
  • Yann Animmaniac

    Ok I see, but it's not what I want, so I explain better myself.

    I am accostomed to "normal" game engines where I could select an object by its name regardless if there were 0,1 or 1000 with the same name.

    I basically have this.

    I'm selecting a string out of 50 with tokenat.

    On the layout there are 50 insvisible object (all on the same position) which have the same name as the 50 possitble strings that I select with token.

    I need to: select "string from tokenat" object -> set visible

    I think it should be possible to do this but I can't find a solution.. I mean I should put 50 if condition but it's a tedious and stupid way of working the problem.

    Ideas?

    Thanks

  • Ok, I think we are running in circle, you should describe a bit more about your game, the solution might be quite simple, but just asking for some specific feature might not be the correct angle to tackle this problem.

  • You want to select only one of those 50 objects and make it visible, or you want to select all objects?

  • It's the second time the forum errors me and I lose 10 minutes of writing..

    Yann I'll try to explain myself better.

    I'm making an educational application for handicapped children and I need to procedurally generate a question on startup.

    Let's make an example:

    var pool = "book,table,spoon,lamp";

    var answer = tokenat( pool , floor( random( tokenCount(pool ,",") ) ), "," );

    //On the layout there are four hidden objects called (book,table,spoon,lamp) each of them has at least 10 frames, so I can't create only one object and then calling a random frame.

    I now need to: System set object called answer visible

    Basically I have 50 invisible objects and I need to make one visibile.

    Animmaniac only one of those 50 objects and make it visible

  • You could very well use only a single sprite with different animations.

    On startup you select a random instance and set it to use the animation of your choice.

    Capx for creating a random anim Sprite

    Now what you want is to have sprites already spawnt along the layout apparently.

    Commented capx for this

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Damn I've been Kyat ninja'd

    /On the layout there are four hidden objects called (book,table,spoon,lamp) each of them has at least 10 frames, so I can't create only one object and then calling a random frame.

    You can... And you should!

    Basically I would setup the layout this way:

    A Sprite called 'item' in which you put your animation of book,table,spoon,lamp.

    Name the animations properly.

    Then if you want to call a random object

    System: Create item
    item: set animation to tokenat( pool , floor( random( tokenCount(pool ,",") ) ), "," );

    If you want to pick a specific object and play his animation

    item: is animation "spoon" is playing
      -> item: start animation from current frame

    Little remarque on the last one: even if the animation is stopped as long as you display a frame from a specific animation the "is animation playing" is true.

    In short you can use the name of the animation as... naming as you implied I think.

    Also, if you have many animation per object, you can still use the name as a prefix

    spoon_idle, spoon_run (oh noes a running spoon /o/)

  • Yann, Kyatric as usual thanks.

    I see there's always a solution to my problems, next time I'll approach the problem with a different attitude.

    Love

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