ArmatureDisplay 类型

继承于 RenderComponent

模块: dragonBones

DragonBones 骨骼动画

(Armature Display 具有对骨骼数据的引用并且存储了骨骼实例的状态, 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。
多个 Armature Display 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。)

索引

属性(properties)
  • dragonAsset DragonBonesAsset attachments,皮肤等等)和动画但不持有任何状态。
  • dragonAtlasAsset DragonBonesAtlasAsset 骨骼数据所需的 Atlas Texture 数据。
  • armatureName String 当前的 Armature 名称。
  • animationName String 当前播放的动画名称。
  • _defaultArmatureIndex Number
  • timeScale Number 当前骨骼中所有动画的时间缩放率。
  • playTimes Number 播放默认动画的循环次数...
  • premultipliedAlpha Boolean 是否启用贴图预乘。
  • debugBones Boolean 是否显示 bone 的 debug 信息。
  • enableBatch Boolean 开启合批,如果渲染大量相同纹理,且结构简单的骨骼动画,开启合批可以降低drawcall,否则请不要开启,cpu消耗会上升。
  • __eventTargets Array Register all related EventTargets,...
  • node Node 该组件被附加到的节点。
  • uuid String 组件的 uuid,用于编辑器。
  • _enabled Boolean
  • enabled Boolean 表示该组件自身是否启用。
  • enabledInHierarchy Boolean 表示该组件是否被启用并且所在的节点也处于激活状态。
  • _isOnLoadCalled Number 返回一个值用来判断 onLoad 是否被调用过,不等于 0 时调用过,等于 0 时未调用。
  • _name String
  • _objFlags Number
  • name String 该对象的名称。
  • isValid Boolean 表示该对象是否可用(被 destroy 后将不可用)。
方法
  • getArmatureKey 缓存龙骨数据的key值,换装的时会使用到该值,作为dragonbonesName使用
  • setAnimationCacheMode 若想切换渲染模式,最好在设置'dragonAsset'之前,先设置好渲染模式,否则有运行时开销。
  • isAnimationCached 当前是否处于缓存模式。
  • playAnimation animName 指定播放动画的名称。
  • updateAnimationCache 更新某个动画缓存。
  • getArmatureNames 获取 DragonBones 数据中所有的 armature 名称
  • getAnimationNames 获取指定的 armature 的所有动画名称。
  • on 添加 DragonBones 事件监听器,与 addEventListener 作用相同。
  • off 移除 DragonBones 事件监听器,与 removeEventListener 作用相同。
  • on 添加 DragonBones 一次性事件监听器,回调会在第一时间被触发后删除自身。
  • addEventListener 添加 DragonBones 事件监听器。
  • removeEventListener 移除 DragonBones 事件监听器。
  • buildArmature 构建指定名称的 armature 对象
  • armature 获取 ArmatureDisplay 当前使用的 Armature 对象
  • update 如果该组件启用,则每帧调用 update。
  • lateUpdate 如果该组件启用,则每帧调用 LateUpdate。
  • __preload __preload is called before every onLoad....
  • onLoad 当附加到一个激活的节点上或者其节点第一次激活时候调用。
  • start 如果该组件第一次启用,则在所有组件的 update 之前调用。
  • onEnable 当该组件被启用,并且它的节点也激活时。
  • onDisable 当该组件被禁用或节点变为无效时调用。
  • onDestroy 该方法为生命周期方法,父类未必会有实现。
  • onFocusInEditor
  • onLostFocusInEditor
  • resetInEditor 用来初始化组件或节点的一些属性,当该组件被第一次添加到节点上或用户点击了它的 Reset 菜单时调用。
  • addComponent 向节点添加一个组件类,你还可以通过传入脚本的名称来添加组件。
  • getComponent 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。
  • getComponents 返回节点上指定类型的所有组件。
  • getComponentInChildren 递归查找所有子节点中第一个匹配指定类型的组件。
  • getComponentsInChildren 递归查找自身或所有子节点中指定类型的组件
  • _getLocalBounds 以便编辑器的场景视图可以正确地执行点选测试。
  • onRestore onRestore 是用户在检查器菜单点击 Reset 时,对此组件执行撤消操作后调用的。
  • schedule 调度一个自定义的回调函数。
  • scheduleOnce 调度一个只运行一次的回调函数,可以指定 0 让回调函数在下一帧立即执行或者在一定的延时之后执行。
  • unschedule 取消调度一个自定义的回调函数。
  • unscheduleAllCallbacks 取消调度所有已调度的回调函数:定制的回调函数以及 'update' 回调函数。
  • destroy 销毁该对象,并释放所有它对其它对象的引用。
  • _destruct Clear all references in the instance....
  • _onPreDestroy Called before the object being destroyed.
  • _serialize The customized serialization for this object. (Editor Only)
  • _deserialize Init this object from the custom serialized data.
