createjs在movieclip中的Y位置

时间:2015-09-02 11:16:04

标签: createjs

我在动画片段中播放动画中的图形 我想要做的是在动画片的动画片中获取图形的x和y位置。

但我发现x和y没有更新,即使此刻,我正在勾选功能,我正在使用globalToLocal

function tickHandler(event) {
//get the x and y of this mc using globalToLocal 
console.log(exportRoot.game_anim.meterMC.awd.globalToLocal(exportRoot.game_anim.meterMC.awd.x, exportRoot.game_anim.meterMC.awd.y))

stage.update();
}

exportRoot.gotoAndStop("game")
exportRoot.game_anim.meterMC.arrowYou.addEventListener("mousedown",function (evt) {
var _this = evt.target

 var mouseRight = 0;
 var mouseLeft = 180;

 var offset = {x: _this.x - evt.stageX, y: _this.y - evt.stageY};

 evt.addEventListener("mousemove" , function(ev){
// )

 var pt = exportRoot.game_anim.meterMC.globalToLocal(stage.mouseX, stage.mouseY)


 if ( pt.y > mouseLeft){
    percent = 100;
} else if (pt.y < mouseRight){
    percent = 0;
} else {

    percent = Math.round(((pt.y - mouseRight) / (mouseLeft - mouseRight)*100));
_this.y = pt.y; 
}
 if ( pt.y > mouseLeft){ 

}

;

})

});

1 个答案:

答案 0 :(得分:1)

尝试在目标剪辑中使用带有静态点的localToGlobal。例如: var pt = myMC.subMC.localToGlobal(0,0); console.log(pt.x, pt.y);