Package snap.games
Class Actor
java.lang.Object
snap.props.PropObject
snap.view.View
snap.view.ParentView
snap.games.Actor
- All Implemented Interfaces:
PropChange.DoChange
,XMLArchiver.Archivable
- Direct Known Subclasses:
BoardActor
,PenActor
This class represents a game character in a GameView.
-
Nested Class Summary
Nested classes/interfaces inherited from class snap.view.View
View.Overflow
-
Field Summary
FieldsFields inherited from class snap.view.ParentView
_children, Children_Prop, NeedsLayout_Prop
Fields inherited from class snap.view.View
_align, _border, _borderRadius, _effect, _fill, _font, _margin, _padding, _repaintRect, _showing, _spacing, _vertical, Action, Align_Prop, Border_Prop, BorderRadius_Prop, Cursor_Prop, 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, Overflow_Prop, Padding_Prop, Paintable_Prop, Parent_Prop, Pickable_Prop, PrefHeight_Prop, PrefWidth_Prop, Rotate_Prop, RuntimeClassName_Prop, ScaleX_Prop, ScaleY_Prop, Scroll, Showing_Prop, Spacing_Prop, Text_Prop, TextColor_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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
act()
The act method.<T> T
getActorAtXY
(double aX, double aY, Class<T> aClass) Returns the first actor hit by given point that match given class (class can be null).<T> T
getActorInRange
(double aRadius, Class<T> aClass) Returns the first actor in given range radius that match given class (class can be null).<T> List<T>
getActorsAtXY
(double aX, double aY, Class<T> aClass) Returns the actors hit by given point that match given class (class can be null).<T> List<T>
getActorsInRange
(double aRadius, Class<T> aClass) Returns the actors in given range radius that match given class (class can be null).double
getAngleToActor
(Actor anActor) Returns the angle of the line from this actor center point to given point.double
Returns the angle of the line from this actor center point to current mouse point.double
getAngleToXY
(double aX, double aY) Returns the angle of the line from this actor center point to given point.double
getDistanceToActor
(Actor anActor) Returns the distance from this actor center point to given actor center point.double
getDistanceToXY
(double aX, double aY) Returns the distance from this actor center point to given point.Returns the GameView.<T extends GameView>
TgetGameView
(Class<? extends GameView> aClass) Returns the GameView as given class.getImage()
Returns the image.<T> T
getIntersectingActor
(Class<T> aClass) Returns the actors intersecting this actor that match given class (class can be null).<T> List<T>
getIntersectingActors
(Class<T> aClass) Returns the actors intersecting this actor that match given class (class can be null).protected double
getPrefHeightImpl
(double aW) Pref height.protected double
getPrefWidthImpl
(double aH) Pref width.boolean
intersectsActor
(Actor anActor) Returns whether actor intersects given actor.protected boolean
isActorInRange
(Actor anActor, double aRadius, Class<?> aClass) Returns whether given actor is in range and of matching class (class can be null).boolean
Returns whether at edge.boolean
isIntersectingActor
(Class<?> aClass) Returns the actors intersecting this actor that match given class (class can be null).protected boolean
isIntersectingActor
(Actor anActor, Class<?> aClass) Returns whether given actor is intersecting and of matching class (class can be null).protected void
Layout.void
moveBy
(double aCount) Move actor forward.void
moveToXY
(double anX, double aY) Move actor to a point using setRotation and moveBy (so pen drawing works).void
scaleBy
(double aScale) Scale actor by given amount.void
Sets the image.void
setImageForName
(String imageName) Sets the image for given name.void
turnBy
(double theDegrees) Turn actor by given degrees.void
turnToActor
(Actor anActor) Turn actor to given point X/Y.void
turnToXY
(double aX, double aY) Turn actor to given point X/Y.Methods inherited from class snap.view.ParentView
addChild, addChild, addDeepChangeListener, childDidDeepChange, childDidPropChange, fromXML, fromXMLChildren, fromXMLView, getChild, getChildAtXY, getChildCount, getChildCountManaged, getChildForClass, getChildForName, getChildren, getChildrenArray, getChildrenForClass, getChildrenInPaintOrder, getChildrenManaged, getFocusNext, getFocusPrev, getLastChild, getPropValue, getViewProxy, indexOfChild, initProps, intersectsShape, isInLayout, isNeedsLayout, isNeedsLayoutDeep, isNeedsRepaintDeep, layout, layoutDeep, layoutDeepImpl, layoutFloatingViews, paintAll, paintChildren, parentFontChanged, processPropChange, relayout, removeChild, removeChild, removeChildren, removeDeepChangeListener, setChildren, setFont, setNeedsLayout, setNeedsLayoutDeep, setNeedsRepaintDeep, setOwner, setOwnerChildren, setPropValue, setShowing, themeChanged, toXML, toXMLChildren, toXMLView
Methods inherited from class snap.view.View
addEventFilter, addEventHandler, clone, contains, contains, containsShape, createActionEvent, disableEvents, enableEvents, fireActionEvent, getAlign, getAlignX, getAlignY, getAnim, getAnimCleared, getAnimTimeDeep, getBestHeight, getBestSize, getBestWidth, getBorder, getBorderRadius, getBounds, getBoundsLocal, getBoundsParent, getBoundsShape, getBoundsShapeParent, getClip, getClipAll, getClipBounds, getClipBoundsAll, getCursor, getDefaultFont, getEffect, getEnv, getEventAdapter, getFill, getFillColor, getFocusNext, getFocusPrev, getFont, getHeight, getHost, getInsetsAll, getLean, getLeanX, getLeanY, getLocalToParent, getLocalToParent, getMargin, getMaxHeight, getMaxSize, getMaxWidth, getMaxX, getMaxY, getMidX, getMidXY, getMidY, getMinHeight, getMinHeightImpl, getMinSize, getMinWidth, getMinWidthImpl, getName, getOpacity, getOpacityAll, getOverflow, getOwner, getOwner, getPadding, getParent, getParent, getParentCount, getParentToLocal, getParentToLocal, getPhysics, getPhysics, getPrefHeight, getPrefHeight, getPrefSize, getPrefWidth, getPrefWidth, getProp, getPropDefault, getProps, getRepaintRect, getRepaintRectExpanded, getRootView, getRotate, getRuntimeClassName, getScale, getScaleX, getScaleY, getSize, getSpacing, getText, getTextColor, getToolTip, getToolTip, getTransX, getTransY, getUpdater, getValuePropName, getVisibleBounds, getWidth, getWindow, getX, getXY, getY, indexInHost, indexInParent, initStyleProps, isActionable, isAncestor, isAnimActive, isClipToBounds, isDisabled, isEnabled, isFocusable, isFocused, isFocusKeysEnabled, isFocusPainted, isFocusWhenPressed, isFontSet, isGrowHeight, isGrowWidth, isGuest, isHorizontal, isLocalToParentSimple, isManaged, isManagedVisible, isMaxHeightSet, isMaxWidthSet, isMinHeightSet, isMinWidthSet, isMouseDown, isMouseOver, isNeedsRepaint, isPaintable, isPickable, isPickableVisible, isPrefHeightSet, isPrefWidthSet, isPropDefault, isShowing, isToolTipEnabled, isVertical, isVisible, localToParent, localToParent, localToParent, localToParent, localToScreen, paintAbove, paintBack, paintFront, parentToLocal, parentToLocal, parentToLocal, parentToLocal, playAnimDeep, processEvent, processEventAll, processEventFilters, processEventHandlers, relayoutParent, removeEventFilter, removeEventHandler, repaint, repaint, repaint, repaintInParent, requestFocus, runDelayed, runIntervals, runLater, scrollToVisible, setActionable, setAlign, setAlignX, setAlignY, setAnimString, setAnimTimeDeep, setBorder, setBorder, setBorderRadius, setBounds, setBounds, setBoundsLocal, setClipToBounds, setCursor, setDisabled, setEffect, setEnabled, setFill, setFocusable, setFocused, setFocusKeysEnabled, setFocusPainted, setFocusWhenPressed, setGrowHeight, setGrowWidth, setHeight, setLean, setLeanX, setLeanY, setManaged, setMargin, setMargin, setMaxHeight, setMaxSize, setMaxSize, setMaxWidth, setMidXY, setMinHeight, setMinSize, setMinSize, setMinWidth, setName, setOpacity, setOverflow, setPadding, setPadding, setPaintable, setParent, setPickable, setPrefHeight, setPrefSize, setPrefSize, setPrefWidth, setProp, setRotate, setRuntimeClassName, setScale, setScaleX, setScaleY, setSize, setSize, setSizeLocal, setSizeToBestSize, setSizeToPrefSize, setSpacing, setText, setTextColor, setToolTip, setToolTipEnabled, setTransX, setTransY, setVertical, setVisible, setWidth, setX, setXY, setXYLocal, setY, stopAnimDeep, stopIntervals, toStringProps
Methods inherited from class snap.props.PropObject
addPropChangeListener, addPropChangeListener, batchPropChange, batchPropChange, batchPropChanges, fireBatchPropChanges, firePropChange, firePropChange, firePropChange, getPropForName, getPropParent, getPropSet, getPropsForArchival, getPropsForArchivalExtra, getPropsString, processArchivedNode, processUnarchivedNode, removePropChangeListener, removePropChangeListener, setPropsString, setPropValues, toString
-
Field Details
-
Image_Prop
- See Also:
-
-
Constructor Details
-
Actor
public Actor()Constructor.
-
-
Method Details
-
getGameView
Returns the GameView. -
getGameView
Returns the GameView as given class. -
getImage
Returns the image. -
setImage
Sets the image. -
setImageForName
Sets the image for given name. -
moveBy
public void moveBy(double aCount) Move actor forward. -
moveToXY
public void moveToXY(double anX, double aY) Move actor to a point using setRotation and moveBy (so pen drawing works). -
turnBy
public void turnBy(double theDegrees) Turn actor by given degrees. -
turnToXY
public void turnToXY(double aX, double aY) Turn actor to given point X/Y. -
turnToActor
Turn actor to given point X/Y. -
scaleBy
public void scaleBy(double aScale) Scale actor by given amount. -
isIntersectingActor
Returns the actors intersecting this actor that match given class (class can be null). -
getIntersectingActor
Returns the actors intersecting this actor that match given class (class can be null). -
getIntersectingActors
Returns the actors intersecting this actor that match given class (class can be null). -
isIntersectingActor
Returns whether given actor is intersecting and of matching class (class can be null). -
getActorInRange
Returns the first actor in given range radius that match given class (class can be null). -
getActorsInRange
Returns the actors in given range radius that match given class (class can be null). -
isActorInRange
Returns whether given actor is in range and of matching class (class can be null). -
getActorAtXY
Returns the first actor hit by given point that match given class (class can be null). -
getActorsAtXY
Returns the actors hit by given point that match given class (class can be null). -
getAngleToXY
public double getAngleToXY(double aX, double aY) Returns the angle of the line from this actor center point to given point. -
getAngleToActor
Returns the angle of the line from this actor center point to given point. -
getAngleToMouse
public double getAngleToMouse()Returns the angle of the line from this actor center point to current mouse point. -
getDistanceToXY
public double getDistanceToXY(double aX, double aY) Returns the distance from this actor center point to given point. -
getDistanceToActor
Returns the distance from this actor center point to given actor center point. -
intersectsActor
Returns whether actor intersects given actor. -
isAtGameViewEdge
public boolean isAtGameViewEdge()Returns whether at edge. -
act
protected void act()The act method. -
layoutImpl
protected void layoutImpl()Layout.- Overrides:
layoutImpl
in classParentView
-
getPrefWidthImpl
protected double getPrefWidthImpl(double aH) Pref width.- Overrides:
getPrefWidthImpl
in classView
-
getPrefHeightImpl
protected double getPrefHeightImpl(double aW) Pref height.- Overrides:
getPrefHeightImpl
in classView
-