使用EaselJs 0.6.0,我试图使用stagemousedown和stagemousemove事件拖动我的舞台。但是,正确捕获鼠标按下事件时,似乎不会触发舞台鼠标移动事件。
var stage = new createjs.Stage("canvas");
createjs.Ticker.addEventListener("tick", tick);
stage.addEventListener("stagemousedown", startDrag);
// Container to drag around
var dragContainer = new createjs.Container();
stage.addChild(dragContainer);
//..... add stuff onto the stage
// Drag
var offset = new createjs.Point();
function startDrag(event) {
console.log('startDrag');
offset.x = stage.mouseX - dragContainer.x;
offset.y = stage.mouseY - dragContainer.y;
event.addEventListener("stagemousemove", doDrag);
}
function doDrag(event) {
console.log('doDrag');
dragContainer.x = event.stageX - offset.x;
dragContainer.y = event.stageY - offset.y;
}
// Update the stage
function tick(event) {
stage.update();
}
未调用DoDrag。我做错了什么?