madhu
madhu

Reputation: 35

how to add mouse pointer position to custom mouse pointer in createjs

Here I custom my mouse pointer to circle on that circle I want mouse pointer. Initially mouse pointer is on circle but when I moved mouse on stage mouse pointer is not on exact position on circle. 3 How to get exact position of each?

var cursor;
createjs.Touch.enable(stage);

stage.enableMouseOver();

cursor = new createjs.Shape(new createjs.Graphics().beginFill("#000000").drawCircle(0, 0, 25));
cursor.cursor = "pointer";
stage.addChild(cursor);
stage.addEventListener("stagemousemove", handleMouseMove);
stage.update();

function handleMouseMove(event) {

    cursor.x = stage.mouseX;
    cursor.y = stage.mouseY;
    stage.update();

}

Upvotes: 0

Views: 843

Answers (1)

Lanny
Lanny

Reputation: 11294

Can you clarify your question?

Here is a fiddle of your code: http://jsfiddle.net/j6erzwgn/1/

  • I removed the "updateStage" call from your handleMouseMove, and put it in a ticker event, since mouse events fire a lot faster than the stage needs.
  • I changed the Ticker to use RAF so it is nice and smooth.

Here is a sample

createjs.Ticker.on("tick", stage);
createjs.Ticker.timingMode = createjs.Ticker.RAF;

It seems to run fine. If you notice a slight delay, that is somewhat expected with custom cursors, since they aren't updated in synch with the system cursor.

Does that help? I am not sure what your other questions are asking.

Upvotes: 1

Related Questions