我正在開發一款android棋盤遊戲,並且遇到來自我的某個參數的錯誤。這是一個基於mancala的遊戲,其視圖(TableView.class
)包含當時的排坑和石塊,以及主要活動(Game.class
)。我正在嘗試定義一個坑及其內容。使用Java進行Android遊戲開發:無法解析參數
下面是代碼片段:
public class Game extends Activity {
int pitIndex, pitContents;
int _pitContents=4;
int pitsPerRow=5;
//more code here .......
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
table_view = getInitialTableView();
tableView = new TableView(this);
setContentView(tableView);
tableView.requestFocus();
//...more code here
//
// ...
// define a playing pit
public int Pit(int pitIndex, int pitContents) {
this.pitIndex=pitIndex;
this.pitContents=pitContents;
}
// set player1's pits and populate them
public int Player1Pits[] = new int[16*2];
{
for (int i = 0; i < (2 * pitsPerRow); i++) {
if (i < pitsPerRow) {
Player1Pits[i] = new Pit(i,_pitContents);
else {
// do nothing
}
}
}
//.....
}
我從的Eclipse得到的錯誤是「坑不能被解析爲一個類型」當我嘗試實例化一個新坑:
Player1Pits[i] = new Pit(i,_pitContents);
有人知道我要去哪裏嗎?我是否必須將Pit定義爲Game
課程之外的課程? 在發佈此問題之前,我已經詳盡搜索瞭解決方案。您的意見將不勝感激。提前致謝。
請插入你的logcat。 – iSun 2012-02-08 13:29:14
@Ali。感謝您的迴應。截至目前,我沒有logcat。由於這個錯誤,程序不會編譯。 – Buzz 2012-02-08 13:37:01
你確定你知道你在做什麼? – Shaiful 2012-02-08 13:41:04