Quantcast
Channel: Pixi.js Latest Topics
Viewing all articles
Browse latest Browse all 3980

get corners of sprite after rotation

$
0
0

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)

rotation example.jpg

mousee.jpg


Viewing all articles
Browse latest Browse all 3980

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>