用javafx实现的图形界面,这个编辑功能为什么不行啊,怎么改各位们
看看你的 Friend 类,有没有定义 setName 和 setPhone 这两个方法
参数是不是 String 类型的
随机形状、移动、消行、算分等都在这个类里边实现。这个类里边不涉及UI元素,纯粹游戏逻辑。
比如消行部分的逻辑实现:
private void removeRows() {
if (preview != null) {
for (var row = 0; row < preview.getHeight(); row++) {
for (var col = 0; col < preview.getWidth(); col++) {
if (preview.getCell(row, col)) {
var cell = boardData[preview.getTop() + row][preview.getLeft() + col];
cell.visable = true;
cell.color = preview.color;
}
}
}
}
preview = null;
int removeCount = 0;
for (int row = 0; row < 20; row++) {
boolean b = true;
for (int col = 0; col < 10; col++) {
var cube = boardData[row][col].visable;
b = b && cube;
}
if (b) {
removed++;
removeCount++;
for (int ui = row - 1; ui >= 0; ui--) {
for (int uj = 0; uj < 10; uj++) {
var pre = boardData[ui][uj];
boardData[ui + 1][uj].visable = pre.visable;
boardData[ui + 1][uj].color = pre.color;
}
}
}
}
var tempScore = 0;
if (removeCount == 1)
tempScore += 100;
if (removeCount == 2)
tempScore += 200;
if (removeCount == 3)
tempScore += 400;
if (removeCount == 4)
tempScore += 400;
score += tempScore;
levelScore += tempScore;
if (levelScore >= 2000) {
if (level < 12) {
level++;
ticks = 1065 - level * 65;
} else
level = 1;
levelScore = 0;
}
}