LibGDX ClickListener不接收输入

时间:2017-06-05 10:44:27

标签: java android libgdx

到目前为止,我已经能够将ClickListeners添加到我的所有按钮中而没有任何问题。当我尝试通过Runnable Action将侦听器添加到actor时发生了这种故障。

    RunnableAction addListener = Actions.run(new Runnable() {
        @Override
        public void run() {
            tapCounter = 0;
            egg.addListener(new ClickListener(){
                @Override
                public void clicked(InputEvent event, float x, float y) {
                    tapCounter++;
                    if (tapCounter > 3 && tapCounter < 7)
                        egg.setDrawable(new TextureRegionDrawable(eggAtlas.findRegion("egg.1")));
                    else if (tapCounter > 6 && tapCounter < 10)
                        egg.setDrawable(new TextureRegionDrawable(eggAtlas.findRegion("egg.2")));
                    else if (tapCounter > 9 && tapCounter < 13)
                        egg.setDrawable(new TextureRegionDrawable(eggAtlas.findRegion("egg.3")));
                }
            });
        }
    });

上面的代码应该在敲击一定次数时改变演员“egg”的纹理。问题是什么都没发生!我错过了什么吗?

0 个答案:

没有答案