Trouble moving sprite to top of layer in a for each loop

0 favourites
  • 3 posts
From the Asset Store
SynthWave Loop Pack includes 68 seamless loops, founded on 11 original melodies. For use in game and custom works.
  • Hi,

    I've created a function in my game to arrange a bunch of sprites, representing cards, into a column, laying them out so each is on top of the other going down the screen. I'm sure I had it working some time ago, but since I've been sorting out some other issues it would appear I've changed something so now it's not working. but I can't figure out for the life of me why!

    within the function, it selects sprites based on a variable (set before calling the function), then runs a for each loop ordered by another variable. The actions within the for each loop are to set the sprites to a position based on a formula using the loopindex, and then to move the sprite to the top of the layer. The positioning part is working perfectly, so if a card with a lower value is added, it is put in the appropriate place in the column, but it doesn't seem to be rearranging the Z order, it's just leaving them in the order that they were created. I know this should work as I have an almost identical function, used on another layout, that is working properly, and as I said, I'm sure this one was working properly before!

    Here's my files. the function is called ArrangeDeck and is on the PS-Deckbuilder sheet. The action to call the function is a few events above it.

    Any help would be much appreciated, thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • hard to tell... in the AddCard function, all cards are set to PlayerNo = 1

    this may be preventing ArrangeDeck from being able to sort the cards for other players.

  • Thanks AllanR, I should have said, there is a separate event on the ps-incoming sheet, which responds to a message from a peer to add a card, and in that case sets PlayeNo to 2 (as its only a 2 player game). This function isn't working correctly on the host side either though...

    The thing I find strange is that I am sure it's arranging the cards on the x axis correctly, which is the action before move to top of layer, but it just doesn't seem to be them moving it to the top of the layer?

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