-3
\$\begingroup\$

how i can perform for sprite follow mouse if i change angle ? If i change angle the sprite no more follow mouse correctly. I absolutely need the obj follow mouse with pivot.

https://jsfiddle.net/jonforum/ow9w7rfz/10/

thank a lot for help

edit: if you can help me with math problem !

How i can compute from a sprite (radian.skew,pivot) a new point XY ?

Example i move pivot to XY. And i move rotation to ( randian || degree ) After i move again pivot with mouse compute... all became weird..

How i can compute rotation but base on the position from pivot ? for now here it my try code. thank guys, i have difficult with deep math. Also, I would like to compute skew

enter image description here

\$\endgroup\$
0

1 Answer 1

0
\$\begingroup\$

This looks like it might be as simple as setting your position, instead of your pivot.

// add a graphics instance
var rec = new PIXI.Graphics();
rec.beginFill(0x00ff00);
rec.drawRoundedRect(-20, -65/2, 40, 65, 4); // Shifted so the rect is centered across 0,0

// setup
rec.pivot.set(0,0);                         // Pivot at the center 0,0
rec.position.set(500/2,500/2);
rec.rotation = 45 * Math.PI / 180;
stage.addChild(rec);
renderer.render(stage);


//** listener ********
    var updatePosition = function(event) {
      this.position.set(event.layerX,event.layerY); // Set postion, no offset.

      renderer.render(stage);
    };

    document.addEventListener('mousemove', updatePosition.bind(rec));
\$\endgroup\$
3
  • \$\begingroup\$ thank you but I must keep the position. In this context the pivot is used for the z Index. the position is the position of the sprite on the map, and pivot are the z Index. this can help to understand youtu.be/MpZD0E0_iKI \$\endgroup\$ Commented May 3, 2018 at 11:46
  • \$\begingroup\$ If you have an important constraint like that, please always describe it in your question. Users here are not mind-readers, and know nothing about your project except what you tell us explicitly. \$\endgroup\$ Commented May 3, 2018 at 11:49
  • \$\begingroup\$ you right, forgive me my forgetfulness. \$\endgroup\$ Commented May 3, 2018 at 11:59

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.