Texts from Paul Nicholls were found on both girls' phones, the court heard
A 39-year-old air cadet instructor has been accused in court of having sex with two girls, including a 13-year-old who later killed herself.
Cherrell Ardle was found hanged in late 2007, Merthyr Crown court heard.
A 15-year-old girl went to police after Cherrell died and told officers she had also had sex with Paul Nicholls.
Mr Nicholls, of Rhondda, denies charges relating to the 15-year-old, three of sexual activity and one of attempting sexual activity. The trial continues.
The court heard that his sexual relationship with Cherrell, also from Rhondda, ended and she was found hanged at her home.
The prosecution said Mr Nicholls had "an unhealthy attraction" to young girls.
Prosecutor Jennet Treharne told the court the older girl said a sexual relationship had developed between Nicholls and her.
"She said she did not tell anyone in authority what was happening at the time," she said.
But the 15-year-old came forward after Cherrell took her own life.
Cherrell Ardle was found hanged at her home in December 2007
"She claimed that Cherrell had also been having a sexual relationship with Nicholls and it was her belief his conduct to Cherrell caused her to take her own life," said Miss Treharne.
The older girl, who cannot be named, told police she had slept with Nicholls 10 times, before he moved on to Cherrell.
Miss Treharne said: "She said she didn't want to tell anyone at the time that they were having the affair because Nicholls told her it would ruin everything."
Police were told Mr Nicholls, of Pontygwaith, had sex with the 15-year-old in his bedroom, his living room and in his car parked on a mountain.
Miss Treharne said: "The girl believed that sexual activity stopped after two months because he started to act in a similar way with Cherrell."
The court heard Mr Nicholls sent her a text message saying he wanted to invite both the girls to have sex.
In one text he allegedly wrote: "I know one is better than none. But now I prefer two."
The court heard police found several text messages from Mr Nicholls on both girls' phones.
Miss Treharne said: "Nicholls has a propensity for sexual relationships with young girls."
She told the court both girls were vulnerable and had been invited to his house.
Another girl said he had touched her inappropriately.
"He had an unhealthy attraction to girls much younger than himself," said Miss Treharne.