【问题标题】:createjs Y position inside of movieclip在movieclip内createjs Y位置
【发布时间】:2015-09-02 11:16:04
【问题描述】:

我在影片剪辑中播放的动画中有一个图形 我想要做的是获取动画剪辑中图形的 x 和 y 位置。

但我发现 x 和 y 没有更新,即使目前我在 tick 函数中检查,我正在使用 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){ 

}

;

})

});

【问题讨论】:

    标签: createjs


    【解决方案1】:

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

    【讨论】:

    • 谢谢你的回答我会试试看
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-17
    • 1970-01-01
    • 2014-03-19
    • 2011-12-12
    • 1970-01-01
    • 2017-07-01
    • 2021-04-12
    相关资源
    最近更新 更多