C# Класс flxSharp.flxSharp.FlxObject

This is the base class for most of the display objects (FlxSprite, FlxText, etc). It includes some basic attributes about game objects, including retro-style flickering, basic state information, sizes, scrolling, and basic physics and motion.
Наследование: FlxBasic
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
Acceleration FlxPoint
Drag FlxPoint
MaxVelocity FlxPoint
ScrollFactor FlxPoint
Velocity FlxPoint

Защищенные свойства (Protected)

Свойство Тип Описание
PZero FlxPoint
_flicker bool
_flickerTimer float
_pathInc int
_pathMode uint
_pathNodeIndex int
_pathRotate bool
_tagPoint FlxPoint
_tagRect FlxRect

Открытые методы

Метод Описание
FlxObject ( float x, float y, float width, float height ) : System

Instantiates a FlxObject.

destroy ( ) : void

Override this function to null out variables or manually call destroy() on class members if necessary. Don't forget to call super.destroy()!

draw ( ) : void

Rarely called, and in this case just increments the visible objects count and calls drawDebug() if necessary.

drawDebug ( FlxCamera Camera = null ) : void

#flx - Not yet implemented / missing FlxG.flashGfx for direct drawing (draw on immovable debug overlay?)

flicker ( float duration = 1.0f ) : void

Tells this object to flicker, retro-style. Pass a negative value to flicker forever.

followPath ( FlxPath path, float speed = 100, uint mode = PathForward, bool autoRotate = false ) : void

Call this function to give this object a path to follow. If the path does not have at least one node in it, this function will log a warning message and return.

getMidpoint ( FlxPoint point = null ) : FlxPoint

Retrieve the midpoint of this object in world coordinates.

getScreenXY ( FlxPoint point = null, FlxCamera camera = null ) : FlxPoint

Call this function to figure out the on-screen position of the object.

hurt ( float damage ) : void

Reduces the "health" variable of this sprite by the amount specified in Damage. Calls kill() if health drops to or below zero.

isTouching ( uint direction ) : bool

Handy function for checking if this object is touching a particular surface. For slightly better performance you can just & the value directly into touching. However, this method is good for readability and accessibility.

justTouched ( uint direction ) : bool

Handy function for checking if this object is just landed on a particular surface.

onScreen ( FlxCamera camera = null ) : bool

Check and see if this object is currently on screen.

overlaps ( FlxBasic objectOrGroup, bool inScreenSpace = false, FlxCamera camera = null ) : bool

Checks to see if some FlxObject overlaps this FlxObject or FlxGroup. If the group has a LOT of things in it, it might be faster to use FlxG.overlaps(). WARNING: Currently tilemaps do NOT support screen space overlap checks!

overlapsAt ( float x, float y, FlxBasic objectOrGroup, bool inScreenSpace = false, FlxCamera camera = null ) : bool

Checks to see if this FlxObject were located at the given position, would it overlap the FlxObject or FlxGroup? This is distinct from overlapsPoint(), which just checks that point, rather than taking the object's size into account. WARNING: Currently tilemaps do NOT support screen space overlap checks!

overlapsPoint ( FlxPoint point, bool inScreenSpace = false, FlxCamera camera = null ) : bool

Checks to see if a point in 2D world space overlaps this FlxObject object.

postUpdate ( ) : void

Post-update is called right after update() on each object in the game loop. In FlxObject this function handles integrating the objects motion based on the velocity and acceleration settings, and tracking/clearing the touching flags.

preUpdate ( ) : void

Pre-update is called right before update() on each object in the game loop. In FlxObject it controls the flicker timer, tracking the last coordinates for collision purposes, and checking if the object is moving along a path or not.

reset ( float x, float y ) : void

Handy function for reviving game objects. Resets their existence flags and position.

separate ( FlxObject objectOne, FlxObject objectTwo ) : bool

The main collision resolution function in flixel.

separateX ( FlxObject objectOne, FlxObject objectTwo ) : bool

The X-axis component of the object separation process.

separateY ( FlxObject objectOne, FlxObject objectTwo ) : bool

The Y-axis component of the object separation process.

stopFollowingPath ( bool destroyPath = false ) : void

Tells this object to stop following the path its on.

update ( ) : void

flx# - ? method not present in flixel

Защищенные методы

Метод Описание
advancePath ( bool snap = true ) : FlxPoint

Internal function that decides what node in the path to aim for next based on the behavior flags.

updateMotion ( ) : void

Internal function for updating the position and speed of this object. Useful for cases when you need to update this but are buried down in too many supers. Does a slightly fancier-than-normal integration to help with higher fidelity framerate-independenct motion.

updatePathMotion ( ) : void

Internal function for moving the object along the path. Generally this function is called automatically by preUpdate(). The first half of the function decides if the object can advance to the next node in the path, while the second half handles actually picking a velocity toward the next node.

Описание методов

FlxObject() публичный Метод

Instantiates a FlxObject.
public FlxObject ( float x, float y, float width, float height ) : System
x float X-coordinate of the object in space.
y float y-coordinate of the object in space.
width float Desired width of the rectangle.
height float Desired height of the rectangle.
Результат System

