All you have to do is run round him quickly a few times, and then he disintegrates and you can pick up your hat. Result!
Hit the bird that stole it then grab the hat.
Go back to the world you lost your hat in and find it. Then just walk up to it to put it on.
I do not know how many stars you need, but after awhile a light will show up in the castle, look up into it and you will be in the flying course. If you do not get the red coins or you lose your...
You triple jump and then you start flying.Simple.