Skip to main content

FlixelPositional

View source

interface

org.flixelgdx.functional.FlixelPositional

public interface FlixelPositional extends FlixelAngleable

Spatial and kinematic surface shared by FlixelObject: world position, size, scroll factors, velocity-based motion, and immovable toggling so motion tweens never need to cast to FlixelObject.

See Also: FlixelObject

Methods

getScrollX()

public float getScrollX()

Parallax scroll factor on X (1 means the object moves with the camera like a normal world object).

Returns: Current scroll X factor.


getScrollY()

public float getScrollY()

Parallax scroll factor on Y (1 means the object moves with the camera like a normal world object).

Returns: Current scroll Y factor.


setScrollFactor(float, float)

public void setScrollFactor(float scrollX, float scrollY)

Sets FlixelPositional.getScrollX() and FlixelPositional.getScrollY().

Parameters:

NameDescription
scrollXHorizontal scroll factor.
scrollYVertical scroll factor.

getX()

public float getX()

X position of the upper left corner of this object in world space.

Returns: Current X in world units.


setX(float)

public void setX(float x)

Sets world X.

Parameters:

NameDescription
xNew X position.

getY()

public float getY()

Y position of the upper left corner of this object in world space.

Returns: Current Y in world units.


setY(float)

public void setY(float y)

Sets world Y.

Parameters:

NameDescription
yNew Y position.

getWidth()

public float getWidth()

Width of this object's hitbox.

Returns: Hitbox width.


setWidth(float)

public void setWidth(float width)

Sets hitbox width.

Parameters:

NameDescription
widthNew width.

getHeight()

public float getHeight()

Height of this object's hitbox.

Returns: Hitbox height.


setHeight(float)

public void setHeight(float height)

Sets hitbox height.

Parameters:

NameDescription
heightNew height.

getLastX()

public float getLastX()

X position at the start of the current frame, before motion.

Returns: Last frame's starting X.


getLastY()

public float getLastY()

Y position at the start of the current frame, before motion.

Returns: Last frame's starting Y.


setPosition(float, float)

public default void setPosition(float x, float y)

Helper that sets both world coordinates.

Parameters:

NameDescription
xThe new X position.
yThe new Y position.

setSize(float, float)

public void setSize(float width, float height)

Shortcut for setting both FlixelPositional.getWidth() and FlixelPositional.getHeight().

Parameters:

NameDescription
widthThe new width.
heightThe new height.

changeX(float)

public void changeX(float dx)

Adds dx to the current X position.


changeY(float)

public void changeY(float dy)

Adds dy to the current Y position.


getMidpointX()

public float getMidpointX()

Returns the center X coordinate of this object.


getMidpointY()

public float getMidpointY()

Returns the center Y coordinate of this object.


getVelocityX()

public float getVelocityX()

Horizontal velocity in pixels per second.


setVelocityX(float)

public void setVelocityX(float velocityX)

Sets horizontal velocity in pixels per second.


getVelocityY()

public float getVelocityY()

Vertical velocity in pixels per second.


setVelocityY(float)

public void setVelocityY(float velocityY)

Sets vertical velocity in pixels per second.


setVelocity(float, float)

public void setVelocity(float vx, float vy)

Sets both velocity components.

Parameters:

NameDescription
vxHorizontal velocity.
vyVertical velocity.

getAccelerationX()

public float getAccelerationX()

Horizontal acceleration in pixels per second squared.


setAccelerationX(float)

public void setAccelerationX(float ax)

Sets horizontal acceleration in pixels per second squared.


getAccelerationY()

public float getAccelerationY()

Vertical acceleration in pixels per second squared.


setAccelerationY(float)

public void setAccelerationY(float ay)

Sets vertical acceleration in pixels per second squared.


setAcceleration(float, float)

public void setAcceleration(float ax, float ay)

Sets both acceleration components.

Parameters:

NameDescription
axHorizontal acceleration.
ayVertical acceleration.

getDragX()

public float getDragX()

Deceleration applied when FlixelPositional.getAccelerationX() is zero. Only applied when greater than 0.

Returns: Horizontal drag.


setDragX(float)

public void setDragX(float dx)

Sets horizontal drag.


getDragY()

public float getDragY()

Deceleration applied when FlixelPositional.getAccelerationY() is zero. Only applied when greater than 0.

Returns: Vertical drag.


setDragY(float)

public void setDragY(float dy)

Sets vertical drag.


setDrag(float, float)

public void setDrag(float dx, float dy)

Sets both drag components.

Parameters:

NameDescription
dxHorizontal drag.
dyVertical drag.

getMaxVelocityX()

public float getMaxVelocityX()

Maximum absolute horizontal velocity.


setMaxVelocityX(float)

public void setMaxVelocityX(float mvx)

Sets maximum absolute horizontal velocity.


getMaxVelocityY()

public float getMaxVelocityY()

Maximum absolute vertical velocity.


setMaxVelocityY(float)

public void setMaxVelocityY(float mvy)

Sets maximum absolute vertical velocity.


setMaxVelocity(float, float)

public void setMaxVelocity(float mvx, float mvy)

Sets both max velocity components.

Parameters:

NameDescription
mvxMaximum horizontal speed.
mvyMaximum vertical speed.

getAngularVelocity()

public float getAngularVelocity()

Rotational speed in degrees per second.


setAngularVelocity(float)

public void setAngularVelocity(float av)

Sets rotational speed in degrees per second.


getAngularAcceleration()

public float getAngularAcceleration()

Rotational acceleration in degrees per second squared.


setAngularAcceleration(float)

public void setAngularAcceleration(float aa)

Sets rotational acceleration in degrees per second squared.


getAngularDrag()

public float getAngularDrag()

Rotational drag in degrees per second squared.


setAngularDrag(float)

public void setAngularDrag(float ad)

Sets rotational drag in degrees per second squared.


getMaxAngularVelocity()

public float getMaxAngularVelocity()

Maximum angular velocity in degrees per second.


setMaxAngularVelocity(float)

public void setMaxAngularVelocity(float mav)

Sets maximum angular velocity in degrees per second.


getMoves()

public boolean getMoves()

When true, FlixelObject.updateMotion(float) runs each frame on FlixelObject.

Returns: Whether integrated motion is enabled.


setMoves(boolean)

public void setMoves(boolean moves)

Enables or disables automatic motion integration on FlixelObject.

Parameters:

NameDescription
movestrue to integrate velocity each frame.

isImmovable()

public boolean isImmovable()

When true, this object will not be moved by collision resolution. Other objects will still be pushed away from it.

Returns: Current immovable flag.


setImmovable(boolean)

public void setImmovable(boolean immovable)

Sets whether collision resolution may move this object.

Parameters:

NameDescription
immovabletrue to freeze this object during separation.