How do I arrange cards so they don't overlap?

0 favourites
  • 2 posts
From the Asset Store
Tap the ball, control it, avoid touching spikes and score higher!
  • I've got a line of cards in a family, and they move every few seconds. As they go away, I'd like the remaining cards to move a little to fill the gaps.

    Is there any way to call the "arrange/space/vertical" ability that I can do in the layout right-click, but as an action ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's very easy to distribute sprites using lerp expression. For example:

    Card set X to lerp(50, 500, card.iid/(Card.count-1))

    If you need to do this only for some sprite instances, say you need to re-arrange cards that belong to player 1:

    Card compare instance variable player=1
     local variable NumberOfCards
    	Set NumberOfCards to Card.pickedCount
    
     System for each Card
    	Card set X to lerp(50, 500, loopindex/(NumberOfCards-1))
    

    The above will work better for a large number of cards. When there are only 1-3 cards left, they will be too far apart. If you need to keep cards together, say at fixed 80px distance from each other, you need to use some other method. For example:

    Card set X to Card.iid*80 + (LayoutWidth/2-(Card.Count-1)*80/2)
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)