textPlate helper
This commit is contained in:
@@ -58,4 +58,16 @@
|
||||
(let [bitmapData sprite.pixels
|
||||
&mut bytes (new ByteArray)]
|
||||
(set bytes (bitmapData.encode bitmapData.rect (new PNGEncoderOptions true) bytes))
|
||||
(File.saveBytes file bytes))))
|
||||
(File.saveBytes file bytes))))
|
||||
|
||||
(function :FlxSprite textPlate [:String text :Int size :Int margin &opt :FlxColor textColor :FlxColor bgColor]
|
||||
(unless textColor (set textColor FlxColor.WHITE))
|
||||
(unless bgColor (set bgColor FlxColor.BLACK))
|
||||
(let [flxText (new FlxText 0 0 0 text size)
|
||||
textWidth flxText.width
|
||||
textHeight flxText.height
|
||||
plate (new FlxSprite)]
|
||||
(set flxText.color textColor)
|
||||
(plate.makeGraphic (+ (* 2 margin) textWidth) (+ (* 2 margin) textHeight) bgColor)
|
||||
(plate.stamp flxText margin margin)
|
||||
plate))
|
Reference in New Issue
Block a user