Jesse Eisenberg, left, and Kristen Stewart are shown in a scene from "Adventureland."
Jesse Eisenberg, left, and Kristen Stewart are shown in a scene from “Adventureland.”

Director Greg Mottola would like to thank every girl out there who dumped him, didn’t return his phone calls and stood him up for dates.

He’s also grateful to the studios that rejected his screenplays, the TV-network executives who canceled his shows and the film-festival panels that stiffed him on awards.

The way Mottola sees it, failure molded him into the success he’s become today. He’s following the summer 2007 sensation “Superbad” with “Adventureland,” another stunning coming-of-age comedy, which opens Friday.

“I went through years of frustration,” said Mottola. After starting with the unheralded short film “Swingin’ in the Painter’s Room” (1989), Mottola made his first feature, the indie film “The Daytrippers,” which picked up a slew of festival awards in 1996. His next movie project, set up at Columbia Pictures, never got past the preproduction stage.

Mottola switched to television and struggled to write screenplays. He thought he was wasting his time.

“But the time I felt was wasted, when I was frustrated and angry, actually informs some of my direction and lets me give actors part of my insight,” he said.

“Adventureland,” which he wrote before directing “Superbad,” is a semi-autobiographical film. Mottola says he put a lot of himself into the lead character, James (Jesse Eisenberg), a financially strapped college grad who’s forced to work a summer at an amusement park. He’s also still a virgin, waiting for the right girl to take the sexual plunge with. He finds a soulmate in an emotionally shuttered co-worker named Em (Kristen Stewart), an NYU student at home for summer break.

“It has elements of complicated ex-girlfriends in Kristen Stewart’s character,” Mottola said. “I worked at an amusement park in the ’80s and made a lot of mistakes with women. I’m glad I’m married now with a kid and a wife who’s stuck with me.”

Mottola first noticed producer/director/writer Judd Apatow’s genius by watching “Freaks and Geeks,” then got to know him well while working on Apatow’s show, “Undeclared.” The connection served Mottola well, opening the door to “Superbad,” which Apatow produced.

Mottola’s work is also drawing comparisons with another director, John Hughes, who specialized in making charming films about teen outsiders.

“There was some nuance to his characters and interest in their inner lives. It was good storytelling,” Mottola said.

Also, he said, Hughes was great with female characters. “As someone who spent a life with mixed results loving women, I really liked that the cool women in his movies were interesting, not just love interests or simply objects of desire,” he said.

Although “Superbad,” penned by Seth Rogen and Evan Goldberg, shamelessly objectified women, “Adventureland” takes the opposite tack, giving female characters depth and intrigue.

Born in 1964 in Long Island, N.Y., Mottola graduated from Carnegie Mellon College of Fine Arts. He worked odd jobs, including the amusement-park gig as well as a stint in a Chicago elevator-parts factory, while dabbling in film before breaking through with “The Daytrippers.” The comedy, about a woman who takes a car ride with her family to confront her husband about a love letter, starred Hope Davis, Stanley Tucci and Parker Posey. It traveled the festival circuit, picking up awards at Slamdance and Toronto.

After Mottola’s Columbia project fell apart, he became a TV-show director-for-hire. The career introduced him to Apatow on “Undeclared” and Mitchell Hurwitz on “Arrested Development,” influences that honed his comic voice.

“It was insanely fun,” Mottola said, praising them as selfless collaborators who are open to new ideas. “Between those two shows it was comedy boot camp.”

Each show was a short-lived critical favorite. Only the Hurwitz-created “Arrested Development” lasted more than a season, and it was threatened with cancellation throughout its three-season run.

“Television is a strange animal,” he said. “The number of people who watch an episode of ‘Lost’ is so much vaster than the number of people who go see the movie that’s No. 1 at the box office. So if there aren’t millions and millions of people watching a show, (the networks) panic and cut and run.”

In the meantime, Apatow was gaining success in film, which paved the way for Mottola.

Apatow wrote and directed the phenomenally successful “The 40 Year Old Virgin” (sharing the screenplay credit with Steve Carell) and “Knocked Up,” persuading studios and investors to take a chance on movies that mixed intelligent humor with bathroom-wall-style adolescent high jinks.

“The story Judd told the press was that when he was making ‘The 40 Year Old Virgin’ the studio wanted to shut the movie down one week in,” Mottola said. “They didn’t think it worked, but Judd said, ‘Just let me finish it.’ He was a confident guy and proved them quite wrong.”