This site requires JavaScript, please enable it in your browser!
Greenfoot back
kiarocks
kiarocks wrote ...

2011/12/20

How to make actors go on top of each other?

1
2
3
kiarocks kiarocks

2011/12/20

#
Is there such thing as setPaintOrder() for an individual? I am making a solitaire game and the cards wont fit right.
Builderboy2005 Builderboy2005

2011/12/20

#
Unfortunately Greenfoot has no way to set the paint order of individual actors that are the same class type. One alternative solutions would be to draw the images yourself onto the world background, but I can't think of any elegant solutions to this problem off the top of my head D:
danpost danpost

2011/12/21

#
You might be able to make a list of the cards in question (the list containing the suits and values of the cards you want to 'setPaintOrder' for). Next, remove those cards from the world. Then add them back into the world in the order of bottom of stack to top of stack.
kiarocks kiarocks

2011/12/21

#
Yikes, that looks hard.
danpost danpost

2011/12/21

#
Not really! Create an Actor called Pad, and add one at each location a run of cards start. The only thing that Pad needs to do is keep a list of the cards in its spread, in the order that they appear (or should appear -- bottom to top). You could add an instance int variable to track the last known number of cards there, and when it does not equal the length of the list, remove the cards and re-enter them, and update the last known number of cards. You could add a method to Pad to return the top-most card (by getting the last card from the list).
kiarocks kiarocks

2011/12/21

#
ok, ill try that
danpost danpost

2011/12/21

#
I was just thinking (maybe I should not? lol). You could add a method addCard(Card card) to Pad. Then, the pad could add it to the list, remove the card from the world, and re-create it right then (no need for 'last known number of cards'). Each card could have a reference to indicate what pad it is currently on (so you could remove that card from that pad's list before removing the card). Maybe, instead of addCard(Card card), you might use addCards(List<Card>cards) to move multiple cards at once.
kiarocks kiarocks

2011/12/21

#
Good idea, after my dinner I will try it.
danpost danpost

2011/12/22

#
@kiarocks, how is it going with the pads?
kiarocks kiarocks

2011/12/22

#
Didn't try them yet although they are in my world and I just have to write the code. Will do right now!
kiarocks kiarocks

2011/12/22

#
Would an array of Cards be ok? I like using them. ex. Card theCards;
danpost danpost

2011/12/22

#
You could go that route, but I think in this case it might be better to use an ArrayList. For one thing, you do not need to keep track of the number of cards when using ArrayList. For another thing, there are commands to add and remove subLists that would be helpful.
kiarocks kiarocks

2011/12/22

#
Nah, ill just use the list.
kiarocks kiarocks

2011/12/22

#
Still confused on how to do this, with things like references.
danpost danpost

2011/12/22

#
@kiarocks -- any progress yet?
There are more replies on the next page.
1
2
3