2014-07-03 36 views
1
組工作

我有我的舞臺已經添加在我的屏幕libGDX:輸入處理器不能與

//Code in show() method of my screen 
MyGroup myGroup = new MyGroup(); 
Stage stage = new Stage(); 
stage.add(myGroup); 
//And also there are few more actors which are omitted 
Gdx.input.setInputProcessor(stage); 

//Code in my group 
public MyGroup extends Group implements InputProcessor{ 
//Many methods and attributes and a constructor 
//Overridden methods of input listener. 

在我組我有5個演員可以彼此這樣被交換一組,我不想以處理個人蔘與者的任何投入。我想在小組中做到這一點。

但是當我觸摸/ touchDrag時,沒有任何方法被調用。

請幫忙。

回答

4

這是因爲您的MyGroup未註冊爲當前活動的InputProcessor。您需要使用InputMultiplexer才能註冊StageGroup

InputMultiplexer inputMultiplexer = new InputMultiplexer(); 
inputMultiplexer.addProcessor(stage); 
inputMultiplexer.addProcessor(myGroup); 
Gdx.input.setInputProcessor(inputMultiplexer); 
+0

Thanks @noone。它的工作現在:) –

+0

現在我面臨一個更多的問題。也就是說,我從touchDragged事件獲得的觸摸座標是通過X軸鏡像的。任何想法爲什麼發生這種情況? –

+0

那麼,這些座標是屏幕空間座標。舞臺和演員有特殊的方法將座標轉換爲不同的座標系。例如screenToStage或stageToLocal。 – noone