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.


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


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.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.rotation = 45 * Math.PI / 180;

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


    document.addEventListener('mousemove', updatePosition.bind(rec));
  • \$\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\$ – jon May 3 '18 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\$ – DMGregory May 3 '18 at 11:49
  • \$\begingroup\$ you right, forgive me my forgetfulness. \$\endgroup\$ – jon May 3 '18 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.