Cursor-Kollision mit Text, aber wie !?
Übersicht

Blitzkrieg BopBetreff: Cursor-Kollision mit Text, aber wie !? |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Hi!
Ehm, wie ist es am besten möglich eine abfrage zu schalten, ob ein cursor mit einem Text "überlappt"? Imagescollide fällt ja flach, weil der Text ja kein bild ist. Achja: der text verändert sich, steht also net immer an einer stelle. |
||
~ Hey Ho Let's Go ~ |
![]() |
Triton |
![]() Antworten mit Zitat ![]() |
---|---|---|
Code: [AUSKLAPPEN] If mousex() > textx and mouseX() < textx+textbreite and mousey() > texty and mousey() < texty+texthöhe then Text textx,texty, "Sie haben gerade die Maus auf diesem Text!" ![]() |
||
![]() |
Mattis_the_brain |
![]() Antworten mit Zitat ![]() |
---|---|---|
Entweder
RectsOverlap() <-- Hier nicht geeignet (rect und rect wird geprüft) aber möglich wir wollen aber pixel und rect prüfen also wie schon eben gesagt blos eben in einer praktischen Function: Code: [AUSKLAPPEN] text_x = 10 text_y = 90 der_text$ = "Ich bin der Text!" SetBuffer(BackBuffer()) While(KeyHit(1) = 0) Cls Text(text_x, text_y, der_text$) If(kollision(MouseX(), MouseY(), text_x, text_y, StringWidth(der_text$), StringHeight(der_text$))) Text(text_x, text_y + 15, "Maus berührt Text!") Flip Wend End Function kollision(x3, y3, x1, y1, x2, y2) If(x3 => x1 And y3 => y1 And x3 <= x1 + x2 And y3 <= y1 + y2) Return True Else Return False EndIf End Function oder mit rectsoverlap: Code: [AUSKLAPPEN] text_x = 10 text_y = 90 der_text$ = "Ich bin der Text!" SetBuffer(BackBuffer()) While(KeyHit(1) = 0) Cls Text(text_x, text_y, der_text$) If(RectsOverlap(MouseX(), MouseY(), 1, 1, text_x, text_y, StringWidth(der_text$), StringHeight(der_text$))) Text(text_x, text_y + 15, "Maus berührt Text!") Flip Wend End |
||
Blitzkrieg Bop |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
danke, hab shcon anders gelöst ![]() |
||
~ Hey Ho Let's Go ~ |
![]() |
Mattis_the_brain |
![]() Antworten mit Zitat ![]() |
---|---|---|
Das "Anders" mag ich mal sehen^^ | ||
Blitzkrieg Bop |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
also, ich habs wie folgT:
das ist jetzt der code , wenn der den Text "Spiel" überlappt: Code: [AUSKLAPPEN] If x_maus > x-30 And x_maus < x + 18 And y_maus > y - 11 And y_maus < y + 17 Then play_maus1 = play_maus1 + 1 Text 600,600,"Überlappung Spiel",True Else play_maus1 = 0 EndIf |
||
~ Hey Ho Let's Go ~ |
Ensign Joe |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
n Kleiner Tipp:
Arbeite niemals mit festen Zahlen, sondern berechne sie! |
||
![]() |
RallimenSieger des 30-EUR-Wettbewerbs |
![]() Antworten mit Zitat ![]() |
---|---|---|
hallo,
da hab ich auch noch was ......ne kleine function Code: [AUSKLAPPEN] Graphics 800,600,16,2 SetBuffer BackBuffer() Global font1 = LoadFont("Times New Roman", 40, 1, 0, 0) Global font2 = LoadFont("Times New Roman", 20, 1, 0, 0) Repeat SetFont font1 Text 100,100,"Text1 ",1,1 If Maus_Text_Kollision(100,100,"Text1 ",1,1) Then Text 10,10,"Überlappung text 1" SetFont font2 Text 300,250,"Überlappungs Text2",1 If Maus_Text_Kollision(300,250,"Überlappungs Text2",1) Then Text 10,10,"Überlappung text 2" Flip:Cls Until KeyHit(1) End Function Maus_Text_Kollision(xPos,yPos,Text$,AusrichtungX = 0,AusrichtungY = 0) Breite=StringWidth(Text$) Hoehe =StringHeight(Text$) If AusrichtungX = 1 Then xPos = xPos - Breite/2 If AusrichtungY = 1 Then yPos = yPos - Hoehe/2 ;Rect xPos,yPos,Breite,Hoehe,0; Rahmen zur kontrolle If RectsOverlap(xPos,yPos,Breite,Hoehe,MouseX(),MouseY(),1,1) Then Return 1 Return 0 End Function funtioniert auch wenn der text mit Text x,y,A$,1,1 mittig gesetzt wird Kopieren ...Probieren |
||
[BB2D | BB3D | BB+]
|
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group