/** * Sets global game cursor using given name to find * the image cursor within assets/ui/cursors/. * Hotspot is location of the pointer end on the image. * * @param imageName name of image file * @param hotspot hotspot location */ public final void setCursor(String imageName, Point2D hotspot) { root.setCursor(new ImageCursor(FXGL.getAssetLoader().loadCursorImage(imageName), hotspot.getX(), hotspot.getY())); }
public void setCursor(PImage image, int hotspotX, int hotspotY) { int w = image.pixelWidth; int h = image.pixelHeight; WritableImage im = new WritableImage(w, h); im.getPixelWriter().setPixels(0, 0, w, h, PixelFormat.getIntArgbInstance(), image.pixels, 0, w); ImageCursor c = new ImageCursor(im, hotspotX, hotspotY); lastCursor = c; canvas.getScene().setCursor(c); }
cursorImage.getPixelWriter().setColor(padding/2, i, Color.BLACK); root.setCursor(new ImageCursor(cursorImage));