Mouse (or finger) movement
Detect mouse movements and their positions
When the mouse (or a finger on a touch-screen device) moves, an onMouseMove event is fired. Like most events, there is an eventData object that is passed to the event functions, that you can use to get more information about the event.
App = function()
{
this.init = function()
{
// create text and add it to the scene
this.textSprite = new TextSprite('(0, 0)', '32px Arial', 'red', 'center');
this.textObject = new SceneObject(this.textSprite);
wade.addSceneObject(this.textObject);
};
this.onMouseMove = function(eventData)
{
// change text
var x = eventData.screenPosition.x;
var y = eventData.screenPosition.y;
wade.app.textSprite.setText('(' + x + ',' + y +')');
// change color
var color = wade.isMouseDown()? 'blue' : 'red';
wade.app.textSprite.setColor(color);
};
};
Your code was executed successfully!