How do you lose the most high-profile contest of your life and come out looking like the winner? There’s an app for that.

Aaron Gordon was a 20-year-old second-year player on the Orlando Magic when he became a sensation overnight among NBA fans. He thrilled NBA All-Stars and fans during the Slam Dunk Contest earlier this year at the Air Canada Centre, home to the Toronto Raptors and host of the NBA’s All-Star weekend. He ended up losing to the reigning champion Zach Lavine, but many fans thought he should have won. In fact, to some he was the winner because of how well he handled the situation.

“He had the winning aura even though he lost,” said Graham Betchart, a mental strength coach who has worked with Gordon for seven years — since he was 13. “He taught people how to lose with grace.”​

Betchart, who has a master’s degree in sports psychology, has worked with many talented high school basketball players over the last decade for free. Betchart met Gordon when he was 11, and they started working together when he was a precocious 13-year-old, already on the varsity basketball team. Betchart says he likes working with younger people because they’re open-minded. And early on he thought there was something special about Gordon because he wasn’t afraid to fail.

Betchart is now paid a monthly fee by about 10 NBA players, including Gordon and LaVine. He has also worked with Andrew Wiggins, Karl-Anthony Towns and Ben Simmons, the last three No. 1 NBA draft picks, and he has partnered with former Twitter TWTR, -0.62% executive Jason Stirman on an app of his mental strength teachings called Lucid: Mental training for athletes. The app costs $9.99 a month or $99.99 a year and is currently available on iTunes.

Reflecting Betchart’s philosophy that there are no quick fixes when it comes to mental strength, the app offers over a thousand lessons to be listened to in five-minute increments each day.

While discussing the dunk contest, Gordon said it was a culmination of his work with Betchart. He said he centered himself and converted his nervousness into energy to jump higher. “Before the contest, I said, ‘What if I don’t get the scores I want?’ And Graham said, ‘You’re here to let your light shine.’ I did everything I could to control what I could control. I let my light shine.”

Not exactly the types of platitudes you hear from most athletes after a competition.

The 38-year-old Betchart wrote the book “Play Present: A Mental Skills Training Program for Basketball Players” in 2015. But he wanted to reach more young people through something like an app, even though he didn’t know how to achieve that. Fortuitously, at about the same time, Stirman and his business partner, Soren Gordhamer, wanted to create an app that used meditation to help people perform better in various endeavors — including work and athletics.

Stirman provided guided meditations to employees three times a week when he worked at Medium, an online platform where “thousands of people publish ideas and perspectives” every day,” and had recently started a company called Lucid. Other apps in the meditation field include Calm, which has grown in popularity recently.

Through a friend-of-a-friend, Stirman, 38, met Betchart in January 2016. “I only met him to appease my friend, but in the first meeting, we realized we each had done what the other needed,” Stirman said, adding, “We would probably spend years doing what Graham had already done.” The app they worked on together was ready by May 2016.

Zach LaVine and Graham Betchart (right) during All-Star weekend in February 2016. Graham Betchart

The other mental-strength aficionado on board with Lucid is George Mumford. Phil Jackson brought Mumford in to work with the Chicago Bulls when he was their coach, and he has worked with Jackson’s other teams since — the Lakers and the Knicks.

Betchart had long followed Mumford’s impact on NBA players. He said the superstar Michael Jordan became even better after working with Mumford because he taught him about mindfulness and brea​th​ing. Betchart also said Jordan became a better player because he learned to be more compassionate. In Mumford’s book The Mindful Athlete, he says Michael Jordan credits him with “transforming his on-court leadership of the Bulls, helping him lead the team to six NBA championships.”

The word “compassion” also came up when Betchart spoke about referees in the NBA. He and Gordon talk about refs “all the time,” and he tells Gordon to have compassion for them, and not to get emotional after a bad call. “Now Aaron doesn’t judge a call. It’s simply a sound coming from the whistle. He’s totally present. No judgment,” Betchart said.

What the app teaches

