Package view.itemsAndRewards
Class ItemView
java.lang.Object
view.itemsAndRewards.ItemView
- Direct Known Subclasses:
BubbleRewardView,PowerUpView
The abstract ItemView class represents the view for a
ItemModel.
It handles drawing the item, playing audio effects, and updating the item's state.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected intprotected ItemManagerViewprotected ItemModelprotected boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidPlays the audio effects for the item.abstract voidDraws the item on the screen.protected ItemModelReturns the ItemModel associated with this view.protected BooleanisActive()Checks if the item is active.voidupdate()Updates the item's state.protected voidUpdates the animation tick for the de-spawning animation.
-
Field Details
-
itemModel
-
itemManagerView
-
animationTick
protected int animationTick -
animationIndex
protected int animationIndex -
soundPlayed
protected boolean soundPlayed
-
-
Constructor Details
-
ItemView
Constructs an ItemView with the specified ItemModel.- Parameters:
itemModel- the model of the item
-
-
Method Details
-
draw
Draws the item on the screen.- Parameters:
g- the Graphics object to draw with
-
audioEffects
public abstract void audioEffects()Plays the audio effects for the item. -
update
public void update()Updates the item's state. If the item is de-spawning, updates the animation tick. -
updateAnimationTick
protected void updateAnimationTick()Updates the animation tick for the de-spawning animation. Increments the animation tick and index. -
isActive
Checks if the item is active.- Returns:
- true if the item is active, false otherwise
-
getItemModel
Returns the ItemModel associated with this view.- Returns:
- the ItemModel
-