allow font specification on writeOnSprite
This commit is contained in:
@@ -41,13 +41,15 @@
|
|||||||
(stamp.origin.set oX oY))))
|
(stamp.origin.set oX oY))))
|
||||||
|
|
||||||
// TODO allow specifying size relative to canvas
|
// TODO allow specifying size relative to canvas
|
||||||
(function :Void writeOnSprite [:String text :Int size :FlxSprite canvas :RelativePosition pos &opt :FlxColor color]
|
(function :Void writeOnSprite [:String text :Int size :FlxSprite canvas :RelativePosition pos &opt :FlxColor color :String fontPath]
|
||||||
(let [lines (text.split "\n")
|
(let [lines (text.split "\n")
|
||||||
&mut offsetY (/ (* size lines.length) -2)]
|
&mut offsetY (/ (* size lines.length) -2)]
|
||||||
(doFor text lines
|
(doFor text lines
|
||||||
(set pos.offsetY offsetY)
|
(set pos.offsetY offsetY)
|
||||||
(+= offsetY size)
|
(+= offsetY size)
|
||||||
(let [text (new FlxText 0 0 0 text size)]
|
(let [text (new FlxText 0 0 0 text size)]
|
||||||
|
(when fontPath
|
||||||
|
(text.setFormat fontPath size color))
|
||||||
(when color
|
(when color
|
||||||
(set text.color color))
|
(set text.color color))
|
||||||
(drawOnSprite text canvas pos)))))
|
(drawOnSprite text canvas pos)))))
|
||||||
|
Reference in New Issue
Block a user