FlxNapeSpace is a flixel plugin that integrates nape.space.Space to provide Nape physics simulation in Flixel.

Static variables

staticdrawDebug:Bool

Whether or not the nape debug graphics are enabled.

@:value(10)staticpositionIterations:Int = 10

The number of iterations used by nape in resolving errors in the positions of objects. This is far more lightweight than velocity iterations, as well as being less important for the stability of results. (default 10)

staticread onlyshapeDebug:ShapeDebug

A useful "canvas" which can be used to draw debug information on. To get a better idea of its use, see the official Nape demo 'SpatialQueries' (http://napephys.com/samples.html#swf-SpatialQueries) where this is used to draw lines emitted from Rays. A sensible place to use this would be the state's draw() method. Note that shapeDebug is null if drawDebug is false.

staticspace:Space

@:value(10)staticvelocityIterations:Int = 10

The number of iterations used by nape in resolving errors in the velocities of objects. This is together with collision detection the most expensive phase of a simulation update, as well as the most important for stable results. (default 10)

Static methods

@:value({ thickness : 10, maxY : 0, maxX : 0, minY : 0, minX : 0 })staticcreateWalls(minX:Float = 0, minY:Float = 0, maxX:Float = 0, maxY:Float = 0, thickness:Float = 10, ?material:Material):Body

Creates simple walls around the game area - useful for prototying.

Parameters:

minX

The smallest X value of your level (usually 0).

minY

The smallest Y value of your level (usually 0).

maxX

The largest X value of your level - 0 means FlxG.width (usually the level width).

maxY

The largest Y value of your level - 0 means FlxG.height (usually the level height).

thickness

How thick the walls are. 10 by default.

material

The Material to use for the physics body of the walls.

staticinit():Void

Needs to be called before creating any FlxNapeSprites / FlxNapeTilemaps to initialize the space.

Constructor

new()

Methods

@:access(flixel.FlxCamera)draw():Void

Draws debug graphics.

Inherited Variables

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)active:Bool = true

Controls whether update() is automatically called by FlxState/FlxGroup.

@: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).

camera:FlxCamera

Gets or sets the first camera of this object.

cameras:Array<FlxCamera>

This determines on which FlxCameras 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

Available since

5.7.0

.

@:value(true)exists:Bool = true

Controls whether update() and draw() are automatically called by FlxState/FlxGroup.

@:value(true)visible:Bool = true

Controls whether draw() is automatically called by FlxState/FlxGroup.

Inherited Methods

Defined by FlxBasic

destroy():Void

WARNING: A destroyed FlxBasic can't be used anymore. It may even cause crashes if it is still part of a group or state. You may want to use kill() instead if you want to disable the object temporarily only and revive() it later.

This function is usually not called manually (Flixel calls it automatically during state switches for all add()ed objects).

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

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.

Available since

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.

revive():Void

Handy function for bringing game objects "back to life". Just sets alive and exists back to true. In practice, this function is most often called by FlxObject#reset().