“Holes” was made by adults who know the best kids’ movies are the ones that don’t talk down to kids. They assume children are smart, which they are, and that they can follow fairly complicated plots, which they can. Kids’ movies, on the whole, should make fewer flatulence jokes and focus more on treating children like real people, the way “Holes” does.

The film was adapted from the Newbery Medal-winning book by its author, Louis Sachar, and directed by grown-up-film maker Andrew Davis (“The Fugitive,” “Under Siege”), whose philosophy is not to let serious themes get in the way of having a good time, and vice versa. “Holes” has a little death, some perilous situations, and some mature themes like racism, but it trusts that kids can handle it.

It is a curious little story about a juvenile detention facility in the Texas desert, 150 miles from the nearest water or civilization. Here is where perpetually unlucky Stanley Yelnats IV (Shia LaBeouf) is sent after being falsely accused of stealing a famous baseball player’s shoes, the latest in a string of unfortunate circumstances he has found himself in.

The duty of Stanley and every other boy at the ironically named Camp Green Lake is to dig holes on the dried-up lakebed, one hole every day, each hole six feet deep and six feet in diameter. This is to build character, according to Mr. Sir (Jon Voight), the redneckish tough-talker who acts as second-in-command to the mostly unseen warden. But we come to suspect an ulterior motive.

The film has a congenial way of putting Stanley in frightening situations but then reassuring us everything is OK. Mr. Sir may talk mean, but he has no interest in hurting the boys. Ditto the boys themselves, all street kids with cool-sounding nicknames who accept Stanley as one of their own after only a little bit of hazing. Even the warden (Sigourney Weaver), the great and powerful Oz behind this work-camp facade, is more misguided than malicious in her evil-doing. The greatest real threat is from the deadly yellow-spotted lizards that inhabit the desert.

The book’s multi-layered narrative translates on film into an amusing jumble of stories all intercut with each other: Stanley at the camp, Stanley in court, the Yelnats ancestor irritating the gypsy, a charming love story involving a one-room-schoolhouse teacher and an onion farmer, and a ruthless outlaw named Kissin’ Kate. All of these threads relate to each other eventually, and part of what I admire about the film is that it gives kids credit for being to keep track of it all.

Also impressive is the adult cast, who act with dignity and charisma rather than hamming it up, as might be the temptation in a kids’ movie. Jon Voight has rarely been more enjoyable to watch, deftly walking the line between character and parody and coming down firmly on the side of character with a hilariously overwrought performance. Sigourney Weaver, Patricia Arquette, Eartha Kitt, Henry Winkler and Tim Blake Nelson also shine in their diverse roles.

The children have an everyday-kid look about them, resembling not so much movie stars (which most of them aren’t) but, well, kids who might be in a juvenile detention facility. They lack the precociousness of many film children and are as dedicated to “keeping it real,” as the kids say, as their adult co-stars are.

The film’s pacing could be improved in the middle section, a fault not found in the fast-paced book, which you could read in less time than it takes to watch the movie. But slogging through a few slow moments is a small price to pay for a film as imaginative and all-out entertaining as this one.

B+ (1 hr., 51 min.; PG, some extremely mild profanity, some scariness, mild violence.)