[Monkey] Monkeys Gehmnisvolle GetChar funktion?

Übersicht Andere Programmiersprachen Beginners-Corner

Neue Antwort erstellen

Mathias-Kwiatkowski

Betreff: Monkeys Gehmnisvolle GetChar funktion?

BeitragDo, Nov 26, 2015 19:11
Antworten mit Zitat
Benutzer-Profile anzeigen
also ich versuche es eine benutzereingabe zu verwirklichen in html5


(der gesammte code klappt 1A) nur die eigentliche eingabe nicht warum? (in html5 klappt es leider nicht in Desktop APP schon) wo ist das geheimniss?

Code: [AUSKLAPPEN]
Import mojo

#GLFW_WINDOW_TITLE="BlitzProg"
#GLFW_WINDOW_WIDTH=1000
#GLFW_WINDOW_HEIGHT=900
#MOJO_AUTO_SUSPEND_ENABLED=False

Class FPS
   Field Frames:Int
   Field Count:Int
   Field Timer:Int
   
   Function NewFPS:FPS()
      Local F:FPS = New FPS
      F.Timer = Millisecs()
      Return F
   End
   
   Method Update()
      Count = Count + 1
      If (Millisecs() -Timer) > 1000 Then
         Timer = Millisecs()
         Frames = Count
         Count = 0
      EndIf
   End
End



Class Game Extends App
   Field image:Image
   Field MX:Int
   Field MY:Int
   
   Field MyFPS:FPS
   
   Field BenutzerName:String
      
   Method OnCreate()
      SetUpdateRate 60
      image = LoadImage("001.jpg")
      MyFPS = FPS.NewFPS()
   End
   
   Method OnUpdate()
      Repeat
         MX=MouseX()
         MY = MouseY()
         MyFPS.Update()
         
         Local Char = GetChar()
         If Not Char Exit
         If Char >= 32 Then
            BenutzerName += String.FromChar(Char)
         EndIf
         UpdateAsyncEvents
      Forever
   End

   Method OnRender()
      Cls
      DrawImage image,0,0,0,Float(DeviceWidth)/2560.0,Float(DeviceHeight)/1600.0,0

      SetColor 255, 255, 255
      DrawText "Name: " + BenutzerName, 10, 140
      
      DrawText "MX: " + MX + " MY: " + MY, 10, 100
      DrawText DeviceWidth() + " " + DeviceHeight(), 10, 120

      
      SetColor 255, 0, 0
      DrawText "FPS: " + MyFPS.Frames, 10, 600
      
      Print BenutzerName
      
      
   End

End

Function Main()
   New Game()
End



Das Example klappt auch in html5 -> das ist das example
Code: [AUSKLAPPEN]
Import mojo

Class MyApp Extends App

   Field text$="Type something:"

   Method OnCreate()
      SetUpdateRate 30
   End
   
   Method OnUpdate()

         Local char=GetChar()
      '   If Not char Exit
         If char>=32
            text+=String.FromChar( char )
         Endif

   End
   
   Method OnRender()
      Cls
      DrawText text,0,0
   End
End

Function Main()
   New MyApp
End
Skype: Anarchie1984
http://projektworks.de/maxbase/
Icq - Erneuert am 21.08.2017
Yahoo - Erneuert am 21.08.2017

Farbfinsternis

BeitragFr, Nov 27, 2015 19:47
Antworten mit Zitat
Benutzer-Profile anzeigen
Dein Code funktioniert. Hin und wieder ist in solchen Fällen die Lösung: Den Build-Ordner löschen.
Farbfinsternis.tv

Neue Antwort erstellen


Übersicht Andere Programmiersprachen Beginners-Corner

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group