How do i change the color of the score .

I have a score based app and I want to change the color of the score . It is currently white and I want it to be black . If you need it Score.lua :

local M = {} M.score = 0 function M.init( options ) local customOptions = options or {} local opt = {} opt.fontSize = 50 opt.font = "00\_starmap - Shortcut" opt.x = 120 opt.y = 50 opt.maxDigits = 7 opt.leadingZeros = false M.filename = "restart.lua" local prefix = "" if ( opt.leadingZeros ) then prefix = "0" end M.format = "%" .. prefix .. opt.maxDigits .. "d" M.scoreText = display.newText( string.format(M.format, 0), opt.x, opt.y, opt.font, opt.fontSize ) return M.scoreText end function M.set( value ) M.score = value M.scoreText.text = string.format( M.format, M.score ) end function M.get() return M.score end function M.add( amount ) M.score = M.score + amount M.scoreText.text = string.format( M.format, M.score ) end function M.save() local path = system.pathForFile( M.filename, system.DocumentsDirectory ) local file = io.open(path, "w") if ( file ) then local contents = tostring( M.score ) file:write( contents ) io.close( file ) return true else print( "Error: could not read ", M.filename, "." ) return false end end function M.load() local path = system.pathForFile( M.filename, system.DocumentsDirectory ) local contents = "" local file = io.open( path, "r" ) if ( file ) then -- Read all contents of file into a string local contents = file:read( "\*a" ) local score = tonumber(contents); io.close( file ) return score else print( "Error: could not read scores from ", M.filename, "." ) end return nil end return M

Thank you .

Before you return M.scoreText in the init method, you can set it’s fill colour as follows:

M.scoreText:setFillColor(0, 0, 0)

The three arguments are for red, green and blue, and each take values from 0  to 1, with 0 meaning none of that color, and larger numbers meaning more of that colour. 0, 0, 0 means no red, no green, and no blue, so that’s no colour whatsoever. Black. (All ones, incidentally, would be white)

Before you return M.scoreText in the init method, you can set it’s fill colour as follows:

M.scoreText:setFillColor(0, 0, 0)

The three arguments are for red, green and blue, and each take values from 0  to 1, with 0 meaning none of that color, and larger numbers meaning more of that colour. 0, 0, 0 means no red, no green, and no blue, so that’s no colour whatsoever. Black. (All ones, incidentally, would be white)