Which code? The Camera2D AABB code?
You'll need to add it in
_physics_process. The Camera2D node will need to be named
Camera2D exactly, or you will need to change
$Camera2D to reflect the node name. Additionally, the Camera2D node will need to be a child of the node the script is attached to.
If you want to attach the script to the Camera2D directly, you can use something like the following:
if (global_position.x < MIN_X):
global_position.x = MIN_X
elif (global_position.x > MAX_X):
global_position.x = MAX_X
if (global_position.y < MIN_Y):
global_position.y = MIN_Y
elif (global_position.y > MAX_Y)
global_position.y = MAX_Y