本文整理了Java中com.badlogic.gdx.Graphics.newCursor()
方法的一些代码示例,展示了Graphics.newCursor()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graphics.newCursor()
方法的具体详情如下:
包路径:com.badlogic.gdx.Graphics
类名称:Graphics
方法名:newCursor
[英]Create a new cursor represented by the com.badlogic.gdx.graphics.Pixmap. The Pixmap must be in RGBA8888 format, width & height must be powers-of-two greater than zero (not necessarily equal) and of a certain minimum size (32x32 is a safe bet), and alpha transparency must be single-bit (i.e., 0x00 or 0xFF only). This function returns a Cursor object that can be set as the system cursor by calling #setCursor(Cursor) .
[中]创建由com表示的新游标。糟糕的逻辑。gdx。图样Pixmap。Pixmap必须为RGBA8888格式,宽度和高度必须为大于零(不一定相等)的二次幂,并且具有一定的最小大小(32x32是一个安全的赌注),alpha透明度必须为单位(即仅0x00或0xFF)。此函数返回一个游标对象,可通过调用#setCursor(Cursor)将其设置为系统游标。
代码示例来源:origin: libgdx/libgdx
public void create () {
Pixmap pixmap1 = new Pixmap(Gdx.files.internal("data/bobargb8888-32x32.png"));
cursor1 = Gdx.graphics.newCursor(pixmap1, 16, 16);
Pixmap pixmap2 = new Pixmap(32, 32, Format.RGBA8888);
pixmap2.setColor(Color.RED);
pixmap2.fillCircle(16, 16, 8);
cursor2 = Gdx.graphics.newCursor(pixmap2, 16, 16);
Pixmap pixmap3 = new Pixmap(32, 32, Format.RGBA8888);
pixmap3.setColor(Color.BLUE);
pixmap3.fillCircle(16, 16, 8);
cursor3 = Gdx.graphics.newCursor(pixmap3, 16, 16);
}
代码示例来源: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));
}
}
内容来源于网络,如有侵权,请联系作者删除!