Created
March 6, 2025 21:01
-
-
Save MondayHopscotch/ba0e69555d372acaea80a7d400269d91 to your computer and use it in GitHub Desktop.
TextScrollPlayground.hx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package states; | |
import flixel.FlxBasic; | |
import flixel.FlxG; | |
import flixel.graphics.frames.FlxBitmapFont; | |
import flixel.graphics.frames.FlxFrame; | |
import flixel.math.FlxMatrix; | |
import flixel.math.FlxPoint; | |
import flixel.math.FlxRect; | |
import flixel.text.FlxBitmapText; | |
import flixel.text.FlxText; | |
import flixel.util.FlxColor; | |
import openfl.geom.ColorTransform; | |
using flixel.util.FlxColorTransformUtil; | |
class ScrollingTextTestState extends flixel.FlxState | |
{ | |
final string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna alidua. Ut enim ad minim veniam, duis nostrud exercitation ullamco laboris nisi ut alzquip ex ea commodo conseduat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa dui officia deserunt mollit anim id est laborum."; | |
var text:FlxText; | |
var bText:ScrollingBitmapTextY; | |
override function create() | |
{ | |
super.create(); | |
FlxG.cameras.bgColor = 0xFFa0a0a0; | |
FlxG.stage.color = 0xFF000000; | |
bText = new ScrollingBitmapTextY(10, 10, string, 200, 100, MAIN(WHITE)); | |
// bText.scrollFactorset(0, 0); | |
// bText.scale.set(2, 2); | |
// bText.letterSpacing = -1; | |
add(bText); | |
FlxG.watch.addFunction('scroll', () -> '${bText.scrollY}/${bText.maxScrollY}'); | |
} | |
override function update(elapsed) | |
{ | |
super.update(elapsed); | |
final delta = (FlxG.keys.pressed.L ? 1 : 0) | |
- (FlxG.keys.pressed.J ? 1 : 0) | |
+ (FlxG.keys.justPressed.K ? 1 : 0) | |
- (FlxG.keys.justPressed.I ? 1 : 0); | |
if (delta != 0) | |
{ | |
bText.scrollY += delta; | |
} | |
} | |
} | |
class ScrollBitmapText extends FlxBitmapText | |
{ | |
public var scrollX(default, set):Int; | |
function set_scrollX(value:Int) | |
{ | |
scrollX = value; | |
updateScroll(); | |
return scrollX; | |
} | |
final clip = FlxRect.get(); | |
var initted = false; | |
public function new(x = 0.0, y = 0.0, ?text, fieldWidth:Int, font) | |
{ | |
super(x, y, text, font); | |
multiLine = false; | |
autoSize = true; | |
clip.set(0, 0, fieldWidth, textHeight); | |
initted = true; | |
updateScroll(); | |
} | |
function updateScroll() | |
{ | |
clipRect = null; | |
if (scrollX > width - clip.width) | |
scrollX = Math.round(width - clip.width); | |
if (scrollX < 0) | |
scrollX = 0; | |
clip.height = textHeight; | |
clipRect = clip; | |
} | |
override function set_fieldWidth(value:Int):Int | |
{ | |
_fieldWidth = 0; | |
if (initted) | |
{ | |
clip.width = value; | |
updateScroll(); | |
} | |
return value; | |
} | |
override function get_fieldWidth():Int | |
{ | |
return Math.round(clip.width); | |
} | |
override function drawText(posX:Int, posY:Int, isFront = true, ?bitmap, useTiles = false) | |
{ | |
super.drawText(posX - scrollX, posY, isFront, bitmap, useTiles); | |
} | |
} | |
class BaseTextBMP extends flixel.text.FlxBitmapText | |
{ | |
public function new(x = 0.0, y = 0.0, ?text, fieldWidth = 0, ?font:FontType, alignment = LEFT) | |
{ | |
super(x, y, text, getFont(font)); | |
initFont(font); | |
this.fieldWidth = fieldWidth; | |
setStyle(getStyle(font), alignment); | |
} | |
public function setFontType(?font:FontType, ?alignment:FlxTextAlign) | |
{ | |
font = font ?? FontType.MAIN(null); | |
this.font = getFont(font); | |
initFont(font); | |
setStyle(getStyle(font), alignment); | |
} | |
function initFont(font:FontType) | |
{ | |
// Note: for backwards compatibility, we made BaseText line up with BaseTextBMP, not the other way around | |
// If anything on that changes, do so here | |
} | |
public function setStyle(style:Null<TextStyle>, alignment:Null<FlxTextAlign>) | |
{ | |
if (alignment != null) | |
this.alignment = alignment; | |
switch style | |
{ | |
case BLACK | null: | |
color = FlxColor.BLACK; | |
setBorderStyle(NONE); | |
case WHITE: | |
color = FlxColor.WHITE; | |
setBorderStyle(OUTLINE, FlxColor.BLACK, 1); | |
case COLOR(color): | |
this.color = color; | |
setBorderStyle(OUTLINE, FlxColor.BLACK, 1); | |
} | |
} | |
static function getFont(?font:FontType) | |
{ | |
var monospaceLetters:String = " !\"#$%&'()*+,-.\\0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[/]^_`abcdefghijklmnopqrstuvwxyz{|}~"; | |
var charSize = FlxPoint.get(7, 10); | |
return FlxBitmapFont.fromMonospace("assets/fonts/RetroMedievalV3.png", monospaceLetters, charSize); | |
// return switch (font) | |
// { | |
// case null | FontType.MAIN(_): | |
// Fonts.MAIN; | |
// case FontType.FLIXEL(_): | |
// Fonts.FLIXEL; | |
// case FontType.DLG(_): | |
// Fonts.DIALOGUE; | |
// case FontType.MINI(_): | |
// Fonts.MINI; | |
// case FontType.CUSTOM(name, size, _): | |
// {name: name, size: size}; | |
// } | |
} | |
static function getStyle(?font:FontType) | |
{ | |
return switch (font) | |
{ | |
case null | MAIN(null): | |
BLACK; | |
case FontType.MAIN(style): | |
style; | |
case FontType.FLIXEL(style): | |
style; | |
case FontType.DLG(style): | |
style; | |
case FontType.MINI(style): | |
style; | |
case FontType.CUSTOM(_, _, style): | |
style; | |
} | |
} | |
} | |
enum FontType | |
{ | |
MAIN(?style:TextStyle); | |
MINI(?style:TextStyle); | |
FLIXEL(?style:TextStyle); | |
CUSTOM(name:String, size:Int, ?style:TextStyle); | |
/** Currently just a duplicate of MAIN, but may change */ | |
DLG(?style:TextStyle); | |
} | |
enum TextStyle | |
{ | |
/** Black text */ | |
BLACK; | |
/** White text with a black outline */ | |
WHITE; | |
/** text with a black outline, inner color defaults to white */ | |
COLOR(color:FlxColor); | |
} | |
class ScrollingBitmapTextX extends BaseTextBMP | |
{ | |
public var scrollX(default, set):Int; | |
function set_scrollX(value:Int) | |
{ | |
if (value > width - clip.width) | |
value = Math.round(width - clip.width); | |
if (value < 0) | |
value = 0; | |
updateScroll(); | |
return scrollX = value; | |
} | |
final clip = FlxRect.get(); | |
var initted = false; | |
public function new(x = 0.0, y = 0.0, ?text:String, fieldWidth:Int, ?font:FontType) | |
{ | |
super(x, y, text); | |
multiLine = false; | |
autoSize = true; | |
clip.set(0, 0, fieldWidth, textHeight); | |
initted = true; | |
updateScroll(); | |
} | |
function updateScroll() | |
{ | |
clipRect = null; | |
clip.height = textHeight; | |
clipRect = clip; | |
} | |
override function set_fieldWidth(value:Int):Int | |
{ | |
_fieldWidth = 0; | |
if (initted) | |
{ | |
clip.width = value; | |
updateScroll(); | |
} | |
return value; | |
} | |
override function get_fieldWidth():Int | |
{ | |
return Math.round(clip.width); | |
} | |
override function drawText(posX:Int, posY:Int, isFront = true, ?bitmap, useTiles = false) | |
{ | |
super.drawText(posX - scrollX, posY, isFront, bitmap, useTiles); | |
} | |
} | |
class ScrollText extends FlxText | |
{ | |
public var scrollX(default, set):Int; | |
function set_scrollX(value:Int) | |
{ | |
scrollX = value; | |
updateScroll(); | |
return scrollX; | |
} | |
final clip = FlxRect.get(); | |
var initted = false; | |
public function new(x = 0.0, y = 0.0, ?text, fieldWidth:Int, font) | |
{ | |
super(x, y, text, font); | |
wordWrap = false; | |
autoSize = true; | |
clip.set(0, 0, fieldWidth, frameHeight); | |
initted = true; | |
updateScroll(); | |
} | |
function updateScroll() | |
{ | |
clipRect = null; | |
if (scrollX > width - clip.width) | |
scrollX = Math.round(width - clip.width); | |
if (scrollX < 0) | |
scrollX = 0; | |
clip.height = frameHeight; | |
clipRect = clip; | |
} | |
} | |
// class ScrollingBitmapTextY extends BaseTextBMP | |
// { | |
// public var scrollY(default, set):Float = 0; | |
// public var maxScrollY(get, never):Int; | |
// public var fieldHeight(get, set):Int; | |
// function set_scrollY(value:Float) | |
// { | |
// if (value > maxScrollY) | |
// value = maxScrollY; | |
// if (value < 0) | |
// value = 0; | |
// updateScroll(); | |
// return scrollY = value; | |
// } | |
// function get_maxScrollY() | |
// { | |
// return textHeight - Math.round(clip.height); | |
// } | |
// final clip = FlxRect.get(); | |
// var initted = false; | |
// public function new(x = 0.0, y = 0.0, ?text:UnicodeString, fieldWidth:Int, fieldHeight:Int, ?font:FontType) | |
// { | |
// super(x, y, text, fieldWidth, font); | |
// multiLine = true; | |
// autoSize = false; | |
// clip.set(0, 0, fieldWidth, fieldHeight); | |
// initted = true; | |
// updateScroll(); | |
// } | |
// function updateScroll() | |
// { | |
// clipRect = null; | |
// clip.width = textWidth; | |
// clipRect = clip; | |
// } | |
// override function updateText() | |
// { | |
// super.updateText(); | |
// updateScroll(); | |
// } | |
// override function set_fieldWidth(value:Int):Int | |
// { | |
// if (value == 0) | |
// throw "Cannout use autosize (fieldWidth: 0) in ScrollingBitmapTextY"; | |
// super.set_fieldWidth(value); | |
// if (initted) | |
// updateScroll(); | |
// return value; | |
// } | |
// function set_fieldHeight(value:Int):Int | |
// { | |
// if (initted) | |
// { | |
// clip.height = value; | |
// updateScroll(); | |
// } | |
// return value; | |
// } | |
// function get_fieldHeight():Int | |
// { | |
// return Math.round(clip.height); | |
// } | |
// override function drawText(posX:Int, posY:Int, isFront = true, ?bitmap, useTiles = false) | |
// { | |
// super.drawText(posX, posY - Math.round(scrollY), isFront, bitmap, useTiles); | |
// } | |
// static final bgColorTransform = new ColorTransform(); | |
// static final borderColorTransform = new ColorTransform(); | |
// static final textColorTransform = new ColorTransform(); | |
// override function draw() | |
// { | |
// if (FlxG.renderBlit) | |
// { | |
// checkPendingChanges(false); | |
// super.draw(); | |
// } | |
// else | |
// { | |
// checkPendingChanges(true); | |
// textColorTransform.setMultipliers(color.redFloat, color.greenFloat, color.blueFloat, 1); | |
// if (useTextColor) | |
// { | |
// textColorTransform.redMultiplier *= textColor.redFloat; | |
// textColorTransform.greenMultiplier *= textColor.greenFloat; | |
// textColorTransform.blueMultiplier *= textColor.blueFloat; | |
// textColorTransform.blueMultiplier *= textColor.alphaFloat; | |
// } | |
// borderColorTransform.redMultiplier = borderColor.redFloat * color.redFloat; | |
// borderColorTransform.greenMultiplier = borderColor.greenFloat * color.greenFloat; | |
// borderColorTransform.blueMultiplier = borderColor.blueFloat * color.blueFloat; | |
// borderColorTransform.alphaMultiplier = borderColor.alphaFloat * alpha; | |
// final scaleX:Float = scale.x * _facingHorizontalMult; | |
// final scaleY:Float = scale.y * _facingVerticalMult; | |
// final originX:Float = _facingHorizontalMult != 1 ? frameWidth - origin.x : origin.x; | |
// final originY:Float = _facingVerticalMult != 1 ? frameHeight - origin.y : origin.y; | |
// final clippedFrameRect = FlxRect.get(0, 0, frameWidth, frameHeight); | |
// if (clipRect != null) | |
// clippedFrameRect.clipTo(clipRect); | |
// if (clippedFrameRect.isEmpty) | |
// return; | |
// final charClipHelper = FlxRect.get(); | |
// @:privateAccess | |
// final charClippedFrame = new FlxFrame(null); | |
// final cameras = getCamerasLegacy(); | |
// for (camera in cameras) | |
// { | |
// if (!camera.visible || !camera.exists || !isOnScreen(camera)) | |
// { | |
// continue; | |
// } | |
// getScreenPosition(_point, camera).subtractPoint(offset); | |
// if (isPixelPerfectRender(camera)) | |
// { | |
// _point.floor(); | |
// } | |
// updateTrig(); | |
// if (background) | |
// { | |
// // backround tile transformations | |
// _matrix.identity(); | |
// _matrix.scale(0.1 * clippedFrameRect.width, 0.1 * clippedFrameRect.height); | |
// _matrix.translate(clippedFrameRect.x - originX, clippedFrameRect.y - originY); | |
// _matrix.scale(scaleX, scaleY); | |
// if (angle != 0) | |
// { | |
// _matrix.rotateWithTrig(_cosAngle, _sinAngle); | |
// } | |
// _matrix.translate(_point.x + originX, _point.y + originY); | |
// bgColorTransform.redMultiplier = color.redFloat * backgroundColor.redFloat; | |
// bgColorTransform.greenMultiplier = color.greenFloat * backgroundColor.greenFloat; | |
// bgColorTransform.blueMultiplier = color.blueFloat * backgroundColor.blueFloat; | |
// bgColorTransform.alphaMultiplier = alpha * backgroundColor.alphaFloat; | |
// camera.drawPixels(FlxG.bitmap.whitePixel, null, _matrix, bgColorTransform, blend, antialiasing); | |
// } | |
// var hasColorOffsets:Bool = (colorTransform != null && colorTransform.hasRGBAOffsets()); | |
// final drawItem = camera.startQuadBatch(font.parent, true, hasColorOffsets, blend, antialiasing, shader); | |
// if (clipRect != null) | |
// { | |
// clippedFrameRect.left -= borderSize; | |
// clippedFrameRect.top -= borderSize; | |
// clippedFrameRect.right += borderSize; | |
// clippedFrameRect.bottom += borderSize; | |
// } | |
// for (j in 0...Std.int(borderDrawData.length / 3)) | |
// { | |
// final dataPos = j * 3; | |
// final currFrame = font.getCharFrame(Std.int(borderDrawData[dataPos])); | |
// final currTileX = borderDrawData[dataPos + 1]; | |
// final currTileY = borderDrawData[dataPos + 2]; | |
// if (clipRect != null) | |
// { | |
// charClipHelper.copyFrom(clippedFrameRect).offset(-currTileX, -currTileY); | |
// currFrame.clipTo(charClipHelper, charClippedFrame); | |
// } | |
// else | |
// { | |
// currFrame.copyTo(charClippedFrame); | |
// } | |
// charClippedFrame.prepareMatrix(_matrix); | |
// _matrix.translate(currTileX - originX, currTileY - originY); | |
// _matrix.scale(scaleX, scaleY); | |
// if (angle != 0) | |
// { | |
// _matrix.rotateWithTrig(_cosAngle, _sinAngle); | |
// } | |
// _matrix.translate(_point.x + originX, _point.y + originY); | |
// drawItem.addQuad(charClippedFrame, _matrix, borderColorTransform); | |
// } | |
// if (clipRect != null) | |
// { | |
// clippedFrameRect.left += borderSize; | |
// clippedFrameRect.top += borderSize; | |
// clippedFrameRect.right -= borderSize; | |
// clippedFrameRect.bottom -= borderSize; | |
// } | |
// for (j in 0...Std.int(textDrawData.length / 3)) | |
// { | |
// final dataPos = j * 3; | |
// var currFrame = font.getCharFrame(Std.int(textDrawData[dataPos])); | |
// final currTileX = textDrawData[dataPos + 1]; | |
// final currTileY = textDrawData[dataPos + 2]; | |
// if (clipRect != null) | |
// { | |
// charClipHelper.copyFrom(clippedFrameRect).offset(-currTileX, -currTileY); | |
// currFrame = currFrame.clipTo(charClipHelper); | |
// } | |
// currFrame.prepareMatrix(_matrix); | |
// _matrix.translate(currTileX - originX, currTileY - originY); | |
// _matrix.scale(scaleX, scaleY); | |
// if (angle != 0) | |
// { | |
// _matrix.rotateWithTrig(_cosAngle, _sinAngle); | |
// } | |
// _matrix.translate(_point.x + originX, _point.y + originY); | |
// drawItem.addQuad(currFrame, _matrix, textColorTransform); | |
// } | |
// #if FLX_DEBUG | |
// FlxBasic.visibleCount++; | |
// #end | |
// } | |
// // dispose clipRect helpers | |
// clippedFrameRect.put(); | |
// #if FLX_DEBUG | |
// if (FlxG.debugger.drawDebug) | |
// { | |
// drawDebug(); | |
// } | |
// #end | |
// } | |
// } | |
// } | |
// the bad one | |
class ScrollingBitmapTextY extends BaseTextBMP | |
{ | |
public var scrollY(default, set):Float = 0; | |
public var maxScrollY(get, never):Int; | |
public var fieldHeight(get, set):Int; | |
function set_scrollY(value:Float) | |
{ | |
if (value > maxScrollY) | |
value = maxScrollY; | |
if (value < 0) | |
value = 0; | |
updateScroll(); | |
return scrollY = value; | |
} | |
function get_maxScrollY() | |
{ | |
return textHeight - Math.round(clip.height); | |
} | |
final clip = FlxRect.get(); | |
var initted = false; | |
public function new(x = 0.0, y = 0.0, ?text:UnicodeString, fieldWidth:Int, fieldHeight:Int, ?font:FontType) | |
{ | |
super(x, y, text, fieldWidth, font); | |
multiLine = true; | |
autoSize = false; | |
clip.set(0, 0, fieldWidth, fieldHeight); | |
initted = true; | |
updateScroll(); | |
} | |
function updateScroll() | |
{ | |
clipRect = null; | |
clip.width = textWidth; | |
// clipRect = clip; | |
} | |
override function updateText() | |
{ | |
super.updateText(); | |
updateScroll(); | |
} | |
override function set_fieldWidth(value:Int):Int | |
{ | |
if (value == 0) | |
throw "Cannout use autosize (fieldWidth: 0) in ScrollingBitmapTextY"; | |
super.set_fieldWidth(value); | |
if (initted) | |
updateScroll(); | |
return value; | |
} | |
function set_fieldHeight(value:Int):Int | |
{ | |
if (initted) | |
{ | |
clip.height = value; | |
updateScroll(); | |
} | |
return value; | |
} | |
function get_fieldHeight():Int | |
{ | |
return Math.round(clip.height); | |
} | |
override function drawText(posX:Int, posY:Int, isFront = true, ?bitmap, useTiles = false) | |
{ | |
super.drawText(posX, posY - Math.round(scrollY), isFront, bitmap, useTiles); | |
} | |
static final bgColorTransform = new ColorTransform(); | |
static final borderColorTransform = new ColorTransform(); | |
static final textColorTransform = new ColorTransform(); | |
override function draw() | |
{ | |
if (FlxG.renderBlit) | |
{ | |
checkPendingChanges(false); | |
super.draw(); | |
} | |
else | |
{ | |
checkPendingChanges(true); | |
textColorTransform.setMultipliers(color.redFloat, color.greenFloat, color.blueFloat, 1); | |
if (useTextColor) | |
{ | |
textColorTransform.redMultiplier *= textColor.redFloat; | |
textColorTransform.greenMultiplier *= textColor.greenFloat; | |
textColorTransform.blueMultiplier *= textColor.blueFloat; | |
textColorTransform.blueMultiplier *= textColor.alphaFloat; | |
} | |
borderColorTransform.redMultiplier = borderColor.redFloat * color.redFloat; | |
borderColorTransform.greenMultiplier = borderColor.greenFloat * color.greenFloat; | |
borderColorTransform.blueMultiplier = borderColor.blueFloat * color.blueFloat; | |
borderColorTransform.alphaMultiplier = borderColor.alphaFloat * alpha; | |
final scaleX:Float = scale.x * _facingHorizontalMult; | |
final scaleY:Float = scale.y * _facingVerticalMult; | |
final originX:Float = _facingHorizontalMult != 1 ? frameWidth - origin.x : origin.x; | |
final originY:Float = _facingVerticalMult != 1 ? frameHeight - origin.y : origin.y; | |
final clippedFrameRect = FlxRect.get(0, 0, clip.width, clip.height); | |
if (clip != null) | |
clippedFrameRect.clipTo(clip); | |
if (clippedFrameRect.isEmpty) | |
return; | |
final charClipHelper = FlxRect.get(); | |
@:privateAccess | |
final charClippedFrame = new FlxFrame(null); | |
final cameras = getCamerasLegacy(); | |
for (camera in cameras) | |
{ | |
if (!camera.visible || !camera.exists || !isOnScreen(camera)) | |
{ | |
continue; | |
} | |
getScreenPosition(_point, camera).subtractPoint(offset); | |
if (isPixelPerfectRender(camera)) | |
{ | |
_point.floor(); | |
} | |
updateTrig(); | |
if (background) | |
{ | |
// backround tile transformations | |
_matrix.identity(); | |
_matrix.scale(0.1 * clippedFrameRect.width, 0.1 * clippedFrameRect.height); | |
_matrix.translate(clippedFrameRect.x - originX, clippedFrameRect.y - originY); | |
_matrix.scale(scaleX, scaleY); | |
if (angle != 0) | |
{ | |
_matrix.rotateWithTrig(_cosAngle, _sinAngle); | |
} | |
_matrix.translate(_point.x + originX, _point.y + originY); | |
bgColorTransform.redMultiplier = color.redFloat * backgroundColor.redFloat; | |
bgColorTransform.greenMultiplier = color.greenFloat * backgroundColor.greenFloat; | |
bgColorTransform.blueMultiplier = color.blueFloat * backgroundColor.blueFloat; | |
bgColorTransform.alphaMultiplier = alpha * backgroundColor.alphaFloat; | |
camera.drawPixels(FlxG.bitmap.whitePixel, null, _matrix, bgColorTransform, blend, antialiasing); | |
} | |
var hasColorOffsets:Bool = (colorTransform != null && colorTransform.hasRGBAOffsets()); | |
final drawItem = camera.startQuadBatch(font.parent, true, hasColorOffsets, blend, antialiasing, shader); | |
for (j in 0...Std.int(borderDrawData.length / 3)) | |
{ | |
final dataPos = j * 3; | |
final charCode = Std.int(borderDrawData[dataPos]); | |
final currFrame = font.getCharFrame(charCode); | |
final currTileX = borderDrawData[dataPos + 1]; | |
final currTileY = borderDrawData[dataPos + 2]; | |
// if ([5346, 4626, 3906, 3186, 2466, 1746, 1095, 444].contains(dataPos)) | |
// { | |
// continue; | |
// } | |
if (charCode == StringTools.fastCodeAt('q', 0)) | |
{ | |
if (FlxG.keys.justPressed.D) | |
{ | |
trace('Drawing q ${dataPos} borders at: (${currTileX}, ${currTileY})'); | |
} | |
} | |
if (clip != null) | |
{ | |
charClipHelper.copyFrom(clippedFrameRect).offset(-currTileX, -currTileY); | |
currFrame.clipTo(charClipHelper, charClippedFrame); | |
} | |
else | |
{ | |
currFrame.copyTo(charClippedFrame); | |
} | |
charClippedFrame.prepareMatrix(_matrix); | |
_matrix.translate(currTileX - originX, currTileY - originY); | |
_matrix.scale(scaleX, scaleY); | |
if (angle != 0) | |
{ | |
_matrix.rotateWithTrig(_cosAngle, _sinAngle); | |
} | |
_matrix.translate(_point.x + originX, _point.y + originY); | |
drawItem.addQuad(charClippedFrame, _matrix, borderColorTransform); | |
} | |
if (clip != null) | |
{ | |
clippedFrameRect.left += borderSize; | |
clippedFrameRect.top += borderSize; | |
clippedFrameRect.right -= -borderSize; | |
clippedFrameRect.bottom -= borderSize; | |
} | |
for (j in 0...Std.int(textDrawData.length / 3)) | |
{ | |
final dataPos = j * 3; | |
var charCode = Std.int(textDrawData[dataPos]); | |
var currFrame = font.getCharFrame(charCode); | |
final currTileX = textDrawData[dataPos + 1]; | |
final currTileY = textDrawData[dataPos + 2]; | |
// if ([513].contains(dataPos)) | |
// { | |
// continue; | |
// } | |
if (FlxG.keys.justPressed.D) | |
{ | |
if (Math.abs(currTileX - 133) < 3 && Math.abs(currTileY - 61) < 5) | |
{ | |
trace('Drawing something with charCode ${charCode} at: (${currTileX}, ${currTileY})'); | |
} | |
} | |
if (charCode == StringTools.fastCodeAt('z', 0)) | |
{ | |
trace('a zed!'); | |
} | |
if (charCode == StringTools.fastCodeAt('q', 0)) | |
{ | |
// continue; | |
if (FlxG.keys.justPressed.D) | |
{ | |
trace('Drawing q ${dataPos} text at: (${currTileX}, ${currTileY})'); | |
} | |
} | |
if (clip != null) | |
{ | |
charClipHelper.copyFrom(clippedFrameRect).offset(-currTileX, -currTileY); | |
currFrame = currFrame.clipTo(charClipHelper); | |
} | |
currFrame.prepareMatrix(_matrix); | |
_matrix.translate(currTileX - originX, currTileY - originY); | |
_matrix.scale(scaleX, scaleY); | |
if (angle != 0) | |
{ | |
_matrix.rotateWithTrig(_cosAngle, _sinAngle); | |
} | |
_matrix.translate(_point.x + originX, _point.y + originY); | |
// if (FlxG.random.bool()) | |
drawItem.addQuad(currFrame, _matrix, textColorTransform); | |
} | |
if (clipRect != null) | |
{ | |
clippedFrameRect.left -= borderSize; | |
clippedFrameRect.top -= borderSize; | |
clippedFrameRect.right += borderSize; | |
clippedFrameRect.bottom += borderSize; | |
} | |
#if FLX_DEBUG | |
FlxBasic.visibleCount++; | |
#end | |
} | |
if (FlxG.keys.justPressed.D) | |
{ | |
trace(' '); | |
} | |
// dispose clipRect helpers | |
clippedFrameRect.put(); | |
#if FLX_DEBUG | |
if (FlxG.debugger.drawDebug) | |
{ | |
drawDebug(); | |
} | |
#end | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment