public override void update()
{
//zooming = FlxG.zoom;
//rotating = FlxG.rotation;
//follow closely or check deadzones
if (target != null)
{
if (deadzone == null)
{
focusOn(target.getMidpoint()); //add getMidpoint() for FlxObjects
}
else
{
//FlxG.log("deadzone is not null");
float edge;
float targetX = FlxU.ceil(target.x + ((target.x > 0) ? 0.0000001f : -0.0000001f));
float targetY = FlxU.ceil(target.y + ((target.y > 0) ? 0.0000001f : -0.0000001f));
edge = targetX - deadzone.x;
if (scroll.x > edge)
scroll.x = edge;
edge = targetX + target.width - deadzone.x - deadzone.width;
if (scroll.x < edge)
scroll.x = edge;
edge = targetY - deadzone.y;
if (scroll.y > edge)
scroll.y = edge;
edge = targetY + target.height - deadzone.y - deadzone.height;
if (scroll.y < edge)
scroll.y = edge;
//SHAKE
}
}
//make sure we didnt go outside camera's bounds
if (bounds != null)
{
//FlxG.log("bounds is not null");
if (scroll.x < bounds.left)
scroll.x = bounds.left;
if (scroll.x > bounds.right - width)
scroll.x = bounds.right - width;
if (scroll.y < bounds.top)
scroll.y = bounds.top;
if (scroll.y > bounds.bottom - height)
scroll.y = bounds.bottom - height;
}
//update effects
//shake
if (_fxShakeDuration > 0)
{
_fxShakeDuration -= FlxG.elapsed;
if (_fxShakeDuration <= 0)
{
_fxShakeOffset.make();
if (_fxShakeComplete != null)
_fxShakeComplete();
}
else
{
if ((_fxShakeDirection == SHAKE_BOTH_AXES) || (_fxShakeDirection == SHAKE_HORIZONTAL_ONLY))
_fxShakeOffset.x = (FlxG.random() * _fxShakeIntensity * width * 2 - _fxShakeIntensity * width) * _zoom;
if ((_fxShakeDirection == SHAKE_BOTH_AXES) || (_fxShakeDirection == SHAKE_VERTICAL_ONLY))
_fxShakeOffset.y = (FlxG.random() * _fxShakeIntensity * height * 2 - _fxShakeIntensity * height) * _zoom;
}
}
scroll.x -= _fxShakeOffset.x;
scroll.y -= _fxShakeOffset.y;
if (zooming < 1)
zooming = 1;
}