In the cerebrum, there is a kind of special nerve cells in charge of the transmission of visual signals. These cells can interpret the information transmitted from the eyes into all that we see. But when the head suffers a hit, these nerve cells tremble and the brain will interpret the similar stars image incorrectly. In fact, such thing happens frequently in our daily life. For example, when you pick up something, you may knock your head against the table, under this situation, your cerebrum is surrounded by the cerebrospinal fluid, which plays a role in the protection of the cerebrum. But if the head suffers a hard hit, the cerebrospinal fluid will not have much effect and the hit start over the nerve cells and moves your retina, hence reflecting some ray source, thus you see stars.