事件

Details

属性(properties)

dragonAsset

骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序, attachments,皮肤等等)和动画但不持有任何状态。
多个 ArmatureDisplay 可以共用相同的骨骼数据。

meta description
类型 DragonBonesAsset
定义于 extensions/dragonbones/ArmatureDisplay.js:118
dragonAtlasAsset

骨骼数据所需的 Atlas Texture 数据。

meta description
类型 DragonBonesAtlasAsset
定义于 extensions/dragonbones/ArmatureDisplay.js:142
armatureName

当前的 Armature 名称。

meta description
类型 String
定义于 extensions/dragonbones/ArmatureDisplay.js:161
animationName

当前播放的动画名称。

meta description
类型 String
定义于 extensions/dragonbones/ArmatureDisplay.js:199
_defaultArmatureIndex
meta description
类型 Number
定义于 extensions/dragonbones/ArmatureDisplay.js:214
timeScale

当前骨骼中所有动画的时间缩放率。

meta description
类型 Number
定义于 extensions/dragonbones/ArmatureDisplay.js:297
playTimes

播放默认动画的循环次数 -1 表示使用配置文件中的默认值; 0 表示无限循环 0 表示循环次数

meta description
类型 Number
定义于 extensions/dragonbones/ArmatureDisplay.js:313
premultipliedAlpha

是否启用贴图预乘。 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。

meta description
类型 Boolean
定义于 extensions/dragonbones/ArmatureDisplay.js:330
debugBones

是否显示 bone 的 debug 信息。

meta description
类型 Boolean
定义于 extensions/dragonbones/ArmatureDisplay.js:344
enableBatch

开启合批,如果渲染大量相同纹理,且结构简单的骨骼动画,开启合批可以降低drawcall,否则请不要开启,cpu消耗会上升。

meta description
类型 Boolean
定义于 extensions/dragonbones/ArmatureDisplay.js:358
__eventTargets

Register all related EventTargets, all event callbacks will be removed in _onPreDestroy

meta description
类型 Array
定义于 cocos2d/core/components/CCComponent.js:61
node

该组件被附加到的节点。组件总会附加到一个节点。

meta description
类型 Node
定义于 cocos2d/core/components/CCComponent.js:75
示例
cc.log(comp.node);
uuid

组件的 uuid,用于编辑器。

meta description
类型 String
定义于 cocos2d/core/components/CCComponent.js:106
示例
cc.log(comp.uuid);
_enabled
meta description
类型 Boolean
定义于 cocos2d/core/components/CCComponent.js:147
enabled

表示该组件自身是否启用。

meta description
类型 Boolean
定义于 cocos2d/core/components/CCComponent.js:154
示例
comp.enabled = true;
cc.log(comp.enabled);
enabledInHierarchy

表示该组件是否被启用并且所在的节点也处于激活状态。

meta description
类型 Boolean
定义于 cocos2d/core/components/CCComponent.js:186
示例
cc.log(comp.enabledInHierarchy);
_isOnLoadCalled

返回一个值用来判断 onLoad 是否被调用过,不等于 0 时调用过,等于 0 时未调用。

meta description
类型 Number
定义于 cocos2d/core/components/CCComponent.js:202
示例
cc.log(this._isOnLoadCalled > 0);
_name
meta description
类型 String
定义于 cocos2d/core/platform/CCObject.js:76
_objFlags
meta description
类型 Number
定义于 cocos2d/core/platform/CCObject.js:83
name

该对象的名称。

meta description
类型 String
定义于 cocos2d/core/platform/CCObject.js:243
示例
obj.name = "New Obj";
isValid

表示该对象是否可用(被 destroy 后将不可用)。
当一个对象的 destroy 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 isValid 就会返回 false,而当前帧内 isValid 仍然会是 true。如果希望判断当前帧是否调用过 destroy,请使用 cc.isValid(obj, true),不过这往往是特殊的业务需求引起的,通常情况下不需要这样。

