How do I delete last character from sprite font object?

Get help using Construct 2

Post » Sat Sep 19, 2015 7:49 pm

How on button pressed to remove the last character from a sprite font? There's an append action (Append Text), but no way to remove a letter.


This is pretty much what I want to do:
Code: Select all
Variable = "Value"
Text = Variable
Letter = "Q"

On Button A pressed -> Text -> Append Letter
                    -> System -> Set Variable to TextSprite.Text
On Button B pressed -> Text -> Remove Last Letter?
                    -> System -> Set Variable to TextSprite.Text

// On A pressed will output "ValueQ" and I need on each B press to remove one letter from the back
Ba-dum Tsss!
B
11
S
2
G
1
Posts: 45
Reputation: 757

Post » Sat Sep 19, 2015 8:02 pm

If I understood correctly ...

Spritefont set text to.............left(SpriteFont.Text,len(SpriteFont.Text)-1)


System expressions wrote:left(text, count)
Return the first count characters of text.

len(text)
Return the number of characters in text.
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Sat Sep 19, 2015 8:15 pm

Yes, thank you! That's works like a charm.
Ba-dum Tsss!
B
11
S
2
G
1
Posts: 45
Reputation: 757


Return to How do I....?

Who is online

Users browsing this forum: blackhornet, Lancifer and 18 guests