Hi,
Getting close - current build runs with no errors!
We need help converting our "DrawText()" Godot 3.5 function to Godot 4.
Please, if you can, look at below function, thanks!:
Jesse
func DrawText(index, text, x, y, horizontalJustification, fontSize, scaleX, scaleY, rotation, red, green, blue, alpha, outlineRed, outlineGreen, outlineBlue):
if ( index > (TextCurrentIndex-1) ):
Texts.TextImage.append(RichTextLabel.new())
add_child(Texts.TextImage[index])
var fontToUseIndex = 0
if fontSize == 25:
fontToUseIndex = 0
elif fontSize == 60:
fontToUseIndex = 1
elif fontSize == 35:
fontToUseIndex = 2
elif fontSize == 12:
fontToUseIndex = 3
elif fontSize == 22:
fontToUseIndex = 4
Texts.TextImage[index].rect_clip_content = false
Texts.TextImage[index].add_font_override("normal_font", FontTTF[fontToUseIndex])
# Need code to set font size - it should be set to: "fontSize"
Texts.TextImage[index].modulate = Color(red, green, blue, alpha)
FontTTF[fontToUseIndex].outline_size = 3
FontTTF[fontToUseIndex].outline_color = Color(outlineRed, outlineGreen, outlineBlue, alpha)
Texts.TextImage[index].text = text
var textWidth = Texts.TextImage[index].get_font("normal_font").get_string_size(Texts.TextImage[index].text).x
var textHeight = Texts.TextImage[index].get_font("normal_font").get_string_size(Texts.TextImage[index].text).y
Texts.TextImage[index].rect_global_position.x = x
Texts.TextImage[index].rect_global_position.y = (y - (textHeight / 2))
Texts.TextImage[index].set_size(Vector2(ScreenWidth, ScreenHeight), false)
Texts.TextImage[index].rect_pivot_offset = Vector2((textWidth / 2), (textHeight / 2))
Texts.TextImage[index].rect_scale = Vector2(scaleX, scaleY)
Texts.TextImage[index].rect_rotation = rotation
if horizontalJustification == 0:
Texts.TextImage[index].rect_global_position.x = x
elif horizontalJustification == 1:
Texts.TextImage[index].rect_global_position.x = ((VisualsCore.ScreenWidth/2) - (textWidth / 2))
elif horizontalJustification == 2:
Texts.TextImage[index].rect_global_position.x = (VisualsCore.ScreenWidth - x - (textWidth))
elif horizontalJustification == 4:
Texts.TextImage[index].rect_global_position.x = (x - (textWidth / 2))
Texts.TextIndex.append(index)
Texts.TextScreenX.append(x)
Texts.TextScreenY.append(y)
Texts.TextHorizontalJustification.append(horizontalJustification)
Texts.TextSize.append(fontSize)
Texts.TextScaleX.append(scaleX)
Texts.TextScaleY.append(scaleY)
Texts.TextRotation.append(rotation)
Texts.TextColorRed.append(red)
Texts.TextColorGreen.append(green)
Texts.TextColorBlue.append(blue)
Texts.TextColorAlpha.append(alpha)
Texts.TextOutlineRed.append(outlineRed)
Texts.TextOutlineGreen.append(outlineGreen)
Texts.TextOutlineBlue.append(outlineBlue)
TextCurrentIndex+=1
return(TextCurrentIndex-1)
pass