public Rectangle intersection(Rectangle toIntersect) { float l = CameraUtils.clamp(toIntersect.left, rect.left, rect.right); float r = CameraUtils.clamp(toIntersect.right, rect.left, rect.right); float t = CameraUtils.clamp(toIntersect.top, rect.top, rect.bottom); float b = CameraUtils.clamp(toIntersect.bottom, rect.top, rect.bottom); if (t >= b || l >= r) // don't bother rendering if the texture is off screen { //return new InfiniteRectangle(); return(new Rectangle(0, 0, 0, 0)); } else { //return new InfiniteRectangle(l, t, r - l, b - t); return(asRectangle(new InfiniteRectangle(l, t, r - l, b - t))); } }
/** * To be used as a handler for onEnterFrame. Moves the camera towards its targets * @param e EnterFrameEvent */ private void stepAnimation(CEvent e) { //clamp, ease, angleModulus and nearEquals are from com.byxb.utils. _world.x = CameraUtils.clamp(CameraUtils.ease(_world.x, _targetX, _easingPan), _boundingRect.left, _boundingRect.right); _world.y = CameraUtils.clamp(CameraUtils.ease(_world.y, _targetY, _easingPan), _boundingRect.top, _boundingRect.bottom); _harness.scaleX = _harness.scaleY = CameraUtils.ease(_harness.scaleX, _targetZoom, _easingZoom); _targetRot = CameraUtils.angleModulus(_targetRot, _harness.getRotation()); _harness.setRotation(CameraUtils.ease(_harness.getRotation(), _targetRot, _easingRotate)); //_juggler.advanceTime(e.passedTime); _harness.updateRotation(); //if pretty close to all the targets, treat as having reached the targets if (!_shaking && CameraUtils.nearEquals(_world.x, _targetX) && CameraUtils.nearEquals(_world.y, _targetY) && CameraUtils.nearEquals(_harness.scaleX, _targetZoom) && CameraUtils.nearEquals(_harness.getRotation(), _targetRot)) { stopMoving(); } //dispatchEvent(CameraEvent.CAMERA_UPDATE, false, this.viewport); dispatchEvent(new CameraEvent(CameraEvent.CAMERA_UPDATE, false, this.viewport, false)); }