As I've completed my Analysis on Gear 4, I will now go to my Analysis on the fight.
For starters, if the title is Gear 4 there's plot stamped all over it. This chapter is to showcase gear 4's appearance and allow it to shine. So yes, of course, Luffy would have had to give Doflamingo that beating.
This fight has established that Doflamingo can't use his kicks and punches to smash Doflamingo around for one.
Flamingo seems to actually know about Luffy's abilities and how they worked. As this is a whole new gear never witnessed by anyone else before, Doflamingo would not know about it.
This is why Doflamingo was questioning the retractions of the fruit, the change in body, armament while still being rubber.
Doflamingo is analysing the situation and he by no means is out for the count, in fact, judging from the last panel he looks pissed!
"Why! Why won't he retract?".
Since Luffy has changed his fight style, Doflamingo needs to change his.
As already mentioned, Kicks and Punches don't work. This entire time, Doflamingo has NOT been reliant on his devil fruit against Luffy. The reason for this is because he really didn't need to use it as much, as his brute power was already enough even after taking the Gamma Knife.
Doflamingo tried tanking the King Kong Gun. He had said to himself "What's with this insane amount of force" and had been flinged across the city.
Doflamingo thus far has not taken a hit from attacks like the Elephant gun etc knowing they would have an effect and has counter-attacked at minimum.
Doflamingo genuinely thought he could block the King Kong Gun as he underestimated it, he did not expect Luffy to fly, did not expect Luffy to redirect his attacks and did not expect Luffy to block and bounce off his kick attacks.
Doflamingo is already figuring out his fighting style and WILL adapt.
In fact the moment Doflamingo tried to take it seriously, it was only outdone because he didn't know his normal brute force would not work, and Luffy knew this.
Questions have been arising, why doesn't Doflamingo use strings to stop Luffy, why isn't he using his Devil fruit.
Due to plot, Doflamingo is about to bring that power out and showcase it. Now there is really a need for him to use it unlike before where Doflamingo was clearly outdoing Luffy with brute force.
Now with Luffy's current defensive perks, he needs to counter differently.
Doflamingo will also be used to exploit Gear 4's weaknesses. One so far is manoeuvrability.
To all you people hoping this won't be a curbstomp for Luffy, have faith! For Doflamingo will unleash his beast self and put up a worthy fight to satisfy us after these 2 years and giving Luffy a proper fight!