2014-09-17 6 views
0

저는 동전으로 찍은 이미지를 내 캐릭터가 걷는 게임을 만들고 있습니다. 내가 원하는 것은 그가 동전을 넘어갈 때 사라지는 것입니다. 나는 조사하고 부울 표현식으로 이것을 할 수 있다는 것을 이해하지만 문장을 구성하는 방법에 대해서는 잘 모르겠습니다. 이 일과 아마도 예를 어떻게 진행할 것인지에 대한 설명을 감사하게 생각합니다. 당신이 할 수있는충돌시 이미지가 사라집니다.

... 당신이 당신의 동전을 그릴 때

g.drawImage(coin1, cx1, cy1, this);         
int heightd = coin1.getHeight(this); 
int widthd = coin1.getWidth(this); 

g.drawImage(coin2, cx2, cy2, this);         
int heighte = coin1.getHeight(this); 
int widthe = coin1.getWidth(this); 

g.drawImage(coin3, cx3, cy3, this);         
int heightf = coin1.getHeight(this); 
int widthf = coin1.getWidth(this); 

g.drawImage(coin4, cx4, cy4, this);         
int heightg = coin1.getHeight(this); 
int widthg = coin1.getWidth(this); 


g.drawImage(Hood,hx , hy,this);     
int width = Hood.getWidth(this); 
int height = Hood.getHeight(this); 
+0

을 다시 그리기? –

+0

'부울 식으로이 작업을 수행 할 수 있습니다 .' !!! 'for' 루프와 다른 일반적인 (의미가 명확하지 않은) 문장으로도 할 수 있지만, 실제 정보를 제공하지는 않습니다. – Eypros

+0

@MartinFrank 나는 코인과 같은 방식으로 배경을 그려야한다. –

답변

1

당신이 배경 같은 방법으로 그릴 경우 : 이것은 내가 동전과 문자 "후드"를 표시 어떻게 당신

감사 단순히 전체 풍경 특정 동전없이 ... 당신은 배경을 그리는 어떻게

boolean drawCoin1 = true; //change this, maybe programatically 
boolean drawCoin2 = true; //like: 
boolean drawCoin3 = true; // boolean drawCoin3 = calculateCoinState(); 
boolean drawCoin4 = true; // 

if(drawCoin1){ 
    g.drawImage(coin1, cx1, cy1, this);         
    int heightd = coin1.getHeight(this); 
    int widthd = coin1.getWidth(this); 
} 

if(drawCoin2){ 
    g.drawImage(coin2, cx2, cy2, this);         
    int heighte = coin1.getHeight(this); 
    int widthe = coin1.getWidth(this); 
} 

if(drawCoin3){ 
    g.drawImage(coin3, cx3, cy3, this);         
    int heightf = coin1.getHeight(this); 
    int widthf = coin1.getWidth(this); 
} 

if(drawCoin4){ 
    g.drawImage(coin4, cx4, cy4, this);         
    int heightg = coin1.getHeight(this); 
    int widthg = coin1.getWidth(this); 
} 
+0

그건 의미가있다. 나는 그 때 그것을 할 것이다. –

+0

또한 부울 식으로이 작업을 수행하고 싶다면 어떻게해야할까요? –

+0

'Hood'의 테두리 상자가 동전의 테두리 상자와 교차하는지 확인한 다음 해당하는 drawCoinX를 false로 설정해야합니다. 이것은 내 의견에 언급 된 바와 같이 – Eypros

관련 문제