meta description
类型 Boolean
定义于 cocos2d/core/platform/CCObject.js:261
示例
var node = new cc.Node();
cc.log(node.isValid);    // true
node.destroy();
cc.log(node.isValid);    // true, still valid in this frame
// after a frame...
cc.log(node.isValid);    // false, destroyed in the end of last frame

方法

getArmatureKey

缓存龙骨数据的key值,换装的时会使用到该值,作为dragonbonesName使用

meta description
定义于 extensions/dragonbones/ArmatureDisplay.js:457
示例
let factory = dragonBones.CCFactory.getInstance();
let needChangeSlot = needChangeArmature.armature().getSlot("changeSlotName");
factory.replaceSlotDisplay(toChangeArmature.getArmatureKey(), "armatureName", "slotName", "displayName", needChangeSlot);
setAnimationCacheMode

若想切换渲染模式,最好在设置'dragonAsset'之前,先设置好渲染模式,否则有运行时开销。 若在编辑中设置渲染模式,则无需担心设置次序的问题。

meta description
定义于 extensions/dragonbones/ArmatureDisplay.js:480
参数列表
  • cacheMode AnimationCacheMode
示例
armatureDisplay.setAnimationCacheMode(dragonBones.ArmatureDisplay.AnimationCacheMode.SHARED_CACHE);
isAnimationCached

当前是否处于缓存模式。

meta description
定义于 extensions/dragonbones/ArmatureDisplay.js:501
playAnimation

播放指定的动画. animName 指定播放动画的名称。 playTimes 指定播放动画的次数。 -1 为使用配置文件中的次数。 0 为无限循环播放。

0 为动画的重复次数。

meta description
返回 dragonBones.AnimationState
定义于 extensions/dragonbones/ArmatureDisplay.js:721
参数列表
updateAnimationCache

更新某个动画缓存。

meta description
定义于 extensions/dragonbones/ArmatureDisplay.js:765
参数列表
getArmatureNames

获取 DragonBones 数据中所有的 armature 名称

meta description
返回 Array
定义于 extensions/dragonbones/ArmatureDisplay.js:779
getAnimationNames

获取指定的 armature 的所有动画名称。

meta description
返回 Array
定义于 extensions/dragonbones/ArmatureDisplay.js:792
参数列表
on

添加 DragonBones 事件监听器,与 addEventListener 作用相同。

meta description
定义于 extensions/dragonbones/ArmatureDisplay.js:817
参数列表
  • type String A string representing the event type to listen for.
  • listener Function The callback that will be invoked when the event is dispatched.
  • target Object The target (this object) to invoke the callback, can be null
off

移除 DragonBones 事件监听器,与 removeEventListener 作用相同。

meta description
定义于 extensions/dragonbones/ArmatureDisplay.js:832
参数列表
on

添加 DragonBones 一次性事件监听器,回调会在第一时间被触发后删除自身。。

meta description
定义于 extensions/dragonbones/ArmatureDisplay.js:846
参数列表
  • type String A string representing the event type to listen for.
  • listener Function The callback that will be invoked when the event is dispatched.
  • target Object The target (this object) to invoke the callback, can be null
addEventListener

添加 DragonBones 事件监听器。

meta description
定义于 extensions/dragonbones/ArmatureDisplay.js:861
参数列表
  • type String A string representing the event type to listen for.
  • listener Function The callback that will be invoked when the event is dispatched.
  • target Object The target (this object) to invoke the callback, can be null
removeEventListener

移除 DragonBones 事件监听器。

meta description
定义于 extensions/dragonbones/ArmatureDisplay.js:876
参数列表
buildArmature

构建指定名称的 armature 对象

meta description
返回 dragonBones.ArmatureDisplay
定义于 extensions/dragonbones/ArmatureDisplay.js:890
参数列表
armature

获取 ArmatureDisplay 当前使用的 Armature 对象

meta description
返回 Object
定义于 extensions/dragonbones/ArmatureDisplay.js:904
update

如果该组件启用,则每帧调用 update。
该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。

meta description
定义于 cocos2d/core/components/CCComponent.js:223
参数列表
  • dt Number the delta time in seconds it took to complete the last frame
