Megatron cycles through the same attack pattern, and the answer to every phase is identical: throw something, then punch.
Wait for him to stop charging. Throw an object at him. He runs at you — punch until he flies away. He returns swinging a ball and chain wildly; throw something else, then punch again. He retreats and comes back breathing fire; throw, punch. One more flight, another charge, then back to the ball and chain, then fire, repeating until his health is gone.
Throwing interrupts whatever he is doing and creates the opening; the punches are only safe immediately afterwards. Trying to punch him mid-charge or mid-swing is what costs players the fight.
Keep throwable objects in reach and do not deviate from the rhythm. Once you have the timing, the encounter is straightforward — and beating it completes the game.