Jump to content

Not possible to change cursor through DisplayObject.cursor?


maegz
 Share

Recommended Posts

Hey all! I've been looking around for quite a while now... I am trying to be helpful with a project with some minor issues, and that project includes the new world of Pixi (fantastic stuff I must say!).

Now to the problem: We need an "ew-resize"-cursor, and it worked with defaultCursor before, but since that's now deprecated it seems impossible to make it work??? Only the default or pointer cursor is possible...

 

If I don't make any sense, please do tell me. And if I make some sense, help would be much appreciated!

Cheers,
maegz.

this.interactive = true;
this.cursor = "ew-resize"; // Does not work!!!

 

Link to comment
Share on other sites

You can add the cursor to the InteractionManager's cursorStyles dictionary like this:

app.renderer.plugins.interaction.cursorStyles["ew-resize"] = "ew-resize";
this.interactive = true;
this.cursor = "ew-resize"; // Works now!

 

Here's a working Code Pen that sets the sprite's cursor to "ew-resize":

 

Disclaimer: I got this approach from reading the source and docs for InteractionManager and trying it out in the Code Pen. So it may not be the official/best way to do it. And I only tested for the latest Pixi version 4.5.0

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...