Package view
Class SceneryView
java.lang.Object
view.EntityView
view.SceneryView
- All Implemented Interfaces:
Configuration
The SceneryView class represents an EntityView specifically for scenery.
Scenery is defined in this context as background that can scroll laterally.
The SceneryView extends EntityView and is the visual representation assumed by SceneryModels.
Scenery can be layered by setting a layer value of the SceneryModel that contains this view..
- Since:
- 1.0
- Author:
- Krish Pillai
-
Nested Class Summary
Nested classes/interfaces inherited from interface common.Configuration
Configuration.Direction -
Field Summary
Fields inherited from interface common.Configuration
AUDIO_DIR, DEFAULT_FRAME_RATE, DRAWABLE_DIR, GAMELOGGER, setViewCallChain -
Constructor Summary
ConstructorsConstructorDescriptionSceneryView(String resource, int width, int height) Constructor that takes the resource file name, and the dimensions of the view port.SceneryView(String resource, Dimension size) Constructor that takes the resource file name, and the dimensions of the view port. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the height of the spritedoubleGetter for the height of the view port.doubleGetter for the width of the view port.intgetWidth()Returns the width of the spritevoidsetScaleFactor(float sx, float sy) Sets the x and y scale factorsvoidsetXDelta(float delta) Returns the displacement used to advance the frame for each rendering.Methods inherited from class view.EntityView
draw, drawBounds, getAnimation, getDimension, getScaleX, getScaleY, isWrappedView, setAnimation, setWrappedView
-
Constructor Details
-
SceneryView
Constructor that takes the resource file name, and the dimensions of the view port. The resource file should be located in the res.drawable package. The resource file contents will be loaded into memory.- Parameters:
resource- File located in the res.drawable packagewidth- The view port widthheight- The view port height
-
SceneryView
Constructor that takes the resource file name, and the dimensions of the view port. Resource file contents are not loaded. The object is not viewable at this point.- Parameters:
resource- Image filesize- Dimensions of the view port.
-
-
Method Details
-
getViewPortWidth
public double getViewPortWidth()Getter for the width of the view port.- Returns:
- width
-
getViewPortHeight
public double getViewPortHeight()Getter for the height of the view port.- Returns:
- height
-
getWidth
public int getWidth()Returns the width of the sprite- Specified by:
getWidthin classEntityView- Returns:
- Scaled width of the sprite
-
getHeight
public int getHeight()Returns the height of the sprite- Specified by:
getHeightin classEntityView- Returns:
- Scaled height of the sprite
-
setScaleFactor
public void setScaleFactor(float sx, float sy) Description copied from class:EntityViewSets the x and y scale factors- Overrides:
setScaleFactorin classEntityView- Parameters:
sx- Scale factor along x axissy- Scale factor along y axis
-
setXDelta
public void setXDelta(float delta) Returns the displacement used to advance the frame for each rendering.- Parameters:
delta- The amount to advance
-