The boss for Spring Yard Zone can get pretty tough. Robotnik, as usual, flies in his eggpod, and a spike will appear from under his ship. Now, here's the thing. You stand on a bridge made out of blocks. When you get under Robotnik and his ship, he'll descend, and will use his spike to destroy one of the blocks that you're standing on. Of course, at that moment, you're in danger too, because if you don't get out of the way, you'll be hurt by the spike. On the other hand, when Robotnik descends, that will be your time to strike. Just move out of the way, and jump on him when he lowers. You can usually get from one or two hits every time. Getting two hits in is riskier because Robotnik will often rise up again and you will fall down into the pit because of the block being taken. You can jump at the right time and hit him when he hovers a bit lower. Also, by standing on the edge of a gap, you can trick Robotnik into stabbing air.
However, because Robotnik keeps descending and destroying blocks, not only do you have to worry about the spike, but as the number of blocks decrease, one of your biggest concerns will be to prevent yourself from falling into the pit. Therefore, in this battle, you'll have to take out Robotnik fast, or else your standing ground will soon disappear completely.
Due to the difficulty of this boss, try to get the extra life just before; it's easy if you're patient.