Shadow = Entity:createSubClass();

function Shadow:init()

   self:setTexture("shmup1_shadows.metatex");

   self.myEnt = nil;
   self.myOffset = { 16, -16 };

   self:setBlockable(false);
   self:setLayer(2);

   -- This is so we don't appear at 0,0 for one frame.
   self:setAlpha(0);

end

function Shadow:updateSpriteFrame()

   if self.myEnt then

	  if self.myEnt:getDead() then

		 self:die();

	  else

		 self:setSpriteFrame(self.myEnt:getSpriteFrame());

		 local x, y = self.myEnt:getPos();
		 x = x + self.myOffset[1];
		 y = y + self.myOffset[2];
		 self:setPos(x, y);
		 
		 self:setSpriteAngle(self.myEnt:getSpriteAngle());
		 
	  end

   end

end

function Shadow:assign(ent)
   self.myEnt = ent;
   self:updateSpriteFrame();
end

function Shadow:postUpdate()
   self:updateSpriteFrame();
   self:setAlpha(1);
end
