Skip to content

Instantly share code, notes, and snippets.

@nshermione
Created January 22, 2019 03:54
Show Gist options
  • Save nshermione/d4e1e9071e8a90d38f91f0cf6482ce4f to your computer and use it in GitHub Desktop.
Save nshermione/d4e1e9071e8a90d38f91f0cf6482ce4f to your computer and use it in GitHub Desktop.
export class Skeleton extends cc._RendererUnderSG {
/** !#en The skeletal animation is paused?
!#zh 该骨骼动画是否暂停。 */
paused: boolean;
/** !#en
The skeleton data contains the skeleton information (bind pose bones, slots, draw order,
attachments, skins, etc) and animations but does not hold any state.<br/>
Multiple skeletons can share the same skeleton data.
!#zh
骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序,
attachments,皮肤等等)和动画但不持有任何状态。<br/>
多个 Skeleton 可以共用相同的骨骼数据。 */
skeletonData: SkeletonData;
/** !#en The name of default skin.
!#zh 默认的皮肤名称。 */
defaultSkin: string;
/** !#en The name of default animation.
!#zh 默认的动画名称。 */
defaultAnimation: string;
/** !#en The name of current playing animation.
!#zh 当前播放的动画名称。 */
animation: string;
_defaultSkinIndex: number;
/** !#en TODO
!#zh 是否循环播放当前骨骼动画。 */
loop: boolean;
/** !#en Indicates whether to enable premultiplied alpha.
You should disable this option when image's transparent area appears to have opaque pixels,
or enable this option when image's half transparent area appears to be darken.
!#zh 是否启用贴图预乘。
当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。 */
premultipliedAlpha: boolean;
/** !#en The time scale of this skeleton.
!#zh 当前骨骼中所有动画的时间缩放率。 */
timeScale: number;
/** !#en Indicates whether open debug slots.
!#zh 是否显示 slot 的 debug 信息。 */
debugSlots: boolean;
/** !#en Indicates whether open debug bones.
!#zh 是否显示 bone 的 debug 信息。 */
debugBones: boolean;
/**
!#en Computes the world SRT from the local SRT for each bone.
!#zh 重新更新所有骨骼的世界 Transform,
当获取 bone 的数值未更新时,即可使用该函数进行更新数值。
@example
```js
var bone = spine.findBone('head');
cc.log(bone.worldX); // return 0;
spine.updateWorldTransform();
bone = spine.findBone('head');
cc.log(bone.worldX); // return -23.12;
```
*/
updateWorldTransform(): void;
/**
!#en Sets the bones and slots to the setup pose.
!#zh 还原到起始动作
*/
setToSetupPose(): void;
/**
!#en
Sets the bones to the setup pose,
using the values from the `BoneData` list in the `SkeletonData`.
!#zh
设置 bone 到起始动作
使用 SkeletonData 中的 BoneData 列表中的值。
*/
setBonesToSetupPose(): void;
/**
!#en
Sets the slots to the setup pose,
using the values from the `SlotData` list in the `SkeletonData`.
!#zh
设置 slot 到起始动作。
使用 SkeletonData 中的 SlotData 列表中的值。
*/
setSlotsToSetupPose(): void;
/**
!#en
Finds a bone by name.
This does a string comparison for every bone.<br>
Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone object.
!#zh
通过名称查找 bone。
这里对每个 bone 的名称进行了对比。<br>
返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone 对象。
@param boneName boneName
*/
findBone(boneName: string): sp.spine.Bone;
/**
!#en
Finds a slot by name. This does a string comparison for every slot.<br>
Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot object.
!#zh
通过名称查找 slot。这里对每个 slot 的名称进行了比较。<br>
返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot 对象。
@param slotName slotName
*/
findSlot(slotName: string): sp.spine.Slot;
/**
!#en
Finds a skin by name and makes it the active skin.
This does a string comparison for every skin.<br>
Note that setting the skin does not change which attachments are visible.<br>
Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin object.
!#zh
按名称查找皮肤,激活该皮肤。这里对每个皮肤的名称进行了比较。<br>
注意:设置皮肤不会改变 attachment 的可见性。<br>
返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin 对象。
@param skinName skinName
*/
setSkin(skinName: string): sp.spine.Skin;
/**
!#en
Returns the attachment for the slot and attachment name.
The skeleton looks first in its skin, then in the skeleton data’s default skin.<br>
Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment object.
!#zh
通过 slot 和 attachment 的名称获取 attachment。Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。<br>
返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment 对象。
@param slotName slotName
@param attachmentName attachmentName
*/
getAttachment(slotName: string, attachmentName: string): sp.spine.Attachment;
/**
!#en
Sets the attachment for the slot and attachment name.
The skeleton looks first in its skin, then in the skeleton data’s default skin.
!#zh
通过 slot 和 attachment 的名字来设置 attachment。
Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。
@param slotName slotName
@param attachmentName attachmentName
*/
setAttachment(slotName: string, attachmentName: string): void;
/**
!#en
Sets runtime skeleton data to sp.Skeleton.<br>
This method is different from the `skeletonData` property. This method is passed in the raw data provided by the Spine runtime, and the skeletonData type is the asset type provided by Creator.
!#zh
设置底层运行时用到的 SkeletonData。<br>
这个接口有别于 `skeletonData` 属性,这个接口传入的是 Spine runtime 提供的原始数据,而 skeletonData 的类型是 Creator 提供的资源类型。
@param skeletonData skeletonData
@param ownsSkeletonData ownsSkeletonData
*/
setSkeletonData(skeletonData: sp.spine.SkeletonData, ownsSkeletonData: sp.spine.SkeletonData): void;
/**
!#en Sets animation state data.<br>
The parameter type is {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData.
!#zh 设置动画状态数据。<br>
参数是 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData。
@param stateData stateData
*/
setAnimationStateData(stateData: sp.spine.AnimationStateData): void;
/**
!#en
Mix applies all keyframe values,
interpolated for the specified time and mixed with the current values.
!#zh 为所有关键帧设定混合及混合时间(从当前值开始差值)。
@param fromAnimation fromAnimation
@param toAnimation toAnimation
@param duration duration
*/
setMix(fromAnimation: string, toAnimation: string, duration: number): void;
/**
!#en Sets event listener.
!#zh 设置动画事件监听器。
@param target target
@param callback callback
*/
setAnimationListener(target: any, callback: Function): void;
/**
!#en Set the current animation. Any queued animations are cleared.<br>
Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
!#zh 设置当前动画。队列中的任何的动画将被清除。<br>
返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。
@param trackIndex trackIndex
@param name name
@param loop loop
*/
setAnimation(trackIndex: number, name: string, loop: boolean): sp.spine.TrackEntry;
/**
!#en Adds an animation to be played delay seconds after the current or last queued animation.<br>
Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
!#zh 添加一个动画到动画队列尾部,还可以延迟指定的秒数。<br>
返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。
@param trackIndex trackIndex
@param name name
@param loop loop
@param delay delay
*/
addAnimation(trackIndex: number, name: string, loop: boolean, delay?: number): sp.spine.TrackEntry;
/**
!#en Find animation with specified name.
!#zh 查找指定名称的动画
@param name name
*/
findAnimation(name: string): sp.spine.Animation;
/**
!#en Returns track entry by trackIndex.<br>
Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
!#zh 通过 track 索引获取 TrackEntry。<br>
返回一个 {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry 对象。
@param trackIndex trackIndex
*/
getCurrent(trackIndex: void): sp.spine.TrackEntry;
/**
!#en Clears all tracks of animation state.
!#zh 清除所有 track 的动画状态。
*/
clearTracks(): void;
/**
!#en Clears track of animation state by trackIndex.
!#zh 清除出指定 track 的动画状态。
@param trackIndex trackIndex
*/
clearTrack(trackIndex: number): void;
/**
!#en Set the start event listener.
!#zh 用来设置开始播放动画的事件监听。
@param listener listener
*/
setStartListener(listener: Function): void;
/**
!#en Set the interrupt event listener.
!#zh 用来设置动画被打断的事件监听。
@param listener listener
*/
setInterruptListener(listener: Function): void;
/**
!#en Set the end event listener.
!#zh 用来设置动画播放完后的事件监听。
@param listener listener
*/
setEndListener(listener: Function): void;
/**
!#en Set the dispose event listener.
!#zh 用来设置动画将被销毁的事件监听。
@param listener listener
*/
setDisposeListener(listener: Function): void;
/**
!#en Set the complete event listener.
!#zh 用来设置动画播放一次循环结束后的事件监听。
@param listener listener
*/
setCompleteListener(listener: Function): void;
/**
!#en Set the animation event listener.
!#zh 用来设置动画播放过程中帧事件的监听。
@param listener listener
*/
setEventListener(listener: Function): void;
/**
!#en Set the start event listener for specified TrackEntry (only supported on Web).
!#zh 用来为指定的 TrackEntry 设置动画开始播放的事件监听。(只支持 Web 平台)
@param entry entry
@param listener listener
*/
setTrackStartListener(entry: sp.spine.TrackEntry, listener: Function): void;
/**
!#en Set the interrupt event listener for specified TrackEntry (only supported on Web).
!#zh 用来为指定的 TrackEntry 设置动画被打断的事件监听。(只支持 Web 平台)
@param entry entry
@param listener listener
*/
setTrackInterruptListener(entry: sp.spine.TrackEntry, listener: Function): void;
/**
!#en Set the end event listener for specified TrackEntry (only supported on Web).
!#zh 用来为指定的 TrackEntry 设置动画播放结束的事件监听。(只支持 Web 平台)
@param entry entry
@param listener listener
*/
setTrackEndListener(entry: sp.spine.TrackEntry, listener: Function): void;
/**
!#en Set the dispose event listener for specified TrackEntry (only supported on Web).
!#zh 用来为指定的 TrackEntry 设置动画即将被销毁的事件监听。(只支持 Web 平台)
@param entry entry
@param listener listener
*/
setTrackDisposeListener(entry: sp.spine.TrackEntry, listener: Function): void;
/**
!#en Set the complete event listener for specified TrackEntry (only supported on Web).
!#zh 用来为指定的 TrackEntry 设置动画一次循环播放结束的事件监听。(只支持 Web 平台)
@param entry entry
@param listener listener
*/
setTrackCompleteListener(entry: sp.spine.TrackEntry, listener: Function): void;
/**
!#en Set the event listener for specified TrackEntry (only supported on Web).
!#zh 用来为指定的 TrackEntry 设置动画帧事件的监听。(只支持 Web 平台)
@param entry entry
@param listener listener
*/
setTrackEventListener(entry: sp.spine.TrackEntry, listener: Function): void;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment