コード例 #1
0
  public SlidingLetterRailBase(
      int sectionLeft,
      int sectionTop,
      int sectionWidth,
      int sectionHeight,
      GameController gameController) {
    super(sectionLeft, sectionTop, sectionWidth, sectionHeight, gameController);

    tileAttrs = MovingLetterTileAttributes.getInstance(gameController);

    firstLetterLeftMax = sectionLeft + Assets.padding;
    lastLetterLeftMin = sectionLeft + sectionWidth - Assets.padding - tileAttrs.getTileDimension();

    letterTiles = new LetterTile[getTileCount()];
    tilesToAdjust = new boolean[getTileCount()];

    letterPickupOffset =
        (int) (LETTER_PICKUP_OFFSET_BASE * gameController.getGraphics().getScale());

    label = getLabel();
    centerWidth = sectionWidth / 2 + sectionLeft;
    labelBaseline = sectionTop + sectionHeight - Assets.padding;

    initializeTiles();
  }
コード例 #2
0
 private DisplayLetterTileAttributes(GameController gameController) {
   // remove one padding from width, then base tile dimen on the # of tiles we want to fit across
   // the screen, then subtract one padding from the width. This should leave us with
   // MAX_WORD_LENGTH
   // tiles and left padding and one more right padding to fill the screen.
   tileDimension =
       ((gameController.getGraphics().getWidth() - Assets.padding)
               / Assets.DISPLAY_LETTERS_PER_SCREEN)
           - Assets.padding;
   letterTextSize = tileDimension * LETTER_TEXT_SIZE_RATIO;
   Rect bounds = new Rect();
   gameController
       .getGraphics()
       .getTextBounds("A", letterTextSize, LETTER_TYPEFACE, LETTER_ALIGNMENT, bounds);
   letterBaselineFromTileTopOffset = (tileDimension / 2) + (bounds.height() / 2);
 }