게임을 구상해 보려하는데
메인메뉴를 만들고 start 버튼을 누르면 게임 맵을 선택하는 화면이 뜨게 하려고 합니다.
메인 엑티비티와 메인 xml , 그리고 셀렉트 엑티비티와 셀렉트 xml을 만들었고,
셀렉트 엑티비티의 기본틀은 메인 엑티비티와 같게 만들었습니다.(소소한 이름 은 바까주고)
그리고 화면상 오류는 보이지 않는데
컴파일을 하게 되면, 빌드가 되지않는다고 빨간 경고문이 보이게 되는데
애초에 알고리즘 설정이 잘못된 것일까요?
메인엑티비티(MainActivity.java)
package android.defence;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
public class MainActivity extends Activity implements OnClickListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
View startButton = findViewById(R.id.Button_Start);
startButton.setOnClickListener(this);
View optionButton = findViewById(R.id.Button_Option);
optionButton.setOnClickListener(this);
View aboutButton = findViewById(R.id.Button_About);
aboutButton.setOnClickListener(this);
View exitButton = findViewById(R.id.Button_Exit);
exitButton.setOnClickListener(this);
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.Button_Start:
Intent i = new Intent(this, SelectActivity.class);
startActivity(i);
break;
case R.id.Button_Option:
case R.id.Button_About:
Intent intent = new Intent(this, About.class);
startActivity(intent);
break;
case R.id.Button_Exit:
finish();
break;
}
}
}
-----------------------------------------------------------------------------------------
main.xml
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:id="@+id/Main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<Button
android:id="@+id/Button_Start"
android:layout_width="155px"
android:layout_height="60px"
android:background="#00000000"
android:textColor="#ffff0000"
android:text="GAME START"
android:textSize="20sp"
android:textStyle="bold"
android:layout_x="80px"
android:layout_y="122px"
>
</Button>
<Button
android:id="@+id/Button_Option"
android:layout_width="155px"
android:layout_height="60px"
android:background="#00000000"
android:textColor="#ffff0000"
android:text="OPTION"
android:textSize="20sp"
android:textStyle="bold"
android:layout_x="250px"
android:layout_y="122px"
>
</Button>
<Button
android:id="@+id/Button_About"
android:layout_width="155px"
android:layout_height="60px"
android:background="#00000000"
android:textColor="#ffff0000"
android:text="ABOUT"
android:textSize="20sp"
android:textStyle="bold"
android:layout_x="80px"
android:layout_y="192px"
>
</Button>
<Button
android:id="@+id/Button_Exit"
android:layout_width="155px"
android:layout_height="60px"
android:background="#00000000"
android:textColor="#ffff0000"
android:text="EXIT"
android:textSize="20sp"
android:textStyle="bold"
android:layout_x="250px"
android:layout_y="192px"
>
</Button>
</AbsoluteLayout>
--------------------------------------------------------------------------------
SelectActivity.java
package android.defence;
import android.app.Activity;
//import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
public class SelectActivity extends Activity implements OnClickListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.select);
View mapOne = findViewById(R.id.map1);
mapOne.setOnClickListener(this);
View mapTwo = findViewById(R.id.map2);
mapTwo.setOnClickListener(this);
View mapThree = findViewById(R.id.map3);
mapThree.setOnClickListener(this);
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.map1:
//Intent i = new Intent(this, SelectAtivity.class);
//startActivity(i);
break;
case R.id.map2:
break;
case R.id.map3:
//Intent intent = new Intent(this, About.class);
//startActivity(intent);
break;
}
}
}
select.xml은 메인 xml과 같고 버튼만 매칭시켰습니다.
아니면, 메인메뉴에서 스타트 버튼을 누를시에 맵 선택 화면이 나오는 적절한 알고리즘을 알려주시면 감사하겠습니다.



