小编Sie*_*rox的帖子

如何确定Android设备是否有加速度计?

我想检查Android设备是否有加速度计,以便我可以发出一个祝酒消息,说如果没有加速度计,游戏将无法在当前设备上正常工作.我正在寻找这样的东西:

if(DEVICE_HAS_ACCELEROMETER == false){
Toast.makeText(context,"No Accelerometer Found.",Toast.LENGTH_LONG).show();
}
Run Code Online (Sandbox Code Playgroud)

如果您可以填写DEVICE_HAS_ACCELEROMETER部分,那就可以完成这项工作.

PS:我不参加活动.

android accelerometer

6
推荐指数
1
解决办法
4766
查看次数

没有使用TextButton调用Libgdx InputListener"exit()"

我想在InputListener中使用exit()方法来查看光标是否在按钮内.

以下是libGDX文档中的解释.

public void exit(InputEvent event, float x, float y, int pointer, Actor toActor)
Run Code Online (Sandbox Code Playgroud)

每当鼠标光标或手指触摸移出演员时调用.

但是当我将光标放在按钮上然后将其移到按钮外时,不会调用该方法.我正在测试它System.out.println("exited");,我在控制台中什么都没得到.

编辑:

LibGDX版本:最新稳定的夜莺

InputListener实现:

//This button class is a custom class to make button creation easier. This is the constructor.
public Button(Vector2 position, String packLocation, String text, Stage stage, BitmapFont font, Color color) {

//Removed buttonStyle creation etc. to shorten the code.
    button = new TextButton(text, buttonStyle);
    button.setPosition(position.x, position.y);
    stage.addActor(button);
    Gdx.input.setInputProcessor(stage);
    pressed = false;

    button.addListener(new ClickListener() {

        @Override
        public boolean touchDown(InputEvent event, …
Run Code Online (Sandbox Code Playgroud)

java android input listener libgdx

3
推荐指数
1
解决办法
623
查看次数

标签 统计

android ×2

accelerometer ×1

input ×1

java ×1

libgdx ×1

listener ×1