Ca fait un moment que je bidouille en pb, mais depuis peu, j'ai changé le mode d'affichage de mes petites applis.
Avant j'ouvrais un Canvas dans une fenetre et pour tester l'appui de touches pour activer un cheatcode par exemple, j'avais placé un eventtype dans mon code et ca marchait niquel:
Code : Tout sélectionner
Repeat
Select WaitWindowEvent(5)
Case #PB_Event_CloseWindow
End
Case #PB_Event_Gadget
If EventType() = #PB_EventType_KeyUp
If key = #PB_Shortcut_W : If CheatCode=0:CheatCode+1:EndIf : EndIf
If key = #PB_Shortcut_O : If CheatCode=2:CheatCode+1:EndIf : EndIf
If key = #PB_Shortcut_O : If CheatCode=1:CheatCode+1:EndIf : EndIf ;inverse pour vraiment appuyer sur les 2 'O'
If key = #PB_Shortcut_D : If CheatCode=3:CheatCode+1:EndIf : EndIf
If key = #PB_Shortcut_Y : If CheatCode=4:CheatCode+1:EndIf : EndIf
If CheatCode=5
CheatON=#True:CheatCode=6 ;pour refaire la MaJ de l'icone de cheat
If SoundON:PlaySound(#sndCheatActivated):EndIf
CreateSoundIconsSprites():StartDrawing(CanvasOutput(#MainCanvas)):DrawAlphaImage(ImageID(#sprSoundIcons),10,10):StopDrawing()
EndIf
EndIf
EndSelect
ForEver
Si je remplace les KeyboardPushed par KeyboardInput, l''effet est le même. Si je remplace par Keyboard Released, ca ne marche carrèment plus.
Code : Tout sélectionner
Repeat
ExamineKeyboard()
If KeyboardPushed(#PB_Key_W) : If CheatCode=0:CheatCode+1:EndIf : EndIf
If KeyboardPushed(#PB_Key_O) : If CheatCode=2:CheatCode+1:EndIf : EndIf
If KeyboardPushed(#PB_Key_O) : If CheatCode=1:CheatCode+1:EndIf : EndIf ;inverse pour vraiment appuyer sur les 2 'O'
If KeyboardPushed(#PB_Key_D) : If CheatCode=3:CheatCode+1:EndIf : EndIf
If KeyboardPushed(#PB_Key_Y) : If CheatCode=4:CheatCode+1:EndIf : EndIf
If CheatCode=5
CheatON=#True:CheatCode=6 ;pour refaire la MaJ de l'icone de cheat
If SoundON:PlaySound(#sndCheatActivated):EndIf
CreateSoundIconsSprites():StartDrawing(ScreenOutput()):DrawAlphaImage(ImageID(#sprSoundIcons),10,10):StopDrawing():FlipBuffers()
EndIf
ForEver