코드가 좀길텐데,, 오류는 밑에 빨간글씨해놓았습니다.
왜 저 부분이 빨간밑줄이 됬는지 이해가안갑니다..
저에게 도움부탁드립니다. ㅜㅜ
public class game_ing extends Activity {
private GameThread m_GameThread;
class GameThread extends Thread {
private int m_nDisplayWidth; // 화면 가로 크기
private int m_nDisplayHeight; // 화면 세로 크기
private Bitmap m_bmpBg; // 배경
private Bitmap m_bmppig; // 돼지
private Bitmap m_bmppig2; // 돼지2
private Bitmap m_bmpcoin; // 동전
private SurfaceHolder m_SurfaceHolder;
public boolean m_bStop;
public GameThread (SurfaceHolder surfaceholder, Context context){
m_SurfaceHolder = surfaceholder;
Resources res = context.getResources();
// png 그림 이미지를 로딩
m_bmpBg = BitmapFactory.decodeResource(res,R.drawable.mainicon);
m_bmppig = BitmapFactory.decodeResource(res,R.drawable.pig1);
m_bmppig2 = BitmapFactory.decodeResource(res,R.drawable.pig2);
m_bmpcoin = BitmapFactory.decodeResource(res,R.drawable.ten);
// 화면의 가로, 세로 사이즈를 구함.
Display display =
((WindowManager)context.getSystemService(context.WINDOW_SERVICE)).getDefaultDisplay();
m_nDisplayWidth = display.getWidth();
m_nDisplayHeight = display.getHeight();
// 쓰레드가 작동하게 설정
m_bStop = false;
}
public void run(){
while(!m_bStop){
Canvas canvas = null;
try {
canvas = m_SurfaceHolder.lockCanvas(null);
synchronized(m_SurfaceHolder){
Rect rcSrc = new Rect();
Rect rcDest = new Rect();
rcSrc.set(0,0,470,498);
rcDest.set(0,0,m_nDisplayHeight,m_nDisplayHeight);
// 배경
canvas.drawBitmap(m_bmpBg , rcSrc, rcDest, null);
// 돼지, 동전이미지
canvas.drawBitmap(m_bmppig , 50, 50, null);
canvas.drawBitmap(m_bmppig2 , 80, 80, null);
canvas.drawBitmap(m_bmpcoin , 100, 100, null);
sleep(100);
}
}
catch (InterruptedException e){
e.printStackTrace();
}
finally{
if(canvas != null){
m_SurfaceHolder.unlockCanvasAndPost(canvas);
}
}
}
}
}
public game_ing(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
SurfaceHolder holder = getHolder();
holder.addCallback(this);
m_GameThread = new GameThread(holder, context);
}
public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
}
public void surfaceCreated(SurfaceHolder arg0) {
// TODO Auto-generated method stub
m_GameThread.start();
}
public void surfaceDestroyed(SurfaceHolder arg0) {
// TODO Auto-generated method stub
}
}