The app is based on Betchart’s “MVP” — meditation, visualization, positive affirmations. When it comes to visualizing, Betchart said the brain doesn’t know the difference between imagining something and actually doing it. So he has athletes imagine themselves doing a performance before they do it.

Gordon used visualization to prepare for the dunk contest. “Graham and I sat in my apartment and visualized each dunk before they happened. By the time I got to the dunk contest I had already made the dunks five or six times thoroughly,” Gordon said.

Meditation is part of each of the app’s five-minute “workouts.” Betchart also says he leads Gordon through longer meditations when they work together in person.

Betchart stresses that in sports you can’t control the results, so control what you can. So he focuses on process, which gets ego out of the equation, he says. “It’s like tying your shoe. If I asked you how you tie your shoe, you’d find it complex to describe.”

After focus, he gets players to work on confidence. This is all very big picture, but it can also help improve something specific.

Graham Betchart (left) and George Mumford at Lucid’s launch party. Lucid

Free throws

Gordon’s free throw percentage in high school was 30%. Betchart said they worked on Gordon’s mindset, and he’s now shooting 70%.

At the free throw line, it’s about ego, Betchart said. For example, players think, “I do not want to miss this shot.” So a lot of the training would be: “You’re not a basketball player, but a human being deciding to play a game. Your life is not on the line.”

“I can see a free throw vividly in my mind if I so choose. Countless mental reps help a lot,” Gordon said.

Using the app

Betchart sees it as a four-year plan in five-minute daily increments. “If I can get a two- or three-year foundation with an athlete, these things can stick.”

The app’s lessons apply to anyone in a competitive environment, including students, lawyers and business professionals, he adds.

In the app’s first workout, Graham’s voice says: “You have greatness already inside of you…Deep down you already know this is true.” Then he walks you through an MVP:

Meditation. Focus on your breath

Visualization. Betchart says: Feel “a golden ball of greatness inside of you…See it as a powerful, confident light…It wants to get out…See your greatest dream become alive right now in this moment.”

Positive affirmations. Betchart asks listeners to say to themselves: “I have greatness already inside of me. I train my mind to unlock all my greatness.”

Another of the first-week’s workouts stresses the importance while competing of playing “present” and not thinking of something in the past or something that could happen in the future.

Aaron Gordon and Graham Betchart on the court during All-Star weekend in February 2016. Graham Betchart

Can an app replace a person?

Dr. John F. Murray, who has a Ph.D. from the University of Florida Department of Clinical and Health Psychology, has worked with many professional and amateur athletes as a sports psychologist. He has also made what are essentially personalized apps for certain athletes, including the former NBA star Tracy McGrady. “No app is going to replace human interaction,” Murray said when told about the Lucid app. But he added that he hasn’t tried it yet and he would like to. And he hopes it can help show more athletes how vitally important mental strength is to success — and lead to more acceptance of mental strength training, including a sports psychologist on every professional sports team. He also said that for junior and amateur athletes — or people who can’t afford to hire a sports psychologist — the app “could be great.”

What’s next for the app

Gordon, Betchart and Mumford have equity stakes in the company, and Betchart is a full-time employee.

Gordon’s title is president of Lucid’s players’ association. If other players in the NBA are interested in working with Lucid, Gordon will meet with them. He also said he will talk with the Orlando Magic’s GM about adding a sports psychologist to the staff.

Stirman said Lucid is also working with an NFL team interested in the app. “The NFL has taken notice. Football, out of necessity, is becoming progressive about mental health,” he said, referring to the NFL’s struggle with some of its veterans dealing with concussions.​

Lucid raised $1.5 million in seed money in October 2015 and Stirman said the company is getting ready to raise more.

So do these guys use the app themselves? Gordon does three times a day — after he wakes up, before he works out, and before he goes to bed.

When asked if he thought working with Graham had helped him make it to the NBA, Gordon was philosophical.

“Once you start to trust, your life really changes dramatically. It changed my vision of success. I used to think 9 for 10 was successful. Now I think 2 for 10 is, as long as you feel great after the game.”