Package pi.event
Interface KeyStrokeListenerRegistration
- All Known Implementing Classes:
Actor,ActorRotationDemo,ActorSetFixtureFromStringDemo,AllDialogsDemo,Animation,AnimationDemo,ApplyForceDemo,ApplyImpulseDemo,ApplyRotationImpulseDemo,ApplyTorqueDemo,Ball,Ball,BallThrowDemo,BaseScene,BaseScene,BasketballThrowDemo,BillardDemo,Blinky,BlockDebugScene,BounceBar,Box,CameraDemo,CameraDemo,CarDemo,Circle,Circle,CircleDemo,Clyde,Coin,CollisionTest,ColorContainerVisualizerDemo,ColorDemo,ColorVariationsDemo,ColorWheelIttenDemo,CopyrightScene,Counter,DensityDemo,DepthFirstSearchDemo,DistanceJointDemo,DudeDemo,Edge,ForceKlickEnvironment,FrameUpdateListenerDemo,FrictionDemo,FroggyJump,Geometry,GetMousePositionDemo,Ghost,GhostsDebugScene,GraphCollectionDemo,GraphDrawerDemo,GravityDemo,Grid,Grid,GridDebugScene,GridDemo,GroupDemo,HelloWorldVersion1,HelloWorldVersion2,Hole,HUD,Image,Image,ImageAverageColorDemo,ImageDemo,ImageFontSpecimenDemo,ImageFontText,ImageFontTextAlignmentDemo,ImageFontTextColorDemo,ImageFontTextDemo,ImageFontTextMultilineDemo,ImageFontTextSetContentDemo,ImageRobot,ImpulseDemo,IngameScene,IngameScene,Inky,InstantModeDisabled,InstantModeDisabledByStaticBlock,InstructionScene,ItemMapPainterTest,JointDemo,JukeboxDemo,JukeboxTetrisDemo,KeyEventDemo,KeyEventDisplayDemo,KeyStrokeCounterDemo,KeyStrokeListenerAsAnonymousClassDemo,KeyStrokeListenerAsLambdaDemo,KeyStrokeListenerAsNormalClassDemo,LabeledEdge,LabeledNode,Layer,LayerDemo,LevelsScene,Line,LineDemo,LineRandomDemo,ListenerOnActorsDemo,LogoDemo,MainMenuScene,MainScene,ManaPickup,MarbleDemo,MinimalDemo,OverlayDemo,Paddle,PaintingCirclesAdvancedDemo,PaintingCirclesDemo,PaintingSurfaceDemo,PaintingSurfaceScene,ParticlesDemo,PauseLayer,PeriodicTaskExecutorDemo,Pinky,Platform,PlayerCharacter,Polygon,PongTable,PressedKeyRepeaterDemo,PrismaticJointDemo,Rectangle,Rectangle,RectangleDemo,RegularPolygon,RepeatDemo,RestitutionDemo,RevolteJointSeesawDemo,RevoluteJointDemo,RopeJointDemo,RotationDemo,Scene,SceneInfoOverlayDemo,ScreenshotDemo,SetPixelMultiplicationDemo,SingleTetrominoDebugScene,SnakeAdvanced,SnakeHead,SnakeMinimal,SnakeScene,Square,Star,StarDemo,StatefulAnimatedGifAnimation,StatefulAnimation,StatefulAnimationDemo,StatefulAnimationDemo,StatefulImagesAnimation,StatefulImagesPrefixAnimation,StatefulPlayerCharacter,StatefulSpritesheetAnimation,StaticKeyStrokeListenerDemo,SubMenuScene,TetrominoDebugScene,TetrominoWithoutGridScene,Text,Text,Text,TextAllSystemFonts,TextDebugScene,TextDemo,TileRegistration,TitleScene,Triangle,Triangle,TriangleDemo,TurtleScene,WeldJointDemo
public interface KeyStrokeListenerRegistration
Eine Schnittstelle zum An- und Abmelden von Beobachtern, die auf die
gedrückte Tasten reagieren.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidaddKeyStrokeListener(KeyStrokeListener listener) Fügt einen statischKeyStrokeListenerhinzu, d. h. dieser KeyStrokeListener gilt global über das ganze Spiel und ist unabhängig von der aktuellen Szene.default voidremoveKeyStrokeListener(KeyStrokeListener listener) Entfernt einenKeyStrokeListenervom Objekt.
-
Method Details
-
keyStrokeListeners
EventListeners<KeyStrokeListener> keyStrokeListeners() -
addKeyStrokeListener
Fügt einen statischKeyStrokeListenerhinzu, d. h. dieser KeyStrokeListener gilt global über das ganze Spiel und ist unabhängig von der aktuellen Szene.Der
KeyStrokeListenerkann auf mehrere Arten implementiert werden:- Als normale Klasse:
class MyKeyStrokelistener implements KeyStrokeListener { @Override public void onKeyDown(KeyEvent e) { // Code here } } obj.addKeyStrokeListener(new MyKeyStrokelistener()); - Als anonyme Klasse:
obj.addKeyStrokeListener(new KeyStrokeListener() { @Override public void onKeyDown(KeyEvent e) { // Code here } }); - Oder als Lambda-Ausdruck:
obj.addKeyStrokeListener(e -> { // Code here });
- Parameters:
listener- Ein Objekt der KlasseKeyStrokeListener.- See Also:
- Als normale Klasse:
-
removeKeyStrokeListener
Entfernt einenKeyStrokeListenervom Objekt.- Parameters:
listener- Ein Objekt der KlasseKeyStrokeListener.- See Also:
-