Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How to automatically edit text?
Started by amar.masic6 Apr 24 2018 10:59 AM

1 reply to this topic
text text-editting
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

amar.masic6

[GLOBAL: userInfoPane.html]
amar.masic6
  • Observer

  • 6 posts
  • Corona SDK

If you don't understand what i mean, i don't blame you because i don't know how to ask this (if i did i would probably somehow find on google), anyways, what i mean is i have a text that says "Score: " and i want it to increment by 1 when a player does something so it says "Score: 1" and "Score: 2" and so on... I got everything set up but i just can't figure that out, i searched google for string formatting, string editing and stuff like that but i couldn't find anything.

 

If you need any code or anything just ask and i will post.

Any help is appreciated.

 

(and also i'm new on the forum so i'm sorry if i did something wrong)



[TOPIC: post.html]
#2

csavalas

[GLOBAL: userInfoPane.html]
csavalas
  • Contributor

  • 101 posts
  • Corona SDK

local myText=display.newText( " ", display.contentWidth*.5, display.contentHeight*.5,  native.systemFont, 20 )

myText.baseText="Score: "
myText.counter=0

myText.updateText=function(increment)
   myText.counter=myText.counter+increment
   myText.text=myText.baseText..tostring(myText.counter)
end

-- Format the initial score
myText.updateText(0)

-- Then sometime later,
-- increment the score by 1
myText.updateText(1)



[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: text, text-editting