@Ignatz so the score is working out really well.
I’ve added a dollar character to the front of the amount to show the dollars you are collecting.
The only thing is as I add another number like the tens,hundreds and thousands column it no longer sits center.
ScoreTime = class()
function ScoreTime:init()
--note how you have to set each of the ten key-value pairs in this case
-- no need to put the Documents:num prefix on all of them
-- we can do it later, below
--check I have all the quotes correctly placed
self.Num = {["0"]="Zero",["1"]="One",["2"]="Two",["3"]="Three",
["4"]="Four",["5"]="Five",["6"]="Six",["7"]="Seven",
["8"]="Eight",["9"]="Nine"}
self.dollar = readImage("Documents:numDollar")
end
function ScoreTime:draw()
for i=1,string.len(score)do
local d=string.sub(score,i,i) --d contains a digit like "4"
--now we add the Documents:num prefix to the number
sprite("Documents:num"..self.Num[d],scalerX*30+i*scalerX*10,soy,scalerX*10,scalerY*20)
end
sprite(self.dollar,scalerX*30,soy,scalerX*10, scalerY*20)
end
function ScoreTime:touched(touch)
-- Codea does not automatically call this method
end
I’ve currently got the graphic text to start at 30% of the screen width from the left. Ideally I’d like to put the whole thing and each time it adds a column of numbers (i) it re-centers the whole thing in the middle of the screen on the Y axis.
I’m thinking I code in an adjuster like i,i = scalerY40 then i,i,i =scalerY35 etc… Taking 5 off each time.
Or can I calculate the string width and then do maths around that to work out position?
Thanks
Major