• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Pin child image roatation and translation

Explorer ,
Jan 09, 2019 Jan 09, 2019

Copy link to clipboard

Copied

Hello community,
I am working on a project that have a protractor image and a rotation-handle image for the protractor.

The rotation-handle rotates the protractor.

rotationHandle.on("mousedown", function (evt) {

     this.parent.addChild(this);

     this.offset = {

          x: this.x - evt.stageX,

          y: this.y - evt.stageY

     };

});

rotationHandle.on("pressmove", function (evt) {

     this.x = evt.stageX + this.offset.x;

     this.y = evt.stageY + this.offset.y;

     protractor.rotation = rotationHandle.rotation = Math.atan2(protractor.y - this.y, protractor.x - this.x) * 180 / Math.PI;

});

The issue is that when I move  the protractor, I need to move the rotation-image too.

protractor.on("mousedown", function (evt) {

     this.parent.addChild(this);

     this.offset = {

          x: this.x - evt.stageX,

          y: this.y - evt.stageY

     };

});

protractor.on("pressmove", function (evt) {

     this.x = evt.stageX + this.offset.x;

     this.y = evt.stageY + this.offset.y;

});

can anybody please tell me how to achieve that.
Thanks.

Views

183

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 10, 2019 Jan 10, 2019

assign its offeset in mousedown and its x and y in pressmove.

Votes

Translate

Translate
Community Expert ,
Jan 10, 2019 Jan 10, 2019

Copy link to clipboard

Copied

LATEST

assign its offeset in mousedown and its x and y in pressmove.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines