Jump to content

Set cursor style


wm1sr
 Share

Recommended Posts

Hi there!

 

There latest version of the dev branch now supports different cursor styles.

Each sprite has a defaultCursor property 

var mySprite = PIXI.Sprite.fromImage("myPIcture.png");// to activate a custom cursor the sprite must be interactive and have button mode set to truemySprite.interactive = true;mySprite.buttonMode = true;// now you can set the cursor to be what you needmySprite.defaultCursor = "crosshair";

Hope this is useful to you!

 

 

Link to comment
Share on other sites

  • 1 year later...
  • 2 months later...

Re-iterating this: Is there a standard way of setting the cursor to be your own image/sprite?

 

We've been creating a sprite and changing its position to match the mouse pointer, but now we run into an issue where mouse events aren't triggering because the mouse is hovering on the mouse cursor sprite and not for example the button sprite you're trying to click.

Link to comment
Share on other sites

  • 1 year later...
  • 3 weeks later...

This is a little late but I was trying to do this with Pixi v4.  I needed it for the 'stage' (now a PIXI.Container I believe).  The following "works for me":

...
var stage = new PIXI.Container();
...
stage.buttonMode = true;
stage.interactive = true;
stage.hitArea = new PIXI.Rectangle(0, 0, 800, 600);
stage.defaultCursor = "url(cursor.png) 3 2, auto";

Where 'cursor.png' is the png of the cursor to use.  Note that, for me, it doesn't work without the "..., auto" at the end, nor does it work if you don't specify a 'hitArea'.

Hope that helps.

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...