AudioClip 类型
继承于 Asset
, EventTarget
(mixin)
模块: cc父模块: cc
音频资源类。
索引
属性(properties)
方法
事件
Details
属性(properties)
loaded
该资源是否已经成功加载
nativeUrl
返回该资源对应的目标平台资源的 URL,如果没有将返回一个空字符串。
_native
Serializable url for native asset.
_nativeAsset
The underlying native asset of this asset if one is available.This property can be used to access additional details or functionality releated to the asset.This property will be initialized by the loader if _native
is available.
_uuid
_name
_objFlags
name
该对象的名称。
示例
obj.name = "New Obj";
isValid
表示该对象是否可用(被 destroy 后将不可用)。当一个对象的 destroy
调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 isValid
就会返回 false,而当前帧内 isValid
仍然会是 true。如果希望判断当前帧是否调用过 destroy
,请使用 cc.isValid(obj, true)
,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。
示例
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
方法
toString
Returns the asset's url.
The Asset
object overrides the toString()
method of the Object
object.For Asset
objects, the toString() method returns a string representation of the object.JavaScript calls the toString() method automatically when an asset is to be represented as a text value or when a texture is referred to in a string concatenation.
serialize
应 AssetDB 要求提供这个方法
createNode
使用该资源在场景中创建一个新节点。如果这类资源没有相应的节点类型,该方法应该是空的。
参数列表
_setRawAsset
Set native file name for this asset.
参数列表
hasEventListener
检查事件目标对象是否有为特定类型的事件注册的回调。
参数列表
type
String The type of event.
on
注册事件目标的特定事件类型回调。这种类型的事件应该被 emit
触发。
参数列表
type
String A string representing the event type to listen for.callback
Function The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
arg1
Any arg1arg2
Any arg2arg3
Any arg3arg4
Any arg4arg5
Any arg5
target
Object The target (this object) to invoke the callback, can be null
示例
eventTarget.on('fire', function () {
cc.log("fire in the hole");
}, node);
off
删除之前用同类型,回调,目标或 useCapture 注册的事件监听器,如果只传递 type,将会删除 type 类型的所有事件监听器。
参数列表
type
String A string representing the event type being removed.callback
Function The callback to remove.target
Object The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
示例
// register fire eventListener
var callback = eventTarget.on('fire', function () {
cc.log("fire in the hole");
}, target);
// remove fire event listener
eventTarget.off('fire', callback, target);
// remove all fire event listeners
eventTarget.off('fire');
targetOff
在当前 EventTarget 上删除指定目标(target 参数)注册的所有事件监听器。这个函数无法删除当前 EventTarget 的所有事件监听器,也无法删除 target 参数所注册的所有事件监听器。这个函数只能删除 target 参数在当前 EventTarget 上注册的所有事件监听器。
参数列表
target
Object The target to be searched for all related listeners
once
注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
参数列表
type
String A string representing the event type to listen for.callback
Function The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
arg1
Any arg1arg2
Any arg2arg3
Any arg3arg4
Any arg4arg5
Any arg5
target
Object The target (this object) to invoke the callback, can be null
示例
eventTarget.once('fire', function () {
cc.log("this is the callback and will be invoked only once");
}, node);
emit
通过事件名发送自定义事件
参数列表
type
String event typearg1
Any First argumentarg2
Any Second argumentarg3
Any Third argumentarg4
Any Fourth argumentarg5
Any Fifth argument
示例
eventTarget.emit('fire', event);
eventTarget.emit('fire', message, emitter);
dispatchEvent
通过事件对象派发事件
参数列表
destroy
销毁该对象,并释放所有它对其它对象的引用。实际销毁操作会延迟到当前帧渲染前执行。从下一帧开始,该对象将不再可用。您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。
示例
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; } } }
_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.
参数列表
data
Object the serialized json datactx
_Deserializer
事件
load Event
模块: cc父模块: cc
当该资源加载成功后触发该事件
索引
Details