gamelistener.java
来自「一个java的俄罗斯方块实现」· Java 代码 · 共 48 行
JAVA
48 行
package cs111.tetris.data;/** * This interface can be implemented by anyone who wants * to be notified when the state of a Game instance changes. * <p> * The Game class provides an <code>addListener()</code> method * to add listeners to a Game. * <p> * Typicaly a UI component implements the GameListener interface and calls * addListener to ask a Game to be notified of changes in the game * state. Thus, the GUI will know when it is necessary to update the * visual display of the game state on the screen. * <p> * <b>CS111 info:</b> Using this kind of Listener notification mechanism * is very typical for programs with a GUI. For example, you will find many different * listener interfaces also in the Java libraries. * <p> * This programming style allows us to decouple the game playing * logic and interesting data structures from the * GUI code. And so... this allows us to provide you with all * of that messy GUI related code and leave the more interesting * stuff to you! * * @author kdvolder */public interface GameListener { /** * This method is called by the game instance when the board state * changed (so the UI should redraw the board on the screen). */ public void boardChanged(); /** * This is called when the pieceCount was updated (e.g. a * new piece was entered at the top of the board). */ public void countChanged(); /** * This is called when the "gameOn" status changed. That * is, the game is either started or stopped. */ public void gameOnChanged();}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?