您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

TileClicked.java 852 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package events;
  2. import com.fasterxml.jackson.databind.JsonNode;
  3. import akka.actor.ActorRef;
  4. import structures.GameState;
  5. /**
  6. * Indicates that the user has clicked an object on the game canvas, in this case a tile.
  7. * The event returns the x (horizontal) and y (vertical) indices of the tile that was
  8. * clicked. Tile indices start at 1.
  9. *
  10. * {
  11. * messageType = “tileClicked”
  12. * tilex = <x index of the tile>
  13. * tiley = <y index of the tile>
  14. * }
  15. *
  16. * @author Dr. Richard McCreadie
  17. *
  18. */
  19. public class TileClicked implements EventProcessor{
  20. @Override
  21. public void processEvent(ActorRef out, GameState gameState, JsonNode message) {
  22. int tilex = message.get("tilex").asInt();
  23. int tiley = message.get("tiley").asInt();
  24. if (gameState.something == true) {
  25. // do some logic
  26. }
  27. }
  28. }