Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Is there a method to know if a sprite has left the camera of the stage? or I have to do my operations? :P

share|improve this question

2 Answers 2

up vote 4 down vote accepted

The Camera class contains a Frustum object with the public method pointInFrustum (Vector3 point) which returns true if your sprite is within the frustum of the camera . You can also have a look at the user wiki for other culling techniques. http://code.google.com/p/libgdx-users/wiki/Culling

share|improve this answer
    
pointInFrustum(point) returns true if the specified point is within the frustum, not a Sprite. The Sprite could have its own width and height so it can't be checked to be inside the screen using that method directly. –  arielsan Mar 6 '12 at 13:26

Just use bounding sphere check.(you can calculate radius using pythagoras ) It fast as hell and also work with rotation. It's not perfect but never cause false culling.

For ad hoc optimized version Intersector have some rectangle contain rectanle methods these can work too. But you need to calculate rectangle for camera frustum your self.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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