Classes
- AnimatedSprite
- BitmapText
- Container
- Culler
- Graphics
- GraphicsContext
- HTMLText
- Mesh
- MeshGeometry
- MeshPlane
- MeshRope
- MeshSimple
- NineSliceGeometry
- NineSlicePlane
- NineSliceSprite
- PlaneGeometry
- RenderContainer
- RopeGeometry
- ShapePath
- Sprite
- Text
- TilingSprite
Interface Definitions
-
Base destroy options.
Properties:
Name Type Description childrenboolean Destroy children recursively.
Example
// Destroy the sprite and all its children. sprite.destroy({ children: true }); -
Constructor options used for
Containerinstances.const container = new Container({ position: new Point(100, 200), scale: new Point(2, 2), rotation: Math.PI / 2, });- See:
Properties:
Name Type Description alphanumber anglenumber blendModeBLEND_MODES boundsAreaRectangle childrenContainer[] culledboolean isRenderGroupboolean parentContainer pivotPointData positionPointData renderableboolean rotationnumber scalePointData skewPointData tintColorSource visibleboolean xnumber ynumber -
A reference to a frame in an AnimatedSprite
Properties:
Name Type Description textureTexture The Texture of the frame.
timenumber The duration of the frame, in milliseconds.
-
Constructor options used for
Graphicsinstances.const graphics = new Graphics({ fillStyle: { color: 0xff0000, alpha: 0.5 }, strokeStyle: { color: 0x00ff00, width: 2 }, });- See:
Properties:
Name Type Description contextGraphicsContext The GraphicsContext to use, useful for reuse and optimisation
roundPixelsboolean Whether or not to round the x/y position.
-
Options for HTML text style, extends scene.TextStyle.
Properties:
Name Type Attributes Description cssOverridesArray<string> <optional>
CSS style(s) to add.
tagStylesRecord<string, HTMLTextStyleOptions> <optional>
Tag styles.
-
Properties:
Name Type Description geometryGEOMETRY Includes vertex positions, face indices, colors, UVs, and custom attributes within buffers, reducing the cost of passing all this data to the GPU. Can be shared between multiple Mesh objects.
roundPixelsboolean Whether or not to round the x/y position.
shaderSHADER Represents the vertex and fragment shaders that processes the geometry and runs on the GPU. Can be shared between multiple Mesh objects.
stateState The state of WebGL required to render the mesh.
textureTexture The texture that the Mesh uses. Null for non-MeshMaterial shaders
-
Constructor options used for
MeshPlaneinstances.const meshPlane = new MeshPlane({ texture: Texture.from('snake.png'), verticesX: 20, verticesY: 20, }); -
Constructor options used for
MeshRopeinstances.const meshRope = new MeshRope({ texture: Texture.from('snake.png'), points: [new Point(0, 0), new Point(100, 0)], textureScale: 0, });- See:
Properties:
Name Type Description pointsPointLike[] An array of points that determine the rope.
textureTexture The texture to use on the rope.
textureScalenumber Rope texture scale, if zero then the rope texture is stretched. Positive values scale rope texture keeping its aspect ratio. You can reduce alpha channel artifacts by providing a larger texture and downsampling here. If set to zero, texture will be stretched instead.
-
Constructor options used for
NineSliceSpriteinstances.const nineSliceSprite = new NineSliceSprite({ texture: Texture.from('button.png'), leftWidth: 20, topHeight: 20, rightWidth: 20, bottomHeight: 20, });- See:
Properties:
Name Type Description bottomHeightnumber Height of the bottom horizontal bar (D)
heightnumber Height of the NineSlicePlane, setting this will actually modify the vertices and not UV's of this plane.
leftWidthnumber Width of the left vertical bar (A)
rightWidthnumber Width of the right vertical bar (B)
roundPixelsboolean Whether or not to round the x/y position.
textureTexture The texture to use on the NineSlicePlane.
topHeightnumber Height of the top horizontal bar (C)
widthnumber Width of the NineSlicePlane, setting this will actually modify the vertices and not the UV's of this plane.
-
Constructor options used for
PlaneGeometryinstances.const planeGeometry = new PlaneGeometry({ width: 100, height: 100, verticesX: 10, verticesY: 10, });- See:
Properties:
Name Type Description heightnumber Height of plane
verticesXnumber Number of vertices on x-axis
verticesYnumber Number of vertices on y-axis
widthnumber Width of plane
-
Options for the RenderContainer constructor.
Properties:
Name Type Description addBounds(bounds: BoundsData) => void how to add the bounds of this object when measuring
containsPoint(point: Point) => boolean how to know if the custom render logic contains a point or not, used for interaction
renderRenderFunction the custom render function
-
Constructor options used for
RopeGeometryinstances.const ropeGeometry = new RopeGeometry({ points: [new Point(0, 0), new Point(100, 0)], width: 10, textureScale: 0, });- See:
Properties:
Name Type Description pointsPointLike[] An array of points that determine the rope.
textureScalenumber Rope texture scale, if zero then the rope texture is stretched. By default the rope texture will be stretched to match rope length. If textureScale is positive this value will be treated as a scaling factor and the texture will preserve its aspect ratio instead. To create a tiling rope set baseTexture.wrapMode to 'repeat' and use a power of two texture, then set textureScale=1 to keep the original texture pixel size. In order to reduce alpha channel artifacts provide a larger texture and downsample - i.e. set textureScale=0.5 to scale it down twice.
widthnumber The width (i.e., thickness) of the rope.
-
Options for the Sprite constructor.
-
Options for the Text class.
Properties:
Name Type Description anchorPointData The anchor point of the text.
renderMode"canvas" | "html" | "bitmap" the render mode -
canvasrenders to a single canvas,htmlrenders using css,bitmapuses a bitmap fontresolutionnumber The resolution of the text.
roundPixelsboolean Whether or not to round the x/y position.
styleTextStyle | HTMLTextStyleOptions | HTMLTextStyle The text style
textTextString The copy for the text object. To split a line you can use '\n'.
Example
const text = new Text({ text: 'Hello Pixi!', style: { fontFamily: 'Arial', fontSize: 24, fill: 0xff1010, align: 'center', } }); -
Constructor options used for
TextStyleinstances.const textStyle = new TextStyle({ fontSize: 12, fill: 'black', });- See:
-
- scene.TextStyle
Properties:
Name Type Description align'left' | 'center' | 'right' | 'justify' Alignment for multiline text, does not affect single line text
breakWordsboolean Indicates if lines can be wrapped within words, it needs
wordWrapto be set totruedropShadowboolean | Partial<TextDropShadow> Set a drop shadow for the text
fillstring | Array<string> | number | Array<number> | CanvasGradient | CanvasPattern A canvas fillstyle that will be used on the text e.g., 'red', '#00FF00'. Can be an array to create a gradient, e.g.,
['#000000','#FFFFFF']MDNfontFamilystring | string[] The font family, can be a single font name, or a list of names where the first is the preferred font.
fontSizenumber | string The font size (as a number it converts to px, but as a string, equivalents are '26px','20pt','160%' or '1.6em')
fontStyle'normal' | 'italic' | 'oblique' The font style.
fontVariant'normal' | 'small-caps' The font variant.
fontWeight'normal' | 'bold' | 'bolder' | 'lighter' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' The font weight.
leadingnumber The height of the line, a number that represents the vertical space that a letter uses.
letterSpacingnumber The amount of spacing between letters, default is 0
lineHeightnumber The line height, a number that represents the vertical space that a letter uses
paddingnumber Occasionally some fonts are cropped. Adding some padding will prevent this from happening by adding padding to all sides of the text.
strokeFillStyleInputs A canvas fillstyle that will be used on the text stroke, e.g., 'blue', '#FCFF00'
textBaseline'alphabetic' | 'top' | 'hanging' | 'middle' | 'ideographic' | 'bottom' The baseline of the text that is rendered.
whiteSpace'normal' | 'pre' | 'pre-line' Determines whether newlines & spaces are collapsed or preserved "normal" (collapse, collapse), "pre" (preserve, preserve) | "pre-line" (preserve, collapse). It needs wordWrap to be set to true.
wordWrapboolean Indicates if word wrap should be used
wordWrapWidthnumber The width at which text will wrap, it needs wordWrap to be set to true
-
Options when destroying textures. Most of these use cases are internal.
// destroy the graphics context and its texture graphicsContext.destroy({ texture: true });Properties:
Name Type Description textureboolean Destroy the texture as well.
textureSourceboolean Destroy the texture source as well.
-
Constructor options used for
TilingSpriteinstances. Extends scene.TilingSpriteViewOptionsconst tilingSprite = new TilingSprite({ texture: Texture.from('assets/image.png'), width: 100, height: 100, tilePosition: { x: 100, y: 100 }, tileScale: { x: 2, y: 2 }, });- See:
-
- TilingSprite
- scene.TilingSpriteViewOptions
Properties:
Name Type Default Description anchorPointData {x: 0, y: 0}The anchor point of the sprite
applyAnchorToTextureboolean falseheightnumber 256The height of the tiling sprite.
roundPixelsboolean Whether or not to round the x/y position.
textureTexture Texture.WHITEThe texture to use for the sprite.
tilePositionPointData {x: 0, y: 0}The offset of the image that is being tiled.
tileRotationnumber 0The rotation of the image that is being tiled.
tileScalePointData {x: 1, y: 1}Scaling of the image that is being tiled.
widthnumber 256The width of the tiling sprite. #
Type Definitions
A drop shadow effect.
Properties:
| Name | Type | Description |
|---|---|---|
alpha |
number |
Set alpha for the drop shadow |
angle |
number |
Set a angle of the drop shadow |
blur |
number |
Set a shadow blur radius |
color |
ColorSource |
A fill style to be used on the e.g., 'red', '#00FF00' |
distance |
number |
Set a distance of the drop shadow |