President Obama continues his West Coast tour with a stop at DreamWorks Studios to highlight how the entertainment industry boosts the economy. (Nicki Demarco/The Washington Post)

President Obama singled out Hollywood’s creative class as a beacon of hope amid a sluggish economic recovery, but lamented Tuesday in a speech here at a major film studio that too many Americans aren’t sharing in their economic success.

“Entertainment is one of the bright spots of our economy,” Obama said in a speech on DreamWorks Animation’s lush Glendale campus. “The gap between what we can do and what other countries can do is enormous. That’s worth cheering for.”

Addressing supporters in the heart of liberal Hollywood, Obama lashed out at Republicans for being what he called “obsessed” with trying to halt his signature health-care law. “If they hadn’t spent 40 votes trying to repeal the Affordable Care Act,” Obama said, House Republicans might have taken votes on rebuilding the nation’s infrastructure or expanding access to pre-kindergarten.

“Instead of rooting for failure or refighting old battles, Republicans in Congress need to work with us,” Obama said. He added, “I will fix whatever problems there are, but I’m not going to abandon people.”

Obama also renewed his call for comprehensive immigration reform and hailed California as “a magnet for dreamers and strivers.”

Obama also talked about gun violence, a top priority early in his second term that has been blocked on Capitol Hill. He said the entertainment industry has “a big responsibility” in producing films and television shows, saying the stories they tell matter and shape the world culture.

“When it comes to issues like gun violence, we’ve got to make sure that we’re not glorifying it because the stories you tell shape our children’s outlook and their lives,” Obama said.

Before his remarks Tuesday, Obama convened a private roundtable session with entertainment industry executives. Aides said they discussed piracy and intellectual property rights, among other issues.

DreamWorks chief executive Jeffrey Katzenberg — who is one of Obama’s biggest campaign donors and fundraisers — led the president on a tour of DreamWorks Animation Studios. Obama visited a motion capture production studio and a voice recording studio, providing a presidential plug for two forthcoming DreamWorks movies.

Obama visited with actors Steve Martin and Jim Parsons, who were recording lines for “Home,” an alien invasion film that comes out next November. The production team created an animated clip of a purple alien, named Oh, with an actual recording of Obama’s voice: “Happy Thanksgiving, everybody. Welcome to the White House.” The president joked that the clip would “impress the girls,” but complained that the alien’s ears stuck out too much.

Obama also visited with two actors for “How to Train Your Dragon 2” who, wearing tight suits with motion-capture sensors all over their bodies, acted out a scene of an animated boy and girl in Viking adventure garb. Watching the actors move and the animated scene take shape on a projection screen above them, Obama remarked, “That was wonderful.”

Obama plugged the film, due out next June, by saying, “Coming to a theater near you!”

Some Republicans and nonpartisan advocates for government transparency called the presidential visit to DreamWorks “payback” for a top fundraiser.

Katzenberg is one of Obama’s biggest political donors and fundraisers, backing him early in the 2008 campaign and raising more than $500,000 for the 2008 and 2012 Obama campaigns. Katzenberg also provided the crucial seed money for the pro-Obama super PAC Priorities USA Action in 2011, eventually pumping $3 million into the independent group.

In his speech, Obama thanked Katzenberg for inviting him to DreamWorks. “I would like to work here,” Obama quipped. “I have asked Jeffrey.”

Obama then prodded the studio boss, saying, “I don’t need to puff him up too much. He has a healthy sense of self.” Later, he said, “Can’t wait to see your next movie!”

White House officials said Katzenberg’s political largess had nothing to do with Obama’s decision to visit his studios.

“Contributing to the president’s campaign or being a political supporter of the president doesn’t guarantee you a presidential visit, but it shouldn’t exclude you from one, either,” White House spokesman Josh Earnest told reporters Monday.

Obama spent much of the week raising money to help Democrats in the 2014 midterm elections. On Monday night in nearby Beverly Hills, Obama spoke at fundraisers at the estates of former basketball star Magic Johnson and media magnate Haim Saban. On Tuesday morning, he visited with a couple dozen supporters at the home of “Friends” co-creator Marta Kauffman and Michael Skloff.