how to add mouse pointer position to custom mouse pointer in createjs - Javascript Canvas

Javascript examples for Canvas:Mouse

Description

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

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Mouse Move</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.createjs.com/createjs-2015.11.26.combined.js"></script> 
      <script type="text/javascript">
    window.onload=function(){/*from  ww w  . j  a v  a 2  s  .  co m*/
var stage = new createjs.Stage("canvas");
createjs.Ticker.on("tick", stage);
createjs.Ticker.timingMode = createjs.Ticker.RAF;
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);
function handleMouseMove(event) {
    cursor.x = stage.mouseX;
    cursor.y = stage.mouseY;
}
    }

      </script> 
   </head> 
   <body> 
      <canvas id="canvas" width="800" height="600"></canvas>  
   </body>
</html>

Related Tutorials