I am not sure if this code snippet is already published.
Anyway I provide this code to display text with shadow with two methods to change main color and shadow color
ShadowText = Core.class(Sprite)
-- Constructor
function ShadowText:init(font, text)
--Shadow text
local text_shadow = TextField.new(font, text)
text_shadow:setPosition(1,2)
text_shadow:setTextColor(0xee0000) --> Black Colour
self.text_shadow = text_shadow
self:addChild(text_shadow)
--Normal text
local text_normal = TextField.new (font, text)
text_normal:setTextColor(0xffffcc)
self.text_normal = text_normal
self:addChild(text_normal)
end
function ShadowText:setNormalColor(color)
self.text_normal:setTextColor(color)
end
function ShadowText:setShadowColor(color)
self.text_shadow:setTextColor(color)
end
function ShadowText:setText(text)
self.text_normal:setText(text)
self.text_shadow:setText(text)
end
:ar!
Comments
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive
https://deluxepixel.com
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive
https://deluxepixel.com
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps