public class Leveltwo extends Activity implements OnClickListener {
ImageView t1,t2,t3,t4,o1;
int count = 5;
int o = 2;
int touch = 0;
int timer = 0;
TextView time;
TextView text;
Handler mHandler;
SoundPool sp;
int soundID;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.leveltwo);
// TODO Auto-generated method stub
t1 = (ImageView)findViewById(R.id.t1);
t2 = (ImageView)findViewById(R.id.t2);
t3 = (ImageView)findViewById(R.id.t3);
t4 = (ImageView)findViewById(R.id.t4);
o1 = (ImageView)findViewById(R.id.o1);
time = (TextView)findViewById(R.id.time);
text = (TextView)findViewById(R.id.text);
time.setTypeface(Typeface.createFromAsset(getAssets(), "FootballGothic.ttf"));
text.setTypeface(Typeface.createFromAsset(getAssets(), "FootballGothic.ttf"));
t1.setOnClickListener(this);
t2.setOnClickListener(this);
t3.setOnClickListener(this);
t4.setOnClickListener(this);
o1.setOnClickListener(this);
sp = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);
soundID =sp.load(Leveltwo.this, R.raw.touch1,1);
Intent intent = getIntent();
timer = intent.getExtras().getInt("time",1);
mHandler = new Handler() {
public void handleMessage(Message msg) {
time.setText(String.valueOf(timer));
timer++;
//1초간의 지연 시간을 두어 1초후에 자기자신이 호출 되도록 한다.
mHandler.sendEmptyMessageDelayed(0,1000);
}
};
mHandler.sendEmptyMessage(0);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
sp.play(soundID, 1, 1, 0, 0, 1);
switch (v.getId()) {
case R.id.t1:
// sp.play(soundID, 1, 1, 0, 0, 1);
t1.setPressed(true);
t1.setVisibility(View.INVISIBLE);
count--;
break;
case R.id.t2:
// sp.play(soundID, 1, 1, 0, 0, 1);
t2.setPressed(true);
t2.setVisibility(View.INVISIBLE);
count--;
break;
case R.id.t3:
// sp.play(soundID, 1, 1, 0, 0, 1);
t3.setPressed(true);
t3.setVisibility(View.INVISIBLE);
count--;
break;
case R.id.t4:
//sp.play(soundID, 1, 1, 0, 0, 1);
t4.setPressed(true);
t4.setVisibility(View.INVISIBLE);
count--;
break;
case R.id.o1:
// sp.play(soundID, 1, 1, 0, 0, 1);
o--;
o1.setSelected(true);
if(o == 0){
o1.setVisibility(View.INVISIBLE);
count--;
}
break;
}
if(count == 0){
Intent intent = new Intent(this,Levelthree.class);
intent.putExtra("time",timer);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
overridePendingTransition(0,0);
}
}
//타이머를 처리하기 위해 핸들러 객체 생성
}
AudioFlinger could not create track, status -12 로그에서 이오류가 납니다... 소리가 났다가 안났다가 거리네요 ;;