Camera = Entity:createSubClass();

function Camera:init()

   self:setForceUpdate(true);
   self:setLayer(3);

end

function Camera:update()

   local target = self:getLinkTarget();
   local ent = entitiesByName[target];

   local x, y = ent:getPos(); 

   local sx, sy = getScreenSize();

   local currentTop = y + (sy / 2);
   local currentLeft = x - (sx / 2);

   if currentTop > 0 then
      y = y - currentTop; -- Clamp to zero as screen top.
   end

   if currentLeft < -1024 then
      x = x - currentLeft - 1024; -- Clamp to zero as screen left;
   end

   setCameraPos(x, 0);
   self:setPos(x, 0);

end


