Class Screen
java.lang.Object
Screen
- Direct Known Subclasses:
World
Screen class - a high level class that handles background screens & millisecond timing
Has a World Subclass
-
Constructor Summary
ConstructorsConstructorDescriptionScreen
(processing.core.PApplet p, String screenName, String movingBgFile, float scale, float x, float y) Screen Constructor #2: For background images that move - Takes String (Coded as a Sprite, not a Processing background PImage)Screen Constructor #1: Stationary background imageScreen
(processing.core.PApplet p, String screenName, processing.core.PImage movingBg, float scale, float x, float y) Screen Constructor #3: For background images that move - Takes PImage (Coded as a Sprite, not a Processing background PImage) -
Method Summary
Modifier and TypeMethodDescriptionfloat
processing.core.PImage
Gets the background as a PImageboolean
Checks if the Screen's background is moveablefloat
getLeftX()
Returns the pixel value for the left edge of the background imagegetName()
Gets the name of the Screen to be used for debugginglong
float
long
getTimeSince
(long lastCheck) float
getTopY()
Returns the pixel value for the top edge of the background imagelong
void
moveBgXY
(float speedX, float speedY) Moves the background image in the X & Y directionsvoid
pause
(int milliseconds) Resets the timer for the screen.void
void
setBg
(processing.core.PImage bgImg) Sets the background image for NON-MOVEABLE backgroundsvoid
setLeftX
(float leftX) Moves the left edge of the background to a specified pixel (ie.void
Sets the name of the Screen to be used for debuggingvoid
setTopY
(float topY) Moves the top edge of the background to a specified pixel (ie.void
show()
Updates all sprites and images on the Screen Does nothing unless Overridden by World, Grid, and HexGridvoid
showBg()
Updates any movement of the background to be showntoString()
-
Constructor Details
-
Screen
Screen Constructor #1: Stationary background image- Parameters:
p
- Processing appletscreenName
- String to track ScreensbgImg
- stationary background image
-
Screen
public Screen(processing.core.PApplet p, String screenName, String movingBgFile, float scale, float x, float y) Screen Constructor #2: For background images that move - Takes String (Coded as a Sprite, not a Processing background PImage)- Parameters:
p
- Processing appletscreenName
- String to track ScreensmovingBgFile
- filename for the background image to movescale
- float that multiplies the size of the image to displayx
- sets the initial left edge of the backgroundy
- sets the intial top edge of the background
-
Screen
public Screen(processing.core.PApplet p, String screenName, processing.core.PImage movingBg, float scale, float x, float y) Screen Constructor #3: For background images that move - Takes PImage (Coded as a Sprite, not a Processing background PImage)- Parameters:
p
- Processing appletscreenName
- String to track ScreensmovingBg
- PImage for a moving backgroundscale
- float that multiplies the size of the image to displayx
- sets the initial left edge of the backgroundy
- sets the intial top edge of the background
-
-
Method Details
-
setName
Sets the name of the Screen to be used for debugging- Parameters:
screenName
- String to track Screens
-
getName
Gets the name of the Screen to be used for debugging- Returns:
- String Can be used to track the Screen
-
setBg
public void setBg(processing.core.PImage bgImg) Sets the background image for NON-MOVEABLE backgrounds- Parameters:
bgImg
- stationary background image
-
getBgImage
public processing.core.PImage getBgImage()Gets the background as a PImage- Returns:
- PImage moving OR non-moving background image
-
getIsMoveable
public boolean getIsMoveable()Checks if the Screen's background is moveable- Returns:
- boolean
true
if background is moveable,false
if stationary
-
moveBgXY
public void moveBgXY(float speedX, float speedY) Moves the background image in the X & Y directions- Parameters:
speedX
- positive moves right, negative moves leftspeedY
- positive moves down, negative moves up
-
setLeftX
public void setLeftX(float leftX) Moves the left edge of the background to a specified pixel (ie. -50.0f)- Parameters:
leftX
- pixel of left edge of moving background
-
getLeftX
public float getLeftX()Returns the pixel value for the left edge of the background image- Returns:
- float pixel of left edge of moving background
-
setTopY
public void setTopY(float topY) Moves the top edge of the background to a specified pixel (ie. -50.0f)- Parameters:
topY
- pixel of top edge of moving background
-
getTopY
public float getTopY()Returns the pixel value for the top edge of the background image- Returns:
- float pixel of top edge of moving background
-
showBg
public void showBg()Updates any movement of the background to be shown -
show
public void show()Updates all sprites and images on the Screen Does nothing unless Overridden by World, Grid, and HexGrid -
distToRightEdge
public float distToRightEdge()- Returns:
- float distance to right edge for a moveable background
-
getTotalTime
public long getTotalTime()- Returns:
- long total number of milliseconds the game has been running
-
getScreenTime
public long getScreenTime()- Returns:
- long milliseconds the Screen has been running
-
getTimeSince
public long getTimeSince(long lastCheck) - Parameters:
lastCheck
- milliseconds since last check- Returns:
- long milliseconds from a previous time
-
getScreenTimeSeconds
public float getScreenTimeSeconds()- Returns:
- float seconds the Screen has been running
-
resetTime
public void resetTime() -
pause
public void pause(int milliseconds) Resets the timer for the screen. Can be used when Screen first becomes visible- Parameters:
milliseconds
- how long to pause the app
-
toString
-