UNPKG

pixi-dragonbones-runtime

Version:
418 lines (417 loc) 13.9 kB
/** * The MIT License (MIT) * * Copyright (c) 2012-2018 DragonBones team and other contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ import { IAnimatable, WorldClock, Animation } from "../animation/index.js"; import { BaseObject, DragonBones } from "../core/index.js"; import { EventObject, IEventDispatcher } from "../event/index.js"; import { ArmatureData, TextureAtlasData } from "../model/index.js"; import { Bone } from "./Bone.js"; import { Constraint } from "./Constraint.js"; import { IArmatureProxy } from "./IArmatureProxy.js"; import { Slot } from "./Slot.js"; /** * [en] Armature is the core of the skeleton animation system. * * [zh] 骨架是骨骼动画系统的核心。 * * @see ArmatureData * @see Bone * @see Slot * @see Animation * @version DragonBones 3.0 */ export declare class Armature extends BaseObject implements IAnimatable { static toString(): string; private static _onSortSlots; /** * [en] Whether to inherit the animation control of the parent armature. * True to try to have the child armature play an animation with the same name when the parent armature play the animation. * * [zh] 是否继承父骨架的动画控制。 * 如果该值为 true,当父骨架播放动画时,会尝试让子骨架播放同名动画。 * * @default true * @version DragonBones 4.5 */ stopped: boolean; inheritAnimation: boolean; /** * @private */ userData: any; /** * @internal */ _lockUpdate: boolean; private _slotsDirty; private _zOrderDirty; /** * @internal */ _zIndexDirty: boolean; /** * @internal */ _alphaDirty: boolean; private _flipX; private _flipY; /** * @internal */ _cacheFrameIndex: number; private _alpha; /** * @internal */ _globalAlpha: number; private readonly _bones; private readonly _slots; /** * @internal */ readonly _constraints: Array<Constraint>; private readonly _actions; /** * @internal */ _armatureData: ArmatureData; private _animation; private _proxy; private _display; /** * @internal */ _replaceTextureAtlasData: TextureAtlasData | null; private _replacedTexture; /** * @internal */ _dragonBones: DragonBones; private _clock; /** * @internal */ _parent: Slot | null; protected _onClear(): void; /** * @internal */ _sortZOrder(slotIndices: Array<number> | Int16Array | null, offset: number): void; /** * @internal */ _addBone(value: Bone): void; /** * @internal */ _addSlot(value: Slot): void; /** * @internal */ _addConstraint(value: Constraint): void; /** * @internal */ _bufferAction(action: EventObject, append: boolean): void; /** * [en] Dispose the armature. (Return to the object pool) * * [zh] 释放骨架。 (回收到对象池) * * @example * ```ts * removeChild(armature.display); * armature.dispose(); * ``` * @version DragonBones 3.0 */ dispose(): void; /** * @internal */ init(armatureData: ArmatureData, proxy: IArmatureProxy, display: any, dragonBones: DragonBones): void; /** * @inheritDoc */ advanceTime(passedTime: number): void; /** * [en] Forces a specific bone or its owning slot to update the transform or display property in the next frame. * * [zh] 强制特定骨骼或其拥有的插槽在下一帧更新变换或显示属性。 * * @param boneName - [en] The bone name. (If not set, all bones will be update) * @param boneName - [zh] 骨骼名称。 (如果未设置,将更新所有骨骼) * * @param updateSlot - [en] Whether to update the bone's slots. (Default: false) * @param updateSlot - [zh] 是否更新骨骼的插槽。 (默认: false) * * @see Bone#invalidUpdate() * @see Slot#invalidUpdate() * @version DragonBones 3.0 */ invalidUpdate(boneName?: string | null, updateSlot?: boolean): void; /** * [en] Check whether a specific point is inside a custom bounding box in a slot. * The coordinate system of the point is the inner coordinate system of the armature. * Custom bounding boxes need to be customized in Dragonbones Pro. * * [zh] 检查特定点是否在某个插槽的自定义边界框内。 * 点的坐标系为骨架内坐标系。 * 自定义边界框需要在 DragonBones Pro 中自定义。 * * @param x - [en] The horizontal coordinate of the point. * @param x - [zh] 点的水平坐标。 * * @param y - [en] The vertical coordinate of the point. * @param y - [zh] 点的垂直坐标。 * * @version DragonBones 5.0 */ containsPoint(x: number, y: number): Slot | null; /** * [en] Check whether a specific segment intersects a custom bounding box for a slot in the armature. * The coordinate system of the segment and intersection is the inner coordinate system of the armature. * Custom bounding boxes need to be customized in Dragonbones Pro. * * [zh] 检查特定线段是否与骨架的某个插槽的自定义边界框相交。 * 线段和交点的坐标系均为骨架内坐标系。 * 自定义边界框需要在 DragonBones Pro 中自定义。 * * @param xA - [en] The horizontal coordinate of the beginning of the segment. * @param xA - [zh] 线段起点的水平坐标。 * * @param yA - [en] The vertical coordinate of the beginning of the segment. * @param yA - [zh] 线段起点的垂直坐标。 * * @param xB - [en] The horizontal coordinate of the end point of the segment. * @param xB - [zh] 线段终点的水平坐标。 * * @param yB - [en] The vertical coordinate of the end point of the segment. * @param yB - [zh] 线段终点的垂直坐标。 * * @param intersectionPointA - [en] The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) * @param intersectionPointA - [zh] 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) * * @param intersectionPointB - [en] The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) * @param intersectionPointB - [zh] 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) * * @param normalRadians - [en] The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) * @param normalRadians - [zh] 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) * * @returns [en] The slot of the first custom bounding box where the segment intersects from the start point to the end point. * @returns [zh] 线段从起点到终点相交的第一个自定义边界框的插槽。 * * @version DragonBones 5.0 */ intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { x: number; y: number; } | null, intersectionPointB?: { x: number; y: number; } | null, normalRadians?: { x: number; y: number; } | null): Slot | null; /** * [en] Get a specific bone. * * [zh] 获取特定的骨骼。 * * @param name - [en] The bone name. * @param name - [zh] 骨骼名称。 * * @see Bone * @version DragonBones 3.0 */ getBone(name: string): Bone | null; /** * [en] Get a specific bone by the display. * * [zh] 通过显示对象获取特定的骨骼。 * * @param display - [en] The display object. * @param display - [zh] 显示对象。 * * @see Bone * @version DragonBones 3.0 */ getBoneByDisplay(display: any): Bone | null; /** * [en] Get a specific slot. * * [zh] 获取特定的插槽。 * * @param name - [en] The slot name. * @param name - [zh] 插槽名称。 * * @see Slot * @version DragonBones 3.0 */ getSlot(name: string): Slot | null; /** * [en] Get a specific slot by the display. * * [zh] 通过显示对象获取特定的插槽。 * * @param display - [en] The display object. * @param display - [zh] 显示对象。 * * @see Slot * @version DragonBones 3.0 */ getSlotByDisplay(display: any): Slot | null; /** * [en] Get all bones. * * [zh] 获取所有的骨骼。 * * @see Bone * @version DragonBones 3.0 */ getBones(): Array<Bone>; /** * [en] Get all slots. * * [zh] 获取所有的插槽。 * * @see Slot * @version DragonBones 3.0 */ getSlots(): Array<Slot>; /** * [en] Whether to flip the armature horizontally. * * [zh] 是否将骨架水平翻转。 * * @version DragonBones 5.5 */ get flipX(): boolean; set flipX(value: boolean); /** * [en] Whether to flip the armature vertically. * * [zh] 是否将骨架垂直翻转。 * * @version DragonBones 5.5 */ get flipY(): boolean; set flipY(value: boolean); /** * [en] The animation cache frame rate, which turns on the animation cache when the set value is greater than 0. * There is a certain amount of memory overhead to improve performance by caching animation data in memory. * The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate. * When the animation cache is turned on, some features will fail, such as the offset property of bone. * * [zh] 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 * 开启动画缓存后,某些功能将会失效,比如骨骼的 offset 属性等。 * * @example * ```ts * armature.cacheFrameRate = 24; * ``` * @see DragonBonesData#frameRate * @see ArmatureData#frameRate * @version DragonBones 4.5 */ get cacheFrameRate(): number; set cacheFrameRate(value: number); /** * [en] The armature name. * * [zh] 骨架名称。 * * @version DragonBones 3.0 */ get name(): string; /** * [en] The armature data. * * [zh] 骨架数据。 * * @see ArmatureData * @version DragonBones 4.5 */ get armatureData(): ArmatureData; /** * [en] The animation player. * * [zh] 动画播放器。 * * @see Animation * @version DragonBones 3.0 */ get animation(): Animation; /** * @pivate */ get proxy(): IArmatureProxy; /** * [en] The EventDispatcher instance of the armature. * * [zh] 该骨架的 EventDispatcher 实例。 * * @version DragonBones 4.5 */ get eventDispatcher(): IEventDispatcher; /** * [en] The display container. * The display of the slot is displayed as the parent. * Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type. * * [zh] 显示容器实例。 * 插槽的显示对象都会以此显示容器为父级。 * 根据渲染引擎的不同,类型会不同,通常是 DisplayObjectContainer 类型。 * * @version DragonBones 3.0 */ get display(): any; /** * @private */ get replacedTexture(): any; set replacedTexture(value: any); /** * @inheritDoc */ get clock(): WorldClock | null; set clock(value: WorldClock | null); /** * [en] Get the parent slot which the armature belongs to. * * [zh] 该骨架所属的父插槽。 * * @see Slot * @version DragonBones 4.5 */ get parent(): Slot | null; /** * [en] Deprecated, please refer to {@link #display}. * * [zh] 已废弃,请参考 {@link #display}。 * * @deprecated */ getDisplay(): any; }