2016-07-03 6 views
1

이미지 버튼이 있는데 프로그램이 시작될 때 비활성화하고 특정 조건에서 사용하도록 설정해야합니다. 프로그램을 시작하고 심지어 button.setDisabled (참) 방법으로 시험 하였을 때libgdx에서 버튼을 비활성화하는 방법

다음

내 코드는,

public Screen() //constructor 
{ 
    ImageButton hints; 
    ImageButton.ImageButtonStyle hintsstyle = new ImageButton.ImageButtonStyle(); 
    hintsstyle.up = skin.getDrawable("newrightbut"); 
    hintsstyle.down = skin.getDrawable("newrightbut"); 
    hintsstyle.pressedOffsetX = 1; 
    hints = new ImageButton(hintsstyle); 
    hints.setPosition(650, 35); 
    hints.setHeight(70); 
    hints.setWidth(70); 
    stage.addActor(hints); 
    hints.setTouchable(Touchable.disabled); 
} 

public void update() 
{ 
    hints.setTouchable(Touchable.enabled); 
} 

하지만, 버튼이 비활성화 받고 있지 않습니다. 또한 작동하지 않습니다. 왜 그런가? 어떤 도움이 좋을지 !! 감사합니다

+0

은 변수 선언 코드를 공유합니다. – Enigo

답변

0

이 문제는 현재 생후 5 개월이지만 관계없이 대답하려고합니다.

ImageButton hints은 생성자 내에서 선언되므로 (해당 범위는 생성자로 제한됩니다).

생성자 외부의 메서드에서 컴파일 오류를 호출하지 못하게하는 유일한 방법은 클래스 내에 다른 메서드를 선언 한 경우뿐입니다.

결론 : 응용 프로그램의 다른 곳에서 선언 했어야하며 모든 기본값이 사용 가능해야합니다.

관련 문제