Search the Community
Showing results for tags 'getlocalbounds'.
-
To start, lets create a Graphics object. const clip = new PIXI.Graphics(); clip.clear(); clip.beginFill(0xAAAAAB, 0.3); clip.lineStyle(0); clip.drawRect(0, 0, 80, 60); clip.endFill(); There are getBounds() method and getLocalBounds() method in the PIXI.Graphics class. I guess one of these two methods are used to get a Rectangle bounds from the Graphics object. But which one? Is it getLocalBounds()? I find this one to be the nearest answer. So now we can use the `contains` method of PIXI.Rectangle to test if a point is in that rectangle. What if my rectangle rotates to a certain angle? like: clip.rotation = randomFloat(-Math.PI, Math.PI); randomFloat(min, max) { return min + Math.random() * (max - min); } Does my rectangle's getLocalBounds returns the correct bounds that rotates a angle? Say I want to build something like a radar that can scan dots around it. I use a very long rectangle and its pivot point is in one end and the other end just spin around the pivot point. Does the rotating rectangle's clip.getLocalBounds().contains(x, y) detect the scanned dots as it rotates? One step further, if my Graphics object also moves with a camera, which means the pivot point and the starting (x,y) of the rectangle changes all the time, I can still use this method right?