[Monkey] Mousehit Mousedown etwas missbrauchen

Übersicht Andere Programmiersprachen Beginners-Corner

Neue Antwort erstellen

Dottakopf

Betreff: Mousehit Mousedown etwas missbrauchen

BeitragFr, Apr 03, 2015 9:32
Antworten mit Zitat
Benutzer-Profile anzeigen
Hallo Blitzer,

vielleich ist es einfach zu früh am morgen aber irgendwie stell ich mich gerade doof an.

ich habe einige simple Buttons(images) wenn man drauf drückt soll das nächste Menü geladen werden... Easy
Nun will ich es aber etwas lebendiger mit minimalsten aufwand(also ohne eine extra Funktion) machen. Es soll für einen kurzen augenblick der Butten "markiert"(zweites Image) werden, und erst dann erst weiter.

Nun dachte ich mir ich missbrauche die Mousehit und Mousedown eigenschaften etwas.
Mousedown -> markierung wird gezeichnet
Mosuehit -> sobalt taste losgelassen wird änderung durchgeführt

genial, oder trottelig.... Very Happy Very Happy es klappt nicht.

Hat das einer schon so simpel gemacht oder werd ich mir "States" für den Button coden müssen, weil es einfach so nicht geht ?

Hier in dem Beispiel sieht man das Mousehit leider schon ausgelöst wird wenn mann es drückt, nicht erst wenn man es loslässt.. hmm irgendwer eine Idee Embarassed

(Rot = normal, Grün = gedrückt) Richtig wäre.. erst grün dann zu Rot und andere Pos..
Code: [AUSKLAPPEN]


Import mojo

Global MHit:Int
Global MDown:Int

Global GameState:Int


Function Main()
   New Game()
End

Class Game Extends App

   'summary:The OnCreate Method is called when mojo has been initialized and the application has been successfully created.
   Method OnCreate()
   
      'Set how many times per second the game should update and render itself
      SetUpdateRate(60)
   
   End
   
   'summary: This method is automatically called when the application's update timer ticks.
   Method OnUpdate()
   
         MHit = 0
         MDown = 0
         
         If MouseHit() Then MHit = 1
         If MouseDown() Then MDown = 1
         
   
   End
   
   'summary: This method is automatically called when the application should render itself, such as when the application first starts, or following an OnUpdate call.
   Method OnRender()
      Cls()
      
      SetColor 255, 0, 0
      
      
      If MDown = 1 Then SetColor 0, 255, 0
      If MHit = 1 Then GameState += 1
      If GameState > 1 Then GameState = 0
      
      
      If GameState = 0 Then
         DrawRect(0, 0, 128, 128)
      Else
         DrawRect(100, 100, 128, 128)
      EndIf
      
      
      
      
   End

   'summary: This method is called instead of OnRender when the application should render itself, but there are still resources such as images or sounds in the process of being loaded.
   Method OnLoading()
      
   End
   
   'summary: This method is called when the application's device window size changes.
   Method OnResize()
      
   End
   
   '#REGION Code to handle susped status of the game goes here
   
   'summary: OnSuspend is called when your application is about to be suspended.
   Method OnSuspend()
   
   End
   
   'summary: OnResume is called when your application is made active again after having been in a suspended state.
   Method OnResume()
      
   End   
   '#END REGION
   
   '#REGION Code to handle game closing goes here:
   
   'summary: This method is called when the application's 'close' button is pressed.
   Method OnClose()
      Super.OnClose()
   End

   'summary:This method is called when the application's 'back' button is pressed.
   Method OnBack()
      Super.OnBack()
   End
   
   '#END REGION

End



Danke !

Gruß
Dottakopf
Rechtschreibfehler gelten der allgemeinen Belustigung!

Jolinah

BeitragFr, Apr 03, 2015 15:45
Antworten mit Zitat
Benutzer-Profile anzeigen
Hallo Dottakopf,

wäre sowas nicht einfacher?

Nur Pseudocode:
Code: [AUSKLAPPEN]
MDown = MouseDown()

If pressed = 0 And MDown = 1 Then
    pressed = 1
    SetColor 0, 255, 0
ElseIf pressed = 1 And MDown = 0 Then
    pressed = 0
    SetColor 255, 0, 0
    GameState += 1
    If GameState > 1 Then GameState = 0
EndIf

Dottakopf

BeitragSa, Apr 04, 2015 9:29
Antworten mit Zitat
Benutzer-Profile anzeigen
Very Happy ja es kann so einfach sein, vielen Dank !
Rechtschreibfehler gelten der allgemeinen Belustigung!

Neue Antwort erstellen


Übersicht Andere Programmiersprachen Beginners-Corner

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group