Package snap.viewx
Class GameView
java.lang.Object
snap.props.PropObject
snap.view.View
snap.view.ParentView
snap.view.ChildView
snap.viewx.GameView
- All Implemented Interfaces:
PropChange.DoChange
,XMLArchiver.Archivable
,ViewHost
This class is the main view for games and manages GameActors.
-
Field Summary
Fields inherited from class snap.view.ParentView
_children, Child_Prop, NeedsLayout_Prop
Fields inherited from class snap.view.View
_align, _borderRadius, _effect, _font, _margin, _padding, _repaintRect, _showing, _spacing, _vertical, Action, Align_Prop, Border_Prop, BorderRadius_Prop, Clip_Prop, Cursor_Prop, DEFAULT_ALIGN, DEFAULT_MARGIN, DEFAULT_PADDING, DEFAULT_SPACING, Disabled_Prop, DragEvents, Effect_Prop, Fill_Prop, Focusable_Prop, Focused_Prop, FocusWhenPressed_Prop, Font_Prop, GrowHeight_Prop, GrowWidth_Prop, Height_Prop, KeyEvents, KeyPress, KeyRelease, KeyType, LeanX_Prop, LeanY_Prop, Managed_Prop, Margin_Prop, MaxHeight_Prop, MaxWidth_Prop, MinHeight_Prop, MinWidth_Prop, MouseDrag, MouseEnter, MouseEvents, MouseExit, MouseMove, MousePress, MouseRelease, Name_Prop, Opacity_Prop, Padding_Prop, Paintable_Prop, Parent_Prop, Pickable_Prop, PrefHeight_Prop, PrefWidth_Prop, Rotate_Prop, ScaleX_Prop, ScaleY_Prop, Scroll, Showing_Prop, Spacing_Prop, Text_Prop, ToolTip_Prop, TransX_Prop, TransY_Prop, Vertical_Prop, Visible_Prop, Width_Prop, X_Prop, Y_Prop
Fields inherited from class snap.props.PropObject
_pcs, EMPTY_OBJECT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
act()
The act method.void
addActorAtXY
(GameActor anActor, double anX, double aY) Adds a new actor to game view at given XY point.Returns the actor with given name.<T extends GameActor>
TgetActorAt
(double aX, double aY, Class<T> aClass) Returns the child actor intersecting given point in local coords.getActorsAt
(double aX, double aY, Class<T> aClass) Returns the child actor intersecting given point in local coords.double
Returns the cell height.int
Returns the number of cells available on Y axis.int
Returns the number of cells available on X axis.double
Returns the cell width.int
Returns the frame delay in milliseconds.double
Returns the frame rate.int
Returns the mouse button.int
Returns the mouse click count.double
Returns the mouse X.double
Returns the mouse Y.boolean
Returns whether to draw coordinate grid.double
Returns the x value of given named actor (or "Mouse").double
Returns the y value of given named actor (or "Mouse").boolean
Returns whether game autostarts.boolean
isKeyClicked
(String aKey) Returns whether a given key was pressed in the current frame.boolean
Returns whether a given key is pressed.boolean
Returns whether the mouse was clicked on this frame.boolean
Returns whether the mouse button is down.boolean
Returns whether game is playing.protected void
paintFront
(Painter aPntr) Paints the canvas.protected void
processEvent
(ViewEvent anEvent) Process event.removeActor
(int anIndex) Removes an actor.int
removeActor
(GameActor anActor) Removes an actor.void
setAutoStart
(boolean aValue) Sets whether game autostarts.void
Sets the color by text.void
setFrameRate
(double aValue) Sets the frame rate.void
setShowCoords
(boolean aValue) Sets whether to draw coordinate grid.protected void
setShowing
(boolean aValue) Override to start/stop animation.void
start()
Starts the animation.void
stop()
Stops the animation.Methods inherited from class snap.view.ChildView
addChild, addChild, addGuest, getGuest, getGuestCount, removeChild, removeChild, removeChildren, removeGuest, setChildren
Methods inherited from class snap.view.ParentView
addDeepChangeListener, childDidDeepChange, childDidPropChange, fromXML, fromXMLChildren, fromXMLView, getChild, getChildAt, getChildAt, getChildCount, getChildCountManaged, getChildForClass, getChildForName, getChildLast, getChildren, getChildrenForClass, getChildrenInPaintOrder, getChildrenManaged, getFocusNext, getFocusPrev, getPropValue, getViewList, getViewProxy, indexOfChild, initProps, intersectsShape, isInLayout, isNeedsLayout, isNeedsLayoutDeep, isNeedsRepaintDeep, layout, layoutDeep, layoutDeepImpl, layoutFloatingViews, layoutImpl, paintAbove, paintAll, paintChildren, parentFontChanged, processPropChange, relayout, removeDeepChangeListener, setFont, setNeedsLayout, setNeedsLayoutDeep, setNeedsRepaintDeep, setOwner, setOwnerChildren, setPropValue, themeChanged, toXML, toXMLChildren, toXMLView
Methods inherited from class snap.view.View
addBinding, addEventFilter, addEventHandler, clone, contains, contains, containsShape, createActionEvent, disableEvents, enableEvents, fireActionEvent, getAlign, getAlignX, getAlignY, getAnim, getAnimCleared, getAnimTimeDeep, getBestHeight, getBestSize, getBestWidth, getBinding, getBinding, getBindingCount, getBindings, getBorder, getBorderRadius, getBounds, getBoundsLocal, getBoundsParent, getBoundsShape, getBoundsShapeParent, getClip, getClipAll, getClipAllBounds, getClipBounds, getClippedRect, getCursor, getDefaultBorder, getDefaultFill, getDefaultFont, getEffect, getEnv, getEventAdapter, getFill, getFillColor, getFocusNext, getFocusPrev, getFont, getHeight, getHost, getInsetsAll, getLean, getLeanX, getLeanY, getLocalToParent, getLocalToParent, getMargin, getMaxHeight, getMaxSize, getMaxWidth, getMaxX, getMaxY, getMidX, getMidY, getMinHeight, getMinHeightImpl, getMinSize, getMinWidth, getMinWidthImpl, getName, getOpacity, getOpacityAll, getOwner, getOwner, getPadding, getParent, getParent, getParentCount, getParentToLocal, getParentToLocal, getPhysics, getPhysics, getPrefHeight, getPrefHeight, getPrefHeightImpl, getPrefSize, getPrefWidth, getPrefWidth, getPrefWidthImpl, getProp, getPropDefault, getProps, getRealClassName, getRepaintRect, getRepaintRectExpanded, getRootView, getRotate, getScale, getScaleX, getScaleY, getSize, getSpacing, getText, getToolTip, getToolTip, getTransX, getTransY, getUpdater, getValuePropName, getVisRect, getWidth, getWindow, getX, getXY, getY, indexInHost, indexInParent, isActionable, isAncestor, isClipToBounds, isDisabled, isEnabled, isFocusable, isFocused, isFocusKeysEnabled, isFocusPainted, isFocusWhenPressed, isFontSet, isGrowHeight, isGrowWidth, isGuest, isHorizontal, isLocalToParentSimple, isManaged, isManagedVisible, isMaxHeightSet, isMaxWidthSet, isMinHeightSet, isMinWidthSet, isMouseOver, isNeedsRepaint, isPaintable, isPickable, isPickableVisible, isPrefHeightSet, isPrefWidthSet, isShowing, isToolTipEnabled, isVertical, isVisible, localToParent, localToParent, localToParent, localToParent, localToScreen, paintBack, parentToLocal, parentToLocal, parentToLocal, parentToLocal, playAnimDeep, processEventAll, processEventFilters, processEventHandlers, relayoutParent, removeBinding, removeBinding, removeEventFilter, removeEventHandler, repaint, repaint, repaint, repaintInParent, requestFocus, runDelayed, runIntervals, runLater, scrollToVisible, setActionable, setAlign, setAlignX, setAlignY, setAnimProps, setAnimString, setAnimTimeDeep, setBorder, setBorder, setBorderRadius, setBounds, setBounds, setBoundsLocal, setClip, setClipToBounds, setCursor, setDisabled, setEffect, setEnabled, setFill, setFocusable, setFocused, setFocusKeysEnabled, setFocusPainted, setFocusWhenPressed, setGrowHeight, setGrowWidth, setHeight, setLean, setLeanX, setLeanY, setManaged, setMargin, setMargin, setMaxHeight, setMaxSize, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinSize, setMinWidth, setName, setOpacity, setPadding, setPadding, setPaintable, setParent, setPickable, setPrefHeight, setPrefSize, setPrefSize, setPrefWidth, setProp, setRealClassName, setRotate, setScale, setScaleX, setScaleY, setSize, setSize, setSizeLocal, setSizeToBestSize, setSizeToPrefSize, setSpacing, setText, setToolTip, setToolTipEnabled, setTransX, setTransY, setVertical, setVisible, setWidth, setX, setXY, setXYLocal, setY, stopAnimDeep, stopIntervals, toStringProps
Methods inherited from class snap.props.PropObject
addPropChangeListener, addPropChangeListener, firePropChange, firePropChange, firePropChange, getPropForName, getPropParent, getPropSet, getPropsForArchival, getPropsForArchivalExtra, getPropsString, isPropDefault, removePropChangeListener, removePropChangeListener, setPropsString, setPropValues, toString
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface snap.view.ViewHost
addGuest, getGuests, removeGuest
-
Constructor Details
-
GameView
public GameView()Constructor.
-
-
Method Details
-
getCellsWide
public int getCellsWide()Returns the number of cells available on X axis. -
getCellsHigh
public int getCellsHigh()Returns the number of cells available on Y axis. -
getCellWidth
public double getCellWidth()Returns the cell width. -
getCellHeight
public double getCellHeight()Returns the cell height. -
addActorAtXY
Adds a new actor to game view at given XY point. -
getActor
Returns the actor with given name. -
getActorAt
Returns the child actor intersecting given point in local coords. -
getActorsAt
Returns the child actor intersecting given point in local coords. -
removeActor
Removes an actor. -
removeActor
Removes an actor. -
getFrameRate
public double getFrameRate()Returns the frame rate. -
setFrameRate
public void setFrameRate(double aValue) Sets the frame rate. -
getFrameDelay
public int getFrameDelay()Returns the frame delay in milliseconds. -
getShowCoords
public boolean getShowCoords()Returns whether to draw coordinate grid. -
setShowCoords
public void setShowCoords(boolean aValue) Sets whether to draw coordinate grid. -
setColor
Sets the color by text. -
getX
Returns the x value of given named actor (or "Mouse"). -
getY
Returns the y value of given named actor (or "Mouse"). -
isMouseDown
public boolean isMouseDown()Returns whether the mouse button is down.- Overrides:
isMouseDown
in classView
-
isMouseClicked
public boolean isMouseClicked()Returns whether the mouse was clicked on this frame. -
getMouseX
public double getMouseX()Returns the mouse X. -
getMouseY
public double getMouseY()Returns the mouse Y. -
getMouseButton
public int getMouseButton()Returns the mouse button. -
getMouseClickCount
public int getMouseClickCount()Returns the mouse click count. -
isKeyDown
Returns whether a given key is pressed. -
isKeyClicked
Returns whether a given key was pressed in the current frame. -
start
public void start()Starts the animation. -
stop
public void stop()Stops the animation. -
isPlaying
public boolean isPlaying()Returns whether game is playing. -
isAutoStart
public boolean isAutoStart()Returns whether game autostarts. -
setAutoStart
public void setAutoStart(boolean aValue) Sets whether game autostarts. -
setShowing
protected void setShowing(boolean aValue) Override to start/stop animation.- Overrides:
setShowing
in classParentView
-
processEvent
Process event.- Overrides:
processEvent
in classView
-
act
protected void act()The act method. -
paintFront
Paints the canvas.- Overrides:
paintFront
in classView
-