Whether you're looking to make a device more conveniently-sized, or just trying to protect its more vulnerable parts when it's not in use, retractability is a great way to improve a design. There are a number of ways to incorporate retraction into an invention and each device will be better suited to a different technique, or combination of techniques. Understanding how these methods work is key to choosing the right design for your retractable creation.
Create a telescoping design. Though telescopes are not, by definition, always retractable, the common practice of making them so resulted in this type of design being so named. Any part of your device that consists of (or could consist of) a long, hollow object, can be collapsed for storage and lengthened for use. This is achieved by turning the long section into a series of semi-conical sections that fit together. Make your long object out of tapered sections, each slightly smaller than the last one. This will make it possible for each tube to slide most of the way through the last tube, but get stuck as the wide end of the smaller section tries to pass through the narrow end of the larger section.
Make the retractable part of the item recede into the body of the object (as with a retractable pen or tube of Chapstick). Use this technique for parts of your device that are long and thin but cannot be telescoped. Create a hollow channel or cavity in the body of your device that the retractable portion can fully recede into when not in use, then be pulled out of.
Use a hinge. A hinge, or series of hinges, can make something retractable by allowing it to fold up into smaller sections that can lay flat against the outside of the rest of the object. A hinge can also be used along with a recede-into-the-body design, as it is on most folding knife blades.
Design retractable soft roofs and walls by combining a foldable cloth drape with a hinge or telescoping retractable frame. This type of design is used in items like folding camping tents and convertible car roofs.
Utilize a "fan" design to create a stiffer retractable flat surface. Stack a series of flat panels (slats) and connect them at the bottom with a pivoting rod drilled through. Spread the slats out so they are semi-overlapping, then connect them at the top with a strip of flexible material, such as rope or cloth. This material will fold when the slats are re-stacked, but will keep them in their overlapped position when the fan is pulled out.