그래서 jme3 엔진과 SDK를 사용하는 방법을 배웠습니다. 필자는 SimpleApplication을 확장하여 기본 응용 프로그램 파일 외부에서 작업하는 것으로 시작하여 내 응용 프로그램의 objet-orient을 더욱 자세하게 설명했습니다.SimpleApplication 외부의 물리 상태를 올바르게 초기화하는 중
내 질문은 .. 어떻게 물리 개체를 올바르게 초기화합니까? 마찬가지로 .. phyiscs라는 BulletAppState 객체가 있지만 처음에 값이 할당되지 않은 Player 클래스를 만듭니다! 생성자 내에 할당됩니다.
class Player {
BulletAppState physics;
public Player(BulletAppState physicsState) {
this.physics = physicsState; // State should now be initialized when
// this constructor is is called
}
}
그런 다음, 메인 클래스 파일
class Main extends SimpleApplcation {
Player player;
BulletAppState physics;
public static void main(String[] args) {
Main app = new Main();
app.start();
}
@Override
public void simpleInitApp() {
physics = new BulletAppState();
physics.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
stateManager.attach(physics);
player = new Player();
}
}
에서 내가 기대 원하는 결과를 얻을 수 없습니다.
출력 결과는 다음과 같습니다.
기본 클래스 물리 상태가 활성화 되었습니까? True
플레이어 등급 물리 상태가 활성화 되었습니까? False
죄송합니다. 제 입력란에 오타가있었습니다. 생성자에서 물리 객체를 전달하고있었습니다. 하지만 physics.isEnabled(); 거짓을 반환합니다. – user2723909