/** * Initialization */ public void begin(){ int bx = 0; int by = 0; int px = 0; int py = 0; for(int i = 0; i < IMG_NUM; i++){ bx = BOARD_MARGIN_X + SIDE_LENGTH * (i % PIECES_PER_COL); by = BOARD_MARGIN_Y + SIDE_LENGTH * (i / PIECES_PER_ROW); px = PUZZLE_OFFSET + PUZZLE_SPACING * (i % PIECES_PER_COL + 1) + SIDE_LENGTH * (i % PIECES_PER_COL); py = PUZZLE_SPACING * (i / PIECES_PER_ROW + 1) + SIDE_LENGTH * (i / PIECES_PER_ROW); //x,y coordination of puzzle & board pieces img[i] = getImage("p" + i + ".jpg"); bLocation[i] = new Location(bx, by); pLocation[i] = new Location(px, py); } text = new Text("YOU WIN!!!", TEXT_X, bLocation[TEXT_LOCATION].getY(), canvas); text.setFontSize(FONT_SIZE); text.setBold(true); text.setColor(Color.GREEN); text.hide(); //pass pieces objects into arrays for(int i = 0; i < IMG_NUM; i++){ bp[i] = new BoardPiece(img[i], i, bLocation[i], canvas); pp[i] = getRandomPiece(pLocation[i], canvas); } }
// Create a FramedText object displaying the text 'contents' // at the position and with the dimensions specified. public FramedText( String contents, double x, double y, double width, double height, DrawingCanvas canvas) { // construct the frame super(x, y, width, height, canvas); // Construct and appropriately position the message message = new Text(contents, x, y, canvas); message.setColor(Color.white); positionContents(); }