Cycle 7: Add player names, blinking for the current player It would be a nice feature to display the player's name close to the card hand. To further improve the user interface, the name of the player who makes the next draw could be blinking. Because the player names are defined dynamically when the players enter the game room, the blinking text is created as an instance of the class TextActor. Blinking can be obtained by showing and hiding the sprite image periodically using the act() method. To realize this idea we declare an additional class BlinkingName as follows: // BlinkingName.java The blinking names for each players are stored in the CardGame class as an array instance variable: private BlinkingName[] blinkingNames = new BlinkingName[nbPlayers]; and initialized in the CardTable constructor: for (int i = 0; i < playerNames.length; i++) We declares in a array instance variable where to show the text: private final Location[] nameLocations = addActor(blinkingNames[toPlayerId(i)], textLocations[i]); We may even align the text properly: if (i == 0 || i == 2) // Center align text protected void setBlinking(int playerId) We invoke this method at several occasions: First whenever the player dropped out (using playerId = - 1), then in setMyTurn() using myPlayerId. Finally in setOtherTurn(), but here we need the information of the current player's id. It your work to implement the code to get this information from the server. Proposal: On the server side you include the current player id as command parameter in the OTHER_TURN command and fetch it as data[1] in the Command.OTHER_TURN case of the Player's dataReceived() callback. Then you pass the id via a parameter to the setOtherTurn() method. Execute the solution you should obtain (with 4 players). | ||