コード例 #1
0
  public static void map(DisplayModel displayModel, Sprite sprite) {
    displayModel.setName(sprite.getName());
    displayModel.setImageUrl(sprite.getImageFileUrl());
    displayModel.setInitX(sprite.getInitCoordinate().getxPosition());
    displayModel.setInitY(sprite.getInitCoordinate().getyPosition());
    displayModel.setHeight(sprite.getHeight());
    displayModel.setWidth(sprite.getWidth());

    // TO-DO sprite to display mapper for event action map
    // Not needed for now
  }
コード例 #2
0
    @Override
    public void actionPerformed(ActionEvent e) {
      Map<String, ArrayList<String>> map = new HashMap<String, ArrayList<String>>();
      ArrayList<String> actions = new ArrayList<String>();
      ArrayList<String> collisionActionsEvents = new ArrayList<String>();

      // TODO Auto-generated method stub
      if (!spriteNameTextBox.getText().isEmpty()
          && !spriteXTextBox.getText().isEmpty()
          && !spriteYTextBox.getText().isEmpty()
          && Pattern.matches("\\b\\d+\\b", spriteXTextBox.getText())
          && Pattern.matches("\\b\\d+\\b", spriteYTextBox.getText())) {
        if (moveLeft.isSelected()) {
          actions.add(ActionName.MOVE_LEFT_ACTION);
        }
        if (moveRight.isSelected()) {
          actions.add(ActionName.MOVE_RIGHT_ACTION);
        }
        if (!collisionEventActionHashMap.isEmpty()) {
          for (String key : collisionEventActionHashMap.keySet()) {
            String tempActionEventCopy = new String();
            tempActionEventCopy = key + ":" + collisionEventActionHashMap.get(key);
            collisionActionsEvents.add(tempActionEventCopy);
          }
        }
        DisplayModel model = new DisplayModel();
        model.setName(spriteNameTextBox.getText().toString());
        model.setImageUrl(spriteImageComboBox.getSelectedItem().toString());
        /*	model.setWidth(Integer.parseInt(spriteWidthValue.getText()
        		.toString()));
        model.setHeight(Integer.parseInt(spriteHeightValue.getText()
        		.toString()));*/
        model.setInitX(Integer.parseInt(spriteXTextBox.getText().toString()));
        model.setInitY(Integer.parseInt(spriteYTextBox.getText().toString()));
        map.put(ActionName.KEY_PRESS_EVENT_KEY, actions);
        map.put(ActionName.COLLISION_EVENT, collisionActionsEvents);
        if (selfMove.isSelected()) {
          actions = new ArrayList<String>();
          actions.add(selfMove.getText());
          map.put(ActionName.MOVE_EVENT, actions);
        }
        model.setEventActionMap(map);
        controller.addSprite(model);
        clearFormOnReset();
        setFormValues();
      }
    }