Code: Select all
Local t_resourcecardsinhand = t_player.resourcecardsinhand
InsertItem(t_resourcecardsinhand, "empty", 0)
Local multiplier=0
ForEachI(t_resourcecardsinhand, Function(index, value)
If value = "empty" Then Return
LayerToFront(value)
MoveLayer(value, #USELAYERPOSITION, #USELAYERPOSITION, t_player.resourcecardx + (carddata.spacebetweencards * multiplier ), t_player.resourcecardy, {speed=carddata.movingspeed} )
multiplier = multiplier + 1
EndFunction)
RemoveItem(t_resourcecardsinhand, 0)
Code: Select all
InsertItem(t_cardsinhand, "empty", 0)
Local multiplier=0
ForEachI(t_cardsinhand, Function(index, value)
If value = "empty" Then Return
LayerToFront(value)
MoveLayer(value, #USELAYERPOSITION, #USELAYERPOSITION, x + (100 * multiplier ), y, {speed=20} )
multiplier = multiplier + 1
EndFunction)
RemoveItem(t_cardsinhand, 0)
Point of this piece of code is to arrange cards in hand (displayed on screen) in such way that the left most card would be shown on top of the other cards, and then rest of the cards would be partially hidden under previous cards, making the right most card be on bottom of every other card. Just like when you hold real playing cards in your hand.
Because of Hollywoods "Foreach" command works in such way, that location 0 is checked last, I am adding this value "empty" to index 0 so that cards would stay in same order, otherwise every time this routine is ran, all cards would change their positions to one place left, plus the left most one would change to become the most right one (or by other words, the last one).
After this routine is ran, I am using "Removeitem" to remove that index 0:s "empty" away again to make the table hold only those cards in it.
Personally I cant find a fault in this code, but when i execute it, it results in following:
https://www.dropbox.com/s/17nayj3r8rcmn ... m.jpg?dl=0
Even if it would execute all the table items in random order, it should still result only in cards changing place and still be in intended way of one being on top of the others, and rest neatly below that card, partially shown.
I have used gimp to put together those pictures of different situations to demonstrate the problem better.
Top most picture i have the original 2 cards (this piece of code havent been executed at that time yet)
Then next pictures I am taking one more card to the hand, and each time card is placed in hand, this piece of code is executed.
Strangest in this is that cards keep switching their places in relative to their neighbor cards from top to bottom each time new card is added.
I havent tried running this piece of code without new cards being add to hand. So I dont know if this is a result of more items being in table, or would this switching from top to bottom to top also happen if i would just be runing the code with same amount of cards.
Any ideas if this a bug or I am doing something wrong here?