advancePath() защищенный Метод

Internal function that decides what node in the path to aim for next based on the behavior flags.
protected advancePath ( bool snap = true ) : FlxPoint
snap bool ?
Результат FlxPoint

destroy() публичный Метод

Override this function to null out variables or manually call destroy() on class members if necessary. Don't forget to call super.destroy()!
public destroy ( ) : void
Результат void

draw() публичный Метод

Rarely called, and in this case just increments the visible objects count and calls drawDebug() if necessary.
public draw ( ) : void
Результат void

drawDebug() публичный Метод

#flx - Not yet implemented / missing FlxG.flashGfx for direct drawing (draw on immovable debug overlay?)
public drawDebug ( FlxCamera Camera = null ) : void
Camera FlxCamera Which Camera - currently only one exists
Результат void

flicker() публичный Метод

Tells this object to flicker, retro-style. Pass a negative value to flicker forever.
public flicker ( float duration = 1.0f ) : void
duration float How many seconds to flicker for.
Результат void

followPath() публичный Метод

Call this function to give this object a path to follow. If the path does not have at least one node in it, this function will log a warning message and return.
public followPath ( FlxPath path, float speed = 100, uint mode = PathForward, bool autoRotate = false ) : void
path FlxPath The FlxPath you want this object to follow.
speed float How fast to travel along the path in pixels per second.
mode uint Optional, controls the behavior of the object following the path using the path behavior constants. Can use multiple flags at once, for example PATH_YOYO|PATH_HORIZONTAL_ONLY will make an object move back and forth along the X axis of the path only.
autoRotate bool Automatically point the object toward the next node. Assumes the graphic is pointing upward. Default behavior is false, or no automatic rotation.
Результат void

getMidpoint() публичный Метод

Retrieve the midpoint of this object in world coordinates.
public getMidpoint ( FlxPoint point = null ) : FlxPoint
point FlxPoint Allows you to pass in an existing FlxPoint object if you're so inclined. Otherwise a new one is created.
Результат FlxPoint

getScreenXY() публичный Метод

Call this function to figure out the on-screen position of the object.
public getScreenXY ( FlxPoint point = null, FlxCamera camera = null ) : FlxPoint
point FlxPoint Takes a FlxPoint object and assigns the post-scrolled X and Y values of this object to it.
camera FlxCamera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
Результат FlxPoint

hurt() публичный Метод

Reduces the "health" variable of this sprite by the amount specified in Damage. Calls kill() if health drops to or below zero.
public hurt ( float damage ) : void
damage float How much health to take away (use a negative number to give a health bonus).
Результат void

isTouching() публичный Метод

Handy function for checking if this object is touching a particular surface. For slightly better performance you can just & the value directly into touching. However, this method is good for readability and accessibility.
public isTouching ( uint direction ) : bool
direction uint Any of the collision flags (e.g. LEFT, FLOOR, etc).
Результат bool

justTouched() публичный Метод

Handy function for checking if this object is just landed on a particular surface.
public justTouched ( uint direction ) : bool
direction uint Any of the collision flags (e.g. LEFT, FLOOR, etc).
Результат bool

onScreen() публичный Метод

Check and see if this object is currently on screen.
public onScreen ( FlxCamera camera = null ) : bool
camera FlxCamera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
Результат bool

overlaps() публичный Метод

Checks to see if some FlxObject overlaps this FlxObject or FlxGroup. If the group has a LOT of things in it, it might be faster to use FlxG.overlaps(). WARNING: Currently tilemaps do NOT support screen space overlap checks!
public overlaps ( FlxBasic objectOrGroup, bool inScreenSpace = false, FlxCamera camera = null ) : bool
objectOrGroup FlxBasic The object or group being tested.
inScreenSpace bool Whether to take scroll factors into account when checking for overlap. Default is false, or "only compare in world space."
camera FlxCamera Specify which game camera you want. If null getScreenXY() will just grab the first global camera. flx# - currently only one exists
Результат bool

overlapsAt() публичный Метод

Checks to see if this FlxObject were located at the given position, would it overlap the FlxObject or FlxGroup? This is distinct from overlapsPoint(), which just checks that point, rather than taking the object's size into account. WARNING: Currently tilemaps do NOT support screen space overlap checks!
public overlapsAt ( float x, float y, FlxBasic objectOrGroup, bool inScreenSpace = false, FlxCamera camera = null ) : bool
x float The X position you want to check. Pretends this object (the caller, not the parameter) is located here.
y float The Y position you want to check. Pretends this object (the caller, not the parameter) is located here.
objectOrGroup FlxBasic The object or group being tested.
inScreenSpace bool Whether to take scroll factors into account when checking for overlap. Default is false, or "only compare in world space."
camera FlxCamera Specify which game camera you want. If null getScreenXY() will just grab the first global camera. flx# - currently only one exists
Результат bool

overlapsPoint() публичный Метод

Checks to see if a point in 2D world space overlaps this FlxObject object.
public overlapsPoint ( FlxPoint point, bool inScreenSpace = false, FlxCamera camera = null ) : bool
point FlxPoint The point in world space you want to check.
inScreenSpace bool Whether to take scroll factors into account when checking for overlap.
camera FlxCamera Specify which game camera you want. If null getScreenXY() will just grab the first global camera. flx# - currently only one exists
Результат bool

postUpdate() публичный Метод

Post-update is called right after update() on each object in the game loop. In FlxObject this function handles integrating the objects motion based on the velocity and acceleration settings, and tracking/clearing the touching flags.
public postUpdate ( ) : void
Результат void

preUpdate() публичный Метод

Pre-update is called right before update() on each object in the game loop. In FlxObject it controls the flicker timer, tracking the last coordinates for collision purposes, and checking if the object is moving along a path or not.
public preUpdate ( ) : void
Результат void

reset() публичный Метод

Handy function for reviving game objects. Resets their existence flags and position.
public reset ( float x, float y ) : void
x float The new X position of this object.
y float The new Y position of this object.
Результат void

separate() публичный статический Метод

The main collision resolution function in flixel.
public static separate ( FlxObject objectOne, FlxObject objectTwo ) : bool
objectOne FlxObject Any FlxObject.
objectTwo FlxObject Any other FlxObject.
Результат bool

separateX() публичный статический Метод

The X-axis component of the object separation process.
public static separateX ( FlxObject objectOne, FlxObject objectTwo ) : bool
objectOne FlxObject Any FlxObject.
objectTwo FlxObject Any other FlxObject.
Результат bool

separateY() публичный статический Метод

The Y-axis component of the object separation process.
public static separateY ( FlxObject objectOne, FlxObject objectTwo ) : bool
objectOne FlxObject Any FlxObject.
objectTwo FlxObject Any other FlxObject.
Результат bool

stopFollowingPath() публичный Метод

Tells this object to stop following the path its on.
public stopFollowingPath ( bool destroyPath = false ) : void
destroyPath bool Tells this function whether to call destroy on the path object. Default value is false.
Результат void

update() публичный Метод

flx# - ? method not present in flixel
public update ( ) : void
Результат void

updateMotion() защищенный Метод

Internal function for updating the position and speed of this object. Useful for cases when you need to update this but are buried down in too many supers. Does a slightly fancier-than-normal integration to help with higher fidelity framerate-independenct motion.
protected updateMotion ( ) : void
Результат void

updatePathMotion() защищенный Метод

Internal function for moving the object along the path. Generally this function is called automatically by preUpdate(). The first half of the function decides if the object can advance to the next node in the path, while the second half handles actually picking a velocity toward the next node.
protected updatePathMotion ( ) : void
Результат void

Описание свойств

Acceleration публичное свойство

How fast the speed of this object is changing. Useful for smooth movement and gravity
public FlxPoint,flxSharp.flxSharp Acceleration
Результат FlxPoint

Drag публичное свойство

This is like deceleration that is only applied when acceleration is not affecting the sprite.
public FlxPoint,flxSharp.flxSharp Drag
Результат FlxPoint

MaxVelocity публичное свойство

If you are using acceleration, you can use MaxVelocity with it to cap the speed automatically (very useful!).
public FlxPoint,flxSharp.flxSharp MaxVelocity
Результат FlxPoint

PZero защищенное статическое свойство

Should always represent (0,0) - useful for different things, for avoideing unnecessary new calls
protected static FlxPoint,flxSharp.flxSharp PZero
Результат FlxPoint

ScrollFactor публичное свойство

A point that can store numbers from 0 to 1 (for X and Y independently) that governs how much this object is affected by the camera subsystem. 0 means it never moves, like a HUD element or far background graphic. 1 means it scrolls along a the same speed as the foreground layer. scrollFactor is initialized as (1,1) by default. flx# - CURRENTLY NOT IMPLEMENTED
public FlxPoint,flxSharp.flxSharp ScrollFactor
Результат FlxPoint

Velocity публичное свойство

Basic speed of this object.
public FlxPoint,flxSharp.flxSharp Velocity
Результат FlxPoint

_flicker защищенное свойство

Internal helper for Retro-styled flickering.
protected bool _flicker
Результат bool

_flickerTimer защищенное свойство

Internal helper for Retro-styled flickering.
protected float _flickerTimer
Результат float

_pathInc защищенное свойство

Internal helper for node navigation, specifically yo-yo and backwards movement.
protected int _pathInc
Результат int

_pathMode защищенное свойство

Internal tracker for path behavior flags (like looping, horizontal only, etc).
protected uint _pathMode
Результат uint

_pathNodeIndex защищенное свойство

Internal helper, tracks which node of the path this object is moving toward.
protected int _pathNodeIndex
Результат int

_pathRotate защищенное свойство

Internal flag for whether the object's angle should be adjusted to the path angle during path follow behavior.
protected bool _pathRotate
Результат bool

_tagPoint защищенное свойство

This is just a pre-allocated x-y point container to be used however you like.
protected FlxPoint,flxSharp.flxSharp _tagPoint
Результат FlxPoint

_tagRect защищенное свойство

This is just a pre-allocated rectangle container to be used however you like.
protected FlxRect _tagRect
Результат FlxRect