Package ch.epfl.cs107.play.window
Class Button
java.lang.Object
ch.epfl.cs107.play.window.Button
- All Implemented Interfaces:
Serializable
Contains the current and previous states of a button.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Button
public Button(boolean previous, boolean current, boolean isLastPressed) Creates a new button state.- Parameters:
previous- (boolean): previous statecurrent- (boolean): current stateisLastPressed- (boolean): indicate if the button is the last button pressed
-
Button
public Button(boolean previous, boolean current) Creates a new button state.- Parameters:
previous- (boolean): previous statecurrent- (boolean): current state
-
Button
public Button(boolean current) Creates a new button state.- Parameters:
current- (boolean): previous and current state
-
-
Method Details
-
isDown
public boolean isDown()- Returns:
- (boolean): whether the button is currently pressed
-
isUp
public boolean isUp()- Returns:
- (boolean): whether the button is currently released
-
wasDown
public boolean wasDown()- Returns:
- (boolean): whether the button was released, regardless of current state
-
wasUp
public boolean wasUp()- Returns:
- (boolean): whether the button was pressed, regardless of current state
-
isPressed
public boolean isPressed()- Returns:
- (boolean): whether the button was just pressed
-
isLastPressed
public boolean isLastPressed()- Returns:
- (boolean): whether the button is the last button pressed
-
isReleased
public boolean isReleased()- Returns:
- (boolean): whether the button was just released
-
updated
Creates an new state, given this state.- Parameters:
next- (boolean): the new state, used to compute new transition- Returns:
- (Button) a new button state, not null
-
hashCode
public int hashCode() -
equals
-
toString
-