lateUpdate

如果该组件启用,则每帧调用 LateUpdate。
该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。

meta description
定义于 cocos2d/core/components/CCComponent.js:234
__preload

__preload is called before every onLoad. It is used to initialize the builtin components internally, to avoid checking whether onLoad is called before every public method calls. This method should be removed if script priority is supported.

meta description
定义于 cocos2d/core/components/CCComponent.js:244
onLoad

当附加到一个激活的节点上或者其节点第一次激活时候调用。onLoad 总是会在任何 start 方法调用前执行,这能用于安排脚本的初始化顺序。
该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。

meta description
定义于 cocos2d/core/components/CCComponent.js:255
start

如果该组件第一次启用,则在所有组件的 update 之前调用。通常用于需要在所有组件的 onLoad 初始化完毕后执行的逻辑。
该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。

meta description
定义于 cocos2d/core/components/CCComponent.js:268
onEnable

当该组件被启用,并且它的节点也激活时。
该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。

meta description
定义于 cocos2d/core/components/CCComponent.js:281
onDisable

当该组件被禁用或节点变为无效时调用。
该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。

meta description
定义于 cocos2d/core/components/CCComponent.js:291
onDestroy

当该组件被销毁时调用
该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。

meta description
定义于 cocos2d/core/components/CCComponent.js:301
onFocusInEditor
meta description
定义于 cocos2d/core/components/CCComponent.js:311
onLostFocusInEditor
meta description
定义于 cocos2d/core/components/CCComponent.js:316
resetInEditor

用来初始化组件或节点的一些属性,当该组件被第一次添加到节点上或用户点击了它的 Reset 菜单时调用。这个回调只会在编辑器下调用。

meta description
定义于 cocos2d/core/components/CCComponent.js:321
addComponent

向节点添加一个组件类,你还可以通过传入脚本的名称来添加组件。

meta description
返回 Component
定义于 cocos2d/core/components/CCComponent.js:331
参数列表
  • typeOrClassName Function | String the constructor or the class name of the component to add
示例
var sprite = node.addComponent(cc.Sprite);
var test = node.addComponent("Test");
getComponent

获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。
传入参数也可以是脚本的名称。

meta description
返回 Component
定义于 cocos2d/core/components/CCComponent.js:349
参数列表
示例
// get sprite component.
var sprite = node.getComponent(cc.Sprite);
// get custom test calss.
var test = node.getComponent("Test");
getComponents

返回节点上指定类型的所有组件。

meta description
返回 Component[]
定义于 cocos2d/core/components/CCComponent.js:373
参数列表
示例
var sprites = node.getComponents(cc.Sprite);
var tests = node.getComponents("Test");
getComponentInChildren

递归查找所有子节点中第一个匹配指定类型的组件。

meta description
返回 Component
定义于 cocos2d/core/components/CCComponent.js:391
参数列表
示例
var sprite = node.getComponentInChildren(cc.Sprite);
var Test = node.getComponentInChildren("Test");
getComponentsInChildren

递归查找自身或所有子节点中指定类型的组件

meta description
返回 Component[]
定义于 cocos2d/core/components/CCComponent.js:409
参数列表
示例
var sprites = node.getComponentsInChildren(cc.Sprite);
var tests = node.getComponentsInChildren("Test");
_getLocalBounds

如果组件的包围盒与节点不同,您可以实现该方法以提供自定义的轴向对齐的包围盒(AABB), 以便编辑器的场景视图可以正确地执行点选测试。

meta description
定义于 cocos2d/core/components/CCComponent.js:429
参数列表
  • out_rect Rect the Rect to receive the bounding box
onRestore

onRestore 是用户在检查器菜单点击 Reset 时,对此组件执行撤消操作后调用的。

如果组件包含了“内部状态”(不在 CCClass 属性中定义的临时成员变量),那么你可能需要实现该方法。

编辑器执行撤销/重做操作时,将调用组件的 get set 来录制和还原组件的状态。 然而,在极端的情况下,它可能无法良好运作。
那么你就应该实现这个方法,手动根据组件的属性同步“内部状态”。 一旦你实现这个方法,当用户撤销或重做时,组件的所有 get set 都不会再被调用。 这意味着仅仅指定了默认值的属性将被编辑器记录和还原。

