분류 | 게시판 |
베스트 |
|
유머 |
|
이야기 |
|
이슈 |
|
생활 |
|
취미 |
|
학술 |
|
방송연예 |
|
방송프로그램 |
|
디지털 |
|
스포츠 |
|
야구팀 |
|
게임1 |
|
게임2 |
|
기타 |
|
운영 |
|
임시게시판 |
|
그 뭐시냐...
아래 View 클래스에서 화면 크기를 받아서 배치까지는 됩니다.(구글에 있는게 왠만해선 액티비티에서 받아오는거라서 뷰 클래스 에서 받는거 찾느라 고생 ㅠㅠ)
그런데 문제가 OnTouch에서 터치 위치를 지정하는데 쓰고 싶은데, OnTouch에서는 받아오질 못하더라구요
전역변수로 해결해 보려 했지만 먹히지 않고 -_-;;
혹시 아는 분 계신가요
public GameView(Context context) {
super(context);
// TODO Auto-generated constructor stub
m_Holder.addCallback(this);
Display display = ((WindowManager) context
.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
@SuppressWarnings("deprecation")
int displayWidth = display.getWidth();// 가로
@SuppressWarnings("deprecation")
int displayHeight = display.getHeight();// 세로
m_Thread = new GameThread(m_Holder, this);
setFocusable(true);
m_Res = context.getResources();
//배경
m_BG = new Background(BitmapFactory.decodeResource(m_Res,
R.drawable.background2));
m_BGOORUM = new Background(BitmapFactory.decodeResource(m_Res,
R.drawable.background_2));
//사운드
m_SoundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);
m_Sound_id_1 = m_SoundPool.load(context, R.raw.effect1, 1);
m_SoundBGM_id = m_SoundPool.load(context, R.raw.background, 1);
//캐릭터&UI
m_Sprite = new SpriteAnimation(BitmapFactory.decodeResource(m_Res,
R.drawable.player));
m_Sprite.Init(62, 104, 30, 6);
m_Sprite.SetPosition(displayWidth / 2, displayHeight - displayHeight/4 );
m_Sprite1 = new SpriteAnimation(BitmapFactory.decodeResource(m_Res,
R.drawable.enemy1));
m_Sprite1.Init(62, 104, 30, 6);
m_Sprite1.SetPosition(displayWidth / 2, 0);
m_KeyPad = new GraphicObject(BitmapFactory.decodeResource(m_Res,
R.drawable.keypad));
m_KeyPad.SetPosition(displayWidth / 6, displayHeight - displayHeight/4);
죄송합니다. 댓글 작성은 회원만 가능합니다.