The name of the kid actor is Felipe Paulino. His acting coach is Fátima Toledo and the movie director is Fernando Meirelles. According with this inverview (it's in Brazilian Portuguese. The citation below is the English translation of its relevant excerpt):
"To Felipe Paulino, 22, it was a shot in the foot. (...) As he
recalls, Fátima Toledo asked actor Leandro Firmino ("Lil Zé") to
scare Felipe with a gun in a dark bedroom. She would've also told
Felipe to think about his mother drowning to death.
Famous for her method of extracting visceral reactions from actors, the coach
states that "nothing of this happened" and that Felipe might have "created a
fantasy". She states that she showed Felipe a gun and asked him if he knew what it was,
then he replied: "Yes, I know, and this one is a toy".
In order to make the scene look real, Fátima states that she asked Felipe to imagine a very
strong pain, like a toothache, moving towards his foot.
"Maybe Felipe confused reality with fiction, because his
performance was extraordinary", states Meirelles, the movie director. "As soon as
the scene was cut, I was so impressed that I ran towards him and hugged him."