Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (734)
Games in Android Showcase (222)
games submitted by our members
Games in WIP (811)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  libgdx - using system cursor  (Read 1225 times)
0 Members and 1 Guest are viewing this topic.
Offline DopplerFrog

Senior Newbie


Medals: 1
Exp: 3 years



« Posted 2016-12-25 11:47:50 »

Hi,

I am trying to use the change the system cursor but for some reason it keeps using the default arrow cursor.
any idea what I am missing?
I tried this in version libgdx 1.9.5 and in version 1.6.5.


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
public class CursorTest extends ApplicationAdapter {
   SpriteBatch batch;
   Texture img;
   
   @Override
   public void create () {
      batch = new SpriteBatch();
      img = new Texture("badlogic.jpg");
      Gdx.graphics.setSystemCursor(Cursor.SystemCursor.VerticalResize);
   }

   @Override
   public void render () {
      Gdx.gl.glClearColor(1, 0, 0, 1);
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
      batch.begin();
      batch.draw(img, 0, 0);
      batch.end();
   }
   
   @Override
   public void dispose () {
      batch.dispose();
      img.dispose();
   }
}


The release notes of version 1.8.0 contain this:

Quote
"- API Change: cursor API has been cleaned up. To create a custom cursor, call Graphics#newCursor(), to set the custom cursor call Graphics#setCursor(), to set a system cursor call Graphics#setSystemCursor(). The Cursor#setSystemCursor method has been removed as that was not the
right place. Note that cursors only work on the LWJGL, LWJGL3 and GWT backends. Note that system cursors only fully work on LWJGL3 as the other two backends lack a means to set a specific system cursor. These backends fall back to displaying an arrow cursor when setting any system cursor."

Maybe It has something to do with the backend. if so, how do I know what backend libgdx is using?


Offline bitbytebytes

Junior Devvie


Medals: 2



« Reply #1 - Posted 2016-12-25 14:56:51 »

Try this,

1  
2  
Pixmap pixmap = new Pixmap(Gdx.files.internal("path_to_your_cursor.png"));
Gdx.graphics.setCursor(Gdx.graphics.newCursor(pixmap, 0, 0));


it works with Gdx 1.7.1
Offline DarkCart

JGO Kernel


Medals: 121
Projects: 9
Exp: 50 years


It's all in the mind, y'know.


« Reply #2 - Posted 2016-12-25 14:57:18 »

Try this,

1  
2  
Pixmap pixmap = new Pixmap(Gdx.files.internal("path_to_your_cursor.png"));
Gdx.graphics.setCursor(Gdx.graphics.newCursor(pixmap, 0, 0));


it works with Gdx 1.7.1

He wants to use the system cursor, not make his own.


EDIT: Found your problem

1  
Gdx.graphics.setSystemCursor(Cursor.SystemCursor.VerticalResize);


When you probably copypasted this line, you didn't change the
Cursor.SystemCursor.VerticalResize
.

The darkest of carts.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline DopplerFrog

Senior Newbie


Medals: 1
Exp: 3 years



« Reply #3 - Posted 2016-12-25 21:20:06 »

1  
Gdx.graphics.setSystemCursor(Cursor.SystemCursor.VerticalResize);


If I use this I get the default arrow, but it should be a vertical line with two arrows.
I also tried the others like:

1  
2  
3  
4  
5  
Gdx.graphics.setSystemCursor(Cursor.SystemCursor.Crosshair);

or

Gdx.graphics.setSystemCursor(Cursor.SystemCursor.Hand);


but I get the default arrow every time.


Offline Lordeblader

Junior Newbie


Medals: 1



« Reply #4 - Posted 2016-12-28 00:03:52 »

I had the same problem! Maybe this helps:
http://stackoverflow.com/questions/41348420/why-setsystemcursor-isnt-working-libgdx/41353632#41353632
Offline DopplerFrog

Senior Newbie


Medals: 1
Exp: 3 years



« Reply #5 - Posted 2017-01-02 23:23:03 »

Thanks, but it does not seem to work.
I changed the build.gradle file but am unable to import the LwjglApplicationConfiguration to Lwjgl3ApplicationConfiguration and LwjglApplication to Lwjgl3Application.
How can I make gradle import the lwjgl?
I am using the 1.9.5 version of libgdx which is the latest version.

EDIT: I noticed there was a window in intellij informing me that the project was not linked with Gradle......
I've always ignored it, but linking it solved this issue.
Btw, is there any reason why the backend is not set to LWJGL3 by default?
Just curious.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 
cybrmynd (30 views)
2017-08-02 12:28:51

cybrmynd (44 views)
2017-08-02 12:19:43

cybrmynd (57 views)
2017-08-02 12:18:09

Sralse (63 views)
2017-07-25 17:13:48

Archive (494 views)
2017-04-27 17:45:51

buddyBro (641 views)
2017-04-05 03:38:00

CopyableCougar4 (1126 views)
2017-03-24 15:39:42

theagentd (1133 views)
2017-03-24 15:32:08

Rule (1108 views)
2017-03-19 12:43:22

Rule (1085 views)
2017-03-19 12:42:17
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!