We have a custom FONT in the game we are using and we want to use it for all of our scoring TEXT. We created Images for them 0-9 and I was wondering if first, anyone had any ideas on how to do it efficiently? [import]uid: 10051 topic_id: 3546 reply_id: 303546[/import]
you could use movieclip.lua (although a little bloated for your needs) or a spritesheet if you have the Game Edition
then get each digit from your score to go to the relevant frame
eg
[lua]local score = 109489
– let’s say we want a 9-digit score
– so we need 9 0’s, and remove the leading 1 from the front
local scoreString = string.sub(tostring(1000000000 + score),2)
print(scoreString) – “000109489”
print("—")
for digit=1,string.len(scoreString),1 do
num = string.sub(scoreString,digit,digit)
– now you can use num to jump to the relevant frame in your movieclip for each digit (ie you’d have 9 movieclips)
– if you’ve used movieclip labels you can presumably label them “0”, “1”, “2” otherwise add 1 to num and goto that frame (lua is 1-indexed not 0-indexed)
print(num)
end[/lua]
you did say efficiently though, and movieclip has a lot of code you won’t even use! [import]uid: 6645 topic_id: 3546 reply_id: 10739[/import]
Is there a way to do this with my timecode?
[lua]x = socket.gettime()
s = 0
function timeCheck (event)
for i=1,10000 do s = s + i end
timernum.text = string.format(“Time: %.2f\n”, (socket.gettime() - x))
score = string.format("%.2f\n", (socket.gettime() - x))
end[/lua]
This displays the time like this 0.00 [import]uid: 10657 topic_id: 3546 reply_id: 12930[/import]