com.badlogic.gdx.Graphics.setCursor()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(150)

本文整理了Java中com.badlogic.gdx.Graphics.setCursor()方法的一些代码示例,展示了Graphics.setCursor()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graphics.setCursor()方法的具体详情如下:
包路径:com.badlogic.gdx.Graphics
类名称:Graphics
方法名:setCursor

Graphics.setCursor介绍

[英]Only viable on the lwjgl-backend and on the gwt-backend. Browsers that support cursor:url() and support the png format (the pixmap is converted to a data-url of type image/png) should also support custom cursors. Will set the mouse cursor image to the image represented by the com.badlogic.gdx.graphics.Cursor. It is recommended to call this function in the main render thread, and maximum one time per frame.
[中]仅在lwjgl后端和gwt后端上可行。支持cursor:url()并支持png格式(pixmap转换为image/png类型的数据url)的浏览器也应该支持自定义游标。将鼠标光标图像设置为com表示的图像。糟糕的逻辑。gdx。图样光标。建议在主渲染线程中调用此函数,每帧最多调用一次。

代码示例

代码示例来源:origin: libgdx/libgdx

public void render () {
    // set the clear color and clear the screen.
    Gdx.gl.glClearColor(1, 1, 1, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    if (Gdx.input.isTouched()) {
      Gdx.graphics.setCursor(cursor1);
    } else {
      cursorActive = !cursorActive;
      if (cursorActive) {
        Gdx.graphics.setCursor(cursor2);
      } else {
        Gdx.graphics.setCursor(cursor3);
      }
    }
  }
}

代码示例来源:origin: kotcrab/vis-ui

/** Restores currently used cursor to default one. */
  public static void restoreDefaultCursor () {
    if (systemCursorAsDefault) {
      Gdx.graphics.setSystemCursor(defaultSystemCursor);
    } else {
      Gdx.graphics.setCursor(defaultCursor);
    }
  }
}

代码示例来源:origin: com.github.nifty-gui/nifty-libgdx-renderer

/**
 * Disables (hides) the mouse cursor image specified in {@link #GdxMouseCursor(GdxImage, int, int)}. Restores (shows)
 * the system mouse cursor image.
 */
@Override
public void disable() {
 Gdx.graphics.setCursor(Gdx.graphics.newCursor(null, hotspotX, hotspotY));
}

代码示例来源:origin: nifty-gui/nifty-gui

/**
 * Disables (hides) the mouse cursor image specified in {@link #GdxMouseCursor(GdxImage, int, int)}. Restores (shows)
 * the system mouse cursor image.
 */
@Override
public void disable() {
 Gdx.graphics.setCursor(Gdx.graphics.newCursor(null, hotspotX, hotspotY));
}

代码示例来源:origin: nifty-gui/nifty-gui

/**
 * Enables (shows) the mouse cursor image specified in {@link #GdxMouseCursor(GdxImage, int, int)}. Replaces (hides)
 * the system mouse cursor image.
 */
@Override
public void enable() {
 try {
  if (cursorImage.hasPixmap()) {
   Gdx.graphics.setCursor(Gdx.graphics.newCursor(cursorImage.getPixmap(), hotspotX, hotspotY));
  }
 } catch (GdxRuntimeException e) {
  log.log(Level.SEVERE, "Applying the mouse cursor failed!", e);
 }
}

代码示例来源:origin: com.github.nifty-gui/nifty-libgdx-renderer

/**
 * Enables (shows) the mouse cursor image specified in {@link #GdxMouseCursor(GdxImage, int, int)}. Replaces (hides)
 * the system mouse cursor image.
 */
@Override
public void enable() {
 try {
  if (cursorImage.hasPixmap()) {
   Gdx.graphics.setCursor(Gdx.graphics.newCursor(cursorImage.getPixmap(), hotspotX, hotspotY));
  }
 } catch (GdxRuntimeException e) {
  log.log(Level.SEVERE, "Applying the mouse cursor failed!", e);
 }
}

代码示例来源:origin: langurmonkey/gaiasky

@Override
  public boolean handle(Event event) {
    if (event instanceof InputEvent) {
      Type type = ((InputEvent) event).getType();
      // Click
      if (type == Type.enter) {
        Gdx.graphics.setCursor(Gdx.graphics.newCursor(GlobalResources.linkCursor, 4, 0));
      } else if (type == Type.exit) {
        Gdx.graphics.setSystemCursor(SystemCursor.Arrow);
      }
      return true;
    }
    return false;
  }
});

代码示例来源:origin: langurmonkey/gaiasky

@Override
  public boolean handle(Event event) {
    if (event instanceof InputEvent) {
      Type type = ((InputEvent) event).getType();
      if (type == Type.enter) {
        if (!me.isDisabled())
          Gdx.graphics.setCursor(Gdx.graphics.newCursor(cursor != null ? cursor : GlobalResources.linkCursor, 4, 0));
        return true;
      } else if (type == Type.exit) {
        Gdx.graphics.setSystemCursor(SystemCursor.Arrow);
        return true;
      }
    }
    return false;
  }
});

代码示例来源:origin: langurmonkey/gaiasky

@Override
  public boolean handle(Event event) {
    if (event instanceof InputEvent) {
      Type type = ((InputEvent) event).getType();
      if (type == Type.enter) {
        if (!me.isDisabled())
          Gdx.graphics.setCursor(Gdx.graphics.newCursor(cursor, 4, 0));
        return true;
      } else if (type == Type.exit) {
        Gdx.graphics.setSystemCursor(SystemCursor.Arrow);
        return true;
      }
    }
    return false;
  }
});

代码示例来源:origin: langurmonkey/gaiasky

@Override
  public boolean handle(Event event) {
    if (event instanceof InputEvent) {
      Type type = ((InputEvent) event).getType();
      // Click
      if (type == Type.touchUp && ((InputEvent) event).getButton() == Buttons.LEFT) {
        Gdx.net.openURI(linkURL);
      } else if (type == Type.enter) {
        Gdx.graphics.setCursor(Gdx.graphics.newCursor(GlobalResources.linkCursor, 4, 0));
      } else if (type == Type.exit) {
        Gdx.graphics.setSystemCursor(SystemCursor.Arrow);
      }
      return true;
    }
    return false;
  }
});

代码示例来源:origin: langurmonkey/gaiasky

private void initialize(Skin skin) {
    this.addListener(event -> {
      if (event instanceof InputEvent) {
        InputEvent.Type type = ((InputEvent) event).getType();
        // Click
        if (type == InputEvent.Type.touchUp && ((InputEvent) event).getButton() == Input.Buttons.LEFT) {
          Gdx.net.openURI(linkURL);
        } else if (type == InputEvent.Type.enter) {
          Gdx.graphics.setCursor(Gdx.graphics.newCursor(GlobalResources.linkCursor, 4, 0));
        } else if (type == InputEvent.Type.exit) {
          Gdx.graphics.setSystemCursor(Cursor.SystemCursor.Arrow);
        }
        return true;
      }
      return false;
    });

    this.addListener(new OwnTextTooltip(linkURL, skin, 10));
  }
}

相关文章