How do I use pick by comparison or by evaluate correctly?

0 favourites
  • 6 posts
From the Asset Store
See how your Logical Resolution looks on different devices
  • Hi,

    I'm having trouble selecting a subgroup of an object's instances. For some reason I don't understand both Pick by Comparison and Pick by Evaluate don't return any results. The only condition that returns results is Pick All. What am I doing wrong?

    This doesn't work =>

    This works =>

    Here is the C3 project => jmp.sh/NO8OEmW

    Best!

  • If you are creating instanced in "On start of layout", you need to wait until they are created before you can pick them. Add "Wait 0" action to the end of event 1. Remove "Wait for previous action to complete", it won't help here.

    Also, you can pick by comparing instance variables, no need to use "System pick by evaluate". Simply do "Card compare variable index>=0"

  • I've changed "Wait for previous action" for "Wait 0". As far as a I see, they both do the same thing allowing for all the spawned instances to be created, but anyway, I did it. At the end of event 1 all the required instances are created without troubles.

    I've also changed the Pick event for just Card.Index >= 0 but it doesn't pick any instance. In fact, this was the first thing I did before trying out the Pick conditions. But the only Pick condition that seems to work is Pick All.

    This doesn't pick anything =>

    C3 Project modified => jmp.sh/aOGSGEu

  • there are two issues with the file you posted,

    first, event 6 was a compare two values statement, and wont actually pick instances. The code sample in the image you posted above will pick instances and would work - if it weren't for the second issue below.

    second, event 6 is a subevent under the "Start of Layout" event, where you spawn the two cards that get rotated. The last one of those is the only instance picked when it gets to event 6. The Wait 0 allows all the new instances to finish creating, but it doesn't undo the picked selection from the last spawn action. So, you need a system - Pick All Cards before you attempt to pick the ones with an index >= 0.

    the "Pick All" is why the previous code you posted worked, where you looped through all instances.

    here is a sample I did for someone last year, that flips cards, makes sure matches exits, shuffles, allows for different layouts, match 2,3 or 4 cards to remove them...

    https://www.rieperts.com/games/forum/MemoryGame.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • arturosanz I've never used Layouter plugin, I thought it spawns all instances at once, but looks like it creates them one by one, so only the last instance remains picked. So yeah, in this case you need to use Pick All, and a Wait 0 before that.

    Also, you don't need a loop, you can do this:

  • The loop is because I needed "loopindex" to upadte Card.Values based on an Array object items values CardList.At(loopindex(""),1). But you are right, I could use Card.IID instead of loopindex so that Card.Value is CardList.At(Card.IID-2,1) and forget the loop.

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