babycarlitos Posted May 5, 2016 Share Posted May 5, 2016 Hello everyone, I have 2 questions and I think they both deal with math. 1. How do i get the x,y, x+ width and y+ height of a sprite after setting a rotation (corners of sprite) image 1 (white background image) 2. how do i make a sprite look at the position of the mouse ( rotate to where the mouse is) I tried various version and this seems to give me the closes one var angle = Math.atan2(mouseX - (boxIMG.position.x), -(mouseY - boxIMG.position.y)); then set the rotation to that boxIMG.rotation = angle; but is not working correctly (black background image) Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted May 5, 2016 Share Posted May 5, 2016 In PIXi v4 there is sprite.calculateVertices() which calculates sprite.vertexData. https://github.com/pixijs/pixi.js/blob/dev/src/core/sprites/Sprite.js#L202 Quote Link to comment Share on other sites More sharing options...
babycarlitos Posted May 5, 2016 Author Share Posted May 5, 2016 thans ivan, that would be easier than me doing the math, just have to update to version 4. i will try that for the first question. For the future, should i do 2 posts separating the questions? I didn't do it since I figure they were somewhat related ( both deal with rotation) Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted May 5, 2016 Share Posted May 5, 2016 Better to ask here, in this thread, its yours Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.