class FlxSpineCollider
package flixel.addons.editors.spine
extends FlxObject › FlxBasic
import flixel.addons.editors.spine.FlxSpine
@:directlyUsedConstructor
Variables
Methods
Inherited Variables
Defined by FlxObject
read onlyacceleration:FlxPoint
How fast the speed of this object is changing (in pixels per second). Useful for smooth movement and gravity.
@:value(FlxDirectionFlags.ANY)allowCollisions:FlxDirectionFlags = FlxDirectionFlags.ANY
Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating collision directions. Use bitwise operators to check the values stored here. Useful for things like one-way platforms (e.g. allowCollisions = UP;). The accessor "solid" just flips this variable between NONE and ANY.
@:value(0)angle:Float = 0
Set the angle (in degrees) of a sprite to rotate it. WARNING: rotating sprites decreases their rendering performance by a factor of ~10x when using blitting!
@:value(0)angularAcceleration:Float = 0
How fast the spin speed should change (in degrees per second).
@:value(0)angularVelocity:Float = 0
This is how fast you want this sprite to spin (in degrees per second).
@:value(IMMOVABLE)collisionXDrag:CollisionDragType = IMMOVABLE
Whether this sprite is dragged along with the horizontal movement of objects it collides with (makes sense for horizontally-moving platforms in platformers for example). Use values IMMOVABLE, ALWAYS, HEAVIER or NEVER
4.11.0
.@:value(NEVER)collisionYDrag:CollisionDragType = NEVER
Whether this sprite is dragged along with the vertical movement of objects it collides with (for sticking to vertically-moving platforms in platformers for example). Use values IMMOVABLE, ALWAYS, HEAVIER or NEVER
4.11.0
.collisonXDrag:Bool
DEPRECATED Whether this sprite is dragged along with the horizontal movement of objects it collides with (makes sense for horizontally-moving platforms in platformers for example).
Apart from having a weird typo, this has been deprecated for collisionXDrag, which allows more options.
@:value(null)debugBoundingBoxColor:Null<FlxColor> = null
Overriding this will force a specific color to be used for debug rect (ignoring any of the other debug bounding box colors specified).
@:value(FlxColor.BLUE)debugBoundingBoxColorNotSolid:FlxColor = FlxColor.BLUE
Color used for the debug rect if allowCollisions == NONE
.
4.2.0
.@:value(FlxColor.GREEN)debugBoundingBoxColorPartial:FlxColor = FlxColor.GREEN
Color used for the debug rect if this object collides partially
(immovable
in the case of FlxObject
, or allowCollisions
not equal to
ANY
or NONE
in the case of tiles in FlxTilemap
).
4.2.0
.@:value(FlxColor.RED)debugBoundingBoxColorSolid:FlxColor = FlxColor.RED
Color used for the debug rect if allowCollisions == ANY
.
4.2.0
.read onlydrag:FlxPoint
This isn't drag exactly, more like deceleration that is only applied
when acceleration
is not affecting the sprite.
@:value(0)elasticity:Float = 0
The bounciness of this object. Only affects collisions. Default value is 0, or "not bouncy at all."
@:value(1)health:Float = 1
Handy for storing health percentage or armor points or whatever.
@:isVarheight:Float
The height of this object's hitbox. For sprites, use offset
to control the hitbox position.
@:value(false)ignoreDrawDebug:Bool = false
Setting this to true
will prevent the object's bounding box from appearing
when FlxG.debugger.drawDebug
is true
.
read onlylast:FlxPoint
Important variable for collision processing.
By default this value is set automatically during at the start of update()
.
@:value(1)mass:Float = 1
The virtual mass of the object. Default value is 1. Currently only used with elasticity during collision resolution. Change at your own risk; effects seem crazy unpredictable so far!
@:value(10000)maxAngular:Float = 10000
Use in conjunction with angularAcceleration for fluid spin speed control.
read onlymaxVelocity:FlxPoint
If you are using acceleration
, you can use maxVelocity
with it
to cap the speed automatically (very useful!).
@:value(defaultMoves)moves:Bool = defaultMoves
Set this to false
if you want to skip the automatic motion/movement stuff (see updateMotion()
).
FlxObject
and FlxSprite
default to true
. FlxText
, FlxTileblock
and FlxTilemap
default to false
.
@:value(null)path:FlxPath = null
The path this object follows. Not initialized by default.
Assign a new FlxPath()
object and start()
it if you want to this object to follow a path.
Set path
to null
again to stop following the path.
See flixel.util.FlxPath
for more info and usage examples.
@:value(true)pixelPerfectPosition:Bool = true
Whether or not the position of this object should be rounded before any draw()
or collision checking.
pixelPerfectRender:Null<Bool>
Whether or not the coordinates should be rounded during rendering.
Does not affect copyPixels()
, which can only render on whole pixels.
Defaults to the camera's global pixelPerfectRender
value,
but overrides that value if not equal to null
.
read onlyscrollFactor:FlxPoint
Controls how much this object is affected by camera scrolling. 0
= no movement (e.g. a background layer),
1
= same movement speed as the foreground. Default value is (1,1)
,
except for UI elements like FlxButton
where it's (0,0)
.
solid:Bool
Whether the object collides or not. For more control over what directions the object will collide from,
use collision constants (like LEFT
, FLOOR
, etc) to set the value of allowCollisions
directly.
@:value(FlxDirectionFlags.NONE)touching:FlxDirectionFlags = FlxDirectionFlags.NONE
Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts. Use bitwise operators to check the values stored here, or use isTouching(), justTouched(), etc. You can even use them broadly as boolean values if you're feeling saucy!
@:value(FlxDirectionFlags.NONE)wasTouching:FlxDirectionFlags = FlxDirectionFlags.NONE
Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts from the previous game loop step. Use bitwise operators to check the values stored here, or use isTouching(), justTouched(), etc. You can even use them broadly as boolean values if you're feeling saucy!
Defined by FlxBasic
@:value(idEnumerator++)ID:Int = idEnumerator++
A unique ID starting from 0 and increasing by 1 for each subsequent FlxBasic
that is created.
@:value(true)alive:Bool = true
Useful state for many game objects - "dead" (!alive
) vs alive
. kill()
and
revive()
both flip this switch (along with exists
, but you can override that).
cameras:Array<FlxCamera>
This determines on which FlxCamera
s this object will be drawn. If it is null
/ has not been
set, it uses the list of default draw targets, which is controlled via FlxG.camera.setDefaultDrawTarget
as well as the DefaultDrawTarget
argument of FlxG.camera.add
.
read onlycontainer:Null<FlxContainer>
The parent containing this basic, typically if you check this recursively you should reach the state
5.7.0
.Inherited Methods
Defined by FlxObject
draw():Void
Rarely called, and in this case just increments the visible objects count and calls drawDebug()
if necessary.
drawDebugOnCamera(camera:FlxCamera):Void
Override this function to draw custom "debug mode" graphics to the
specified camera while the debugger's drawDebug
mode is toggled on.
Parameters:
Camera | Which camera to draw the debug visuals to. |
---|
getMidpoint(?point:FlxPoint):FlxPoint
getPosition(?result:FlxPoint):FlxPoint
Returns the world position of this object.
Parameters:
result | Optional arg for the returning point. |
---|
Returns:
The world position of this object.
getRotatedBounds(?newRect:FlxRect):FlxRect
Calculates the smallest globally aligned bounding box that encompasses this
object's width and height, at its current rotation.
Note, if called on a FlxSprite
, the origin is used, but scale and offset are ignored.
Use getScreenBounds
to use these properties.
Parameters:
newRect | The optional output |
---|
Returns:
A globally aligned FlxRect
that fully contains the input object's width and height.
4.11.0
.getScreenPosition(?result:FlxPoint, ?camera:FlxCamera):FlxPoint
Returns the screen position of this object.
Parameters:
result | Optional arg for the returning point |
---|---|
camera | The desired "screen" coordinate space. If |
Returns:
The screen position of this object.
hurt(damage:Float):Void
Reduces the health
variable of this object by the amount specified in Damage
.
Calls kill()
if health drops to or below zero.
Parameters:
Damage | How much health to take away (use a negative number to give a health bonus). |
---|
inlineinWorldBounds():Bool
Check and see if this object is currently within the world bounds - useful for killing objects that get too far away.
Returns:
Whether the object is within the world bounds or not.
isOnScreen(?camera:FlxCamera):Bool
Check and see if this object is currently on screen.
Parameters:
camera | Specify which game camera you want.
If |
---|
Returns:
Whether the object is on screen or not.
isPixelPerfectRender(?camera:FlxCamera):Bool
Check if object is rendered pixel perfect on a specific camera.
inlineisTouching(direction:FlxDirectionFlags):Bool
Handy function for checking if this object is touching a particular surface.
Note: These flags are set from FlxG.collide
calls, and get reset in super.update()
.
Parameters:
direction | Any of the collision flags (e.g. |
---|
Returns:
Whether the object is touching an object in (any of) the specified direction(s) this frame.
inlinejustTouched(direction:FlxDirectionFlags):Bool
Handy function for checking if this object is just landed on a particular surface.
Note: These flags are set from FlxG.collide
calls, and get reset in super.update()
.
Parameters:
direction | Any of the collision flags (e.g. |
---|
Returns:
Whether the object just landed on (any of) the specified surface(s) this frame.
@:value({ inScreenSpace : false })@:access(flixel.group.FlxTypedGroup)overlaps(objectOrGroup:FlxBasic, inScreenSpace:Bool = false, ?camera:FlxCamera):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.overlap()
.
WARNING: Currently tilemaps do NOT support screen space overlap checks!
Parameters:
objectOrGroup | The object or group being tested. |
---|---|
inScreenSpace | Whether to take scroll factors into account when checking for overlap.
Default is |
camera | Specify which game camera you want.
If |
Returns:
Whether or not the two objects overlap.
@:value({ inScreenSpace : false })@:access(flixel.group.FlxTypedGroup)overlapsAt(x:Float, y:Float, objectOrGroup:FlxBasic, inScreenSpace:Bool = false, ?camera:FlxCamera):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!
Parameters:
x | The X position you want to check. Pretends this object (the caller, not the parameter) is located here. |
---|---|
y | The Y position you want to check. Pretends this object (the caller, not the parameter) is located here. |
objectOrGroup | The object or group being tested. |
inScreenSpace | Whether to take scroll factors into account when checking for overlap.
Default is |
camera | Specify which game camera you want.
If |
Returns:
Whether or not the two objects overlap.
@:value({ inScreenSpace : false })overlapsPoint(point:FlxPoint, inScreenSpace:Bool = false, ?camera:FlxCamera):Bool
Checks to see if a point in 2D world space overlaps this FlxObject
.
Parameters:
point | The point in world space you want to check. |
---|---|
inScreenSpace | Whether to take scroll factors into account when checking for overlap. |
camera | Specify which game camera you want.
If |
Returns:
Whether or not the point overlaps this object.
reset(x:Float, y:Float):Void
Handy function for reviving game objects. Resets their existence flags and position.
Parameters:
x | The new X position of this object. |
---|---|
y | The new Y position of this object. |
@:value({ axes : XY })inlinescreenCenter(axes:FlxAxes = XY):FlxObject
@:value({ y : 0.0, x : 0.0 })setPosition(x:Float = 0.0, y:Float = 0.0):Void
Helper function to set the coordinates of this object. Handy since it only requires one line of code.
Parameters:
x | The new x position |
---|---|
y | The new y position |
Defined by FlxBasic
getCameras():Array<FlxCamera>
The cameras that will draw this. Use this.cameras
to set specific cameras for this object,
otherwise the container's cameras are used, or the container's container and so on. If there
is no container, say, if this is inside FlxGroups
rather than a FlxContainer
then the
default draw cameras are returned.
5.7.0
.kill():Void
Handy function for "killing" game objects. Use reset()
to revive them.
Default behavior is to flag them as nonexistent AND dead.
However, if you want the "corpse" to remain in the game, like to animate an effect or whatever,
you should override
this, setting only alive
to false
, and leaving exists
true
.