There are several ways to get these:
1) You can gain resources by spinning the Wheel of Fortune.
2) You can gain resources by completing levels in the respective locations. Food can be found in the garden or in the inn. Gold can be obtained in the castle, the treasury or the merchant's house, and you can get materials in the port or Lance's hut.
3) You can get resources as a reward for different events.
4) Finally, you can just purchase these from the game store found on the Resources tab.