ich habe eine Prozdure erstellt die eine Sprechblase anzeigen lässt und diese dann mit gewünschten Text füllen lässt. Die Sprecheblase ist eine Ellipse. Hier mal der Code:
Code: Alles auswählen
InitSprite()
InitKeyboard()
Structure DRAttributes
Y.w
X.w
Width.w
EndStructure
NewList DialogRows.DRAttributes()
Enumeration
#DIALOG
EndEnumeration
#ZEILENABSTAND = 12 ;Je größer, umso mehr Abstand hat man zwischen den Zeilen
#VERHAELTNIS = 1 ;Verhäötniss zwischen X und Y Achse der Sprechblase. 1 = 2:1. Je kleiner desto größer ist die Y-Achse
Procedure SpeechBlister(InputText.s)
LoadFont(0,"Comic Sans MS",9,#PB_Font_HighQuality | #PB_Font_Bold )
Text.s = InputText
StartDrawing(ScreenOutput()) ;Textlänge (in Pixel) ermitteln
DrawingFont(UseFont(0))
TextLenght = TextLength(Text)
StopDrawing()
Pi.f = 3.14159
RadiusX.f = Sqr(((Len(Text)*((TextLenght/Len(text))*#ZEILENABSTAND))/Pi)*2*#VERHAELTNIS)+11
RadiusY.f = Sqr(((Len(Text)*((TextLenght/Len(text))*#ZEILENABSTAND))/Pi)/2/#VERHAELTNIS)+11
If DialogBerechnung = 0
MaxRows = 2*RadiusY/#ZEILENABSTAND
For i = 0 To MaxRows-1 ;DilogRows() deklenieren
If i = 0
ii.f = 0.5
Else
ii = i+0.5
EndIf
AddElement(DialogRows())
DialogRows()\Y = ii*2*(RadiusY/MaxRows)
DialogRows()\X = RadiusX - Sqr(Pow(RadiusX,2) * ( 1- (Pow( (RadiusY-DialogRows()\Y), 2)) / Pow(RadiusY,2)))
DialogRows()\Width = 2* (Sqr(Pow(RadiusX,2) * ( 1- (Pow( (RadiusY-DialogRows()\Y), 2)) / Pow(RadiusY,2))))
Next
Dim DialogRowDisplay.s(MaxRows) ;Der Text jeder Reihe in der Sprechblase steht in dem Array
DialogRowDisplay(0) = text
For l = 0 To MaxRows-1 ;Jede Row beschriften
AddChars+1
SelectElement(DialogRows(),l)
While RowTextLength < DialogRows()\Width-5-DecreeseTheWidth
If BreakIfLenToLong = Len(text)+AddChars
Break
EndIf
If RadiusY-DialogRows()\Y < 0 And MaxRows > 1 ;Die 2. Hälfte der Rows wird ein Stück verrückt angezeigt damit sie nicht aus der Sprechblase rangt.
DecreeseTheWidth = 20
EndIf
DialogRowDisplay(l) = Mid(text,RowTextStart,RowLength)
StartDrawing(ScreenOutput())
DrawingFont(UseFont(0))
RowTextLength = TextLength(Mid(text,RowTextStart,RowLength))
StopDrawing()
RowLength + 1
BreakIfLenToLong + 1
Wend
If l <> 0 ;Ohne diese Abfrage würde ein Buchstabe in der Ersten Reihe fehlen.
RowTextStart + RowLength-1
Else
RowTextStart + RowLength
EndIf
RowTextLength = 0
RowLength = 0
Next
CreateSprite(#DIALOG,2*RadiusX,2*RadiusY+20)
StartDrawing(SpriteOutput(#DIALOG)) ;Die Ellipse malen
Ellipse(RadiusX,RadiusY,RadiusX,RadiusY,RGB(240,240,210))
LineXY(RadiusX-RadiusX/4,2*RadiusY-3,RadiusX,2*RadiusY+20,RGB(240,240,210))
LineXY(RadiusX+RadiusX/4,2*RadiusY-3,RadiusX,2*RadiusY+20,RGB(240,240,210))
FillArea(RadiusX,2*RadiusY+10,RGB(240,240,210),RGB(240,240,210))
DrawingMode(1)
DrawingFont(UseFont(0))
Locate(0,0)
FrontColor(1,0,0)
FirstElement(DialogRows())
For k = 0 To MaxRows-1 ;Jede Row ausgeben
If RadiusY-DialogRows()\Y < 0 And MaxRows > 1
NextElement(DialogRows())
AddToX = DialogRows()\x/2+10
PreviousElement(DialogRows())
EndIf
If MaxRows <= 1
Locate(2,0)
Else
Locate(DialogRows()\x+AddToX,DialogRows()\y)
EndIf
DrawText(DialogRowDisplay(k))
NextElement(DialogRows())
Next
StopDrawing()
EndIf
DialogBerechnung = 1
DisplayTransparentSprite(#DIALOG,400-RadiusX,300-RadiusY)
EndProcedure
OpenScreen(800,600,32,"Sprechblase!")
Repeat
SpeechBlister("Feel the Pure Power!")
FlipBuffers()
ExamineKeyboard()
Until KeyboardPushed(#PB_KEY_ESCAPE)

Ciao