同样的,编辑可能无法在极端情况下正确地重置您的组件。
于是如果你需要支持组件重置菜单,你需要在该方法中手工同步组件属性到“内部状态”。
一旦你实现这个方法,组件的所有 get set 都不会在重置操作时被调用。 这意味着仅仅指定了默认值的属性将被编辑器重置。
此方法仅在编辑器下会被调用。

meta description
定义于 cocos2d/core/components/CCComponent.js:442
schedule

调度一个自定义的回调函数。
如果回调函数已调度,那么将不会重复调度它,只会更新时间间隔参数。

meta description
定义于 cocos2d/core/components/CCComponent.js:536
参数列表
  • callback function The callback function
  • interval Number Tick interval in seconds. 0 means tick every frame.
  • repeat Number The selector will be executed (repeat + 1) times, you can use cc.macro.REPEAT_FOREVER for tick infinitely.
  • delay Number The amount of time that the first tick will wait before execution.
示例
var timeCallback = function (dt) {
  cc.log("time: " + dt);
}
this.schedule(timeCallback, 1);
scheduleOnce

调度一个只运行一次的回调函数,可以指定 0 让回调函数在下一帧立即执行或者在一定的延时之后执行。

meta description
定义于 cocos2d/core/components/CCComponent.js:573
参数列表
  • callback function A function wrapped as a selector
  • delay Number The amount of time that the first tick will wait before execution.
示例
var timeCallback = function (dt) {
  cc.log("time: " + dt);
}
this.scheduleOnce(timeCallback, 2);
unschedule

取消调度一个自定义的回调函数。

meta description
定义于 cocos2d/core/components/CCComponent.js:590
参数列表
  • callback_fn function A function wrapped as a selector
示例
this.unschedule(_callback);
unscheduleAllCallbacks

取消调度所有已调度的回调函数:定制的回调函数以及 'update' 回调函数。动作不受此方法影响。

meta description
定义于 cocos2d/core/components/CCComponent.js:606
示例
this.unscheduleAllCallbacks();
destroy

销毁该对象,并释放所有它对其它对象的引用。
实际销毁操作会延迟到当前帧渲染前执行。从下一帧开始,该对象将不再可用。 您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。

meta description
返回 Boolean
定义于 cocos2d/core/platform/CCObject.js:296
示例
obj.destroy();
_destruct

Clear all references in the instance.

NOTE: this method will not clear the getter or setter functions which defined in the instance of CCObject. You can override the _destruct method if you need, for example: _destruct: function () { for (var key in this) { if (this.hasOwnProperty(key)) { switch (typeof this[key]) { case 'string': this[key] = ''; break; case 'object': case 'function': this[key] = null; break; } } }

meta description
定义于 cocos2d/core/platform/CCObject.js:430
_onPreDestroy

Called before the object being destroyed.

meta description
定义于 cocos2d/core/platform/CCObject.js:463
_serialize

The customized serialization for this object. (Editor Only)

meta description
返回 object
定义于 cocos2d/core/platform/CCObject.js:488
参数列表
_deserialize

Init this object from the custom serialized data.

meta description
定义于 cocos2d/core/platform/CCObject.js:498
参数列表
  • data Object the serialized json data
  • ctx _Deserializer

事件

dragonBones.EventObject.START Event

模块: dragonBones

动画开始播放。

索引

Details

dragonBones.EventObject.LOOP_COMPLETE Event

模块: dragonBones

动画循环播放完成一次。

索引

Details

dragonBones.EventObject.COMPLETE Event

模块: dragonBones

动画播放完成。

索引

Details

dragonBones.EventObject.FADE_IN Event

模块: dragonBones

动画淡入开始。

索引

Details

dragonBones.EventObject.FADE_IN_COMPLETE Event

模块: dragonBones

动画淡入完成。

索引

Details

dragonBones.EventObject.FADE_OUT Event

模块: dragonBones

动画淡出开始。

索引

Details

dragonBones.EventObject.FADE_OUT_COMPLETE Event

模块: dragonBones

动画淡出完成。

索引

Details

dragonBones.EventObject.FRAME_EVENT Event

模块: dragonBones

动画帧事件。

索引

Details

dragonBones.EventObject.SOUND_EVENT Event

模块: dragonBones

动画帧声音事件。

索引

Details

条与 "" 相匹配的结果

    没有与 "" 匹配的结果