Pixi.js-マウスを動かす度のイベント(mousemove)

pixijs-mousemove.png

<script src="http://miffysora.wikidot.com/local--files/webgl/pixi.min.js" type="text/javascript"></script>
<script type='text/javascript' >
var renderer = PIXI.autoDetectRenderer(200, 200,{backgroundColor : 0x533E25});
document.body.appendChild(renderer.view);
 
var stage = new PIXI.Container();
 
var sprite = PIXI.Sprite.fromImage('http://miffysora.wdfiles.com/local--files/pixijs/favisora.png');
sprite.position.set(100,80);
stage.addChild(sprite);
 
stage.interactive = true;
stage.mousemove=  function(mouseData) {
 var x = renderer.plugins.interaction.mouse.global.x;
 var y =  renderer.plugins.interaction.mouse.global.y;
sprite.position.x=x;
sprite.position.y=y;
}
 
//アニメーションスタート
animate();
function animate() {
    requestAnimationFrame(animate);
    renderer.render(stage);
}
</script>
<body>
</body>

サポートサイト Wikidot.com