MoverSkeleton

MoverSkeleton

A Class ready to utilize MoverPoints as velocity and thereby move.


Constructor

new MoverSkeleton(x, y, width, height)

Parameters:
Name Type Description
x Number

The x position of the MoverSkeleton

y Number

The y position of the MoverSkeleton

width Number

The width of the MoverSkeleton

height Number

The height of the MoverSkeleton

Members

_lastPos

The last position MoverPoint that the MoverSkeleton had. The update method sets this value.

_lastVeloc

The last velocity MoverPoint that the MoverSkeleton had. The update method sets this value.

_middlePoint

The middle MoverPoint of the MoverSkeleton, updated and referenced via the getMiddle method.

_pos

The position MoverPoint for the MoverSkeleton

_rect

The Rectangle bounds of the MoverSkeleton, it is created during construction of the MoverSkeleton, and is updated and referenced via the getRectangle method.

_veloc

The velocity MoverPoint for the MoverSkeleton

constructor

dX

The x direction of the MoverSkeleton, 1,-1, or 0. This value is updated during setX calls.

dY

The y direction of the MoverSkeleton, this value is updated during setY calls.

height

The height of the MoverSkeleton

mass

To be the mass of the MoverSkeleton, this "Skeleton" class does not really do anything with this variable.

maxSpeed

To be the max speed of the MoverSkeleton, this "Skeleton" class does not really do anything with this variable.

width

The width of the MoverSkeleton

x

The x location of the MoverSkeleton.

y

The y location of the MoverSkeleton.

Methods

getHeight() → {Number}

Returns the height of the MoverSkeleton

Returns:
Type
Number

getHorizontalDirection() → {Number}

Returns the horizontal direction of the MoverSkeleton, 1, -1, 0, if setX is being used.

Returns:
Type
Number

getMiddle() → {MoverPoint}

Returns the middle MoverPoint (_middlePoint) based on x/y width/height.

Returns:
Type
MoverPoint

getPosition() → {MoverPoint}

Returns the position MoverPoint of the MoverSkeleton

Returns:
Type
MoverPoint

getRectangle(wOffset, hOffset) → {Rectangle}

Returns the Rectangle bounds of the MoverSkeleton.

Parameters:
Name Type Description
wOffset
hOffset
Returns:
Type
Rectangle

getVelocity() → {MoverPoint}

Returns the velocity MoverPoint of this MoverSkeleton

Returns:
Type
MoverPoint

getVerticalDirection() → {Number}

Returns the vertical direction of the MoverSkeleton, 1,-1, or 0, if setY are being used.

Returns:
Type
Number

getWidth() → {Number}

Returns the width of the MoverSkeleton

Returns:
Type
Number

getX() → {Number}

Returns the x position of the MoverSkeleton

Returns:
Type
Number

getY() → {Number}

Returns the y position of the MoverSkeleton

Returns:
Type
Number

setPosition(toThis)

Sets the position MoverPoint to the one given. Also updates x and y to the x and y of the MoverPoint given.

Parameters:
Name Type Description
toThis MoverPoint

The MoverPoint to set the position to.

setVelocity(toThis)

Sets the velocity MoverPoint of this MoverSkeleton to the one given.

Parameters:
Name Type Description
toThis MoverPoint

The MoverPoint to set velocity to

setX(toThis, notDX)

Sets the x position of the MoverSkeleton, also updating .dX and _pos.x

These methods setX, setY, are used in the update method of MapMovers, and so MapMovers auto update dX and dY, but only MapMovers do such. In all other cases you would have to use setX and setY yourself if you wanted dX and dY to update, or you could update dX and dY yourself. In MapTravelers you have _lastPos and _lastVeloc that get updated which can be used to do the same things dX and dY would be used for.

Parameters:
Name Type Description
toThis Number

The Number to set x to.

notDX Boolean

If true will not set dX. The default behavior is to set .dX to 1,-1, or 0 based on what is given.

setY(toThis, notDY)

Sets the y value of the MoverSkeleton, and also updates _pos.y and .dY

Parameters:
Name Type Description
toThis Number

The number to set y to.

notDY Boolean

If true will not set direction y; this.dY. The default behavior is to update this.dY to 1,-1, or 0 when this method is used.

update()

This method matches _lastPos to _pos, and _lastVeloc to _veloc If _veloc/_pos are changed after this method is called, _lastVeloc/_lastPos therefore would hold the previous values.

 Classes that extend MoverSkeleton override this method adding in more functionality.