Closed Fishrock123 closed 10 years ago
Fixed, latest commit has updated and working "out of bounds" example too.
Wait what? What does the actual checking then? Meh, nevermind.
It was always checked in the preUpdate loop (comparing Sprite.bounds to game world via an intersects). Now I've just basically confirmed it works fine via a test case.
@photonstorm This issue isn't fixed -- it was about that fact that phaser does not set it.
Can we alleviate having to use .getBounds()
by assuming the last bounds is accurate?
https://github.com/GoodBoyDigital/pixi.js/blob/master/src/pixi/display/Sprite.js#L241-L242
Doesn't set what? checkWorldBounds and _bounds are both set in the constructor and checked in preUpdate.
_currentBounds, despite what it says above it in the code, doesn't seem to be checked on a pixi level at all.
We don't have a pre-check that does Sprite.checkWorldBounds = true
. So it currently never sets it.
But it's disabled by default as it's so expensive, no-where in the phaser source should it ever be set to true. If you want to check the bounds you need to enable it yourself from the game code.
You had said that Sprite.getBounds()
was the expensive part: https://github.com/photonstorm/phaser/commit/4aa945f991a205792aa3b87e364b91cdf83a918c#commitcomment-5373312
Would _currentBounds
alleviate that? Would it be accurate enough to do checks on, you think?
Or does it not change enough?
getBounds is never actually called by Pixi, so _currentBounds won't be populated (or current!). iirc it's called just once by the webgl filter manager.
A safer bounds to use would be the texture frame dimensions imho, but that won't take into account rotation or offsets from parents. There's really no easy way to do it. I guess we could add a flag similar to "this Sprite never rotates, scales or inherits from a parent" - if that was true then you'd only need to do a getBounds once and store the result. And I think in a lot of cases it would be ok too, like bullets in a shmup, or in the Invaders example game. Like a fixed rotation / ultra simple AABB.
Issue origin: 4aa945
In the current 1.2, there is no check that ever sets
Sprite.checkWorldBounds
.