### getState Source: https://docs.cocos.com/creator/2.4/api/zh/classes/audioEngine.html Gets the current state of the audio. ```APIDOC ## getState ### Description Gets the current state of the audio. ### Method `getState` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **audioID** (Number) - The ID of the audio. ### Request Example ```javascript var state = cc.audioEngine.getState(id); ``` ### Response #### Success Response (200) - **state** (audioEngine.AudioState) - The current state of the audio (e.g., PLAYING, PAUSED, STOPPED). #### Response Example ```json { "state": "PLAYING" } ``` ``` -------------------------------- ### Editor.watchPackages(callback) Source: https://docs.cocos.com/creator/2.4/api/zh/editor/main/editor.html Starts watching all packages for changes. ```APIDOC ## Editor.watchPackages(callback) ### Description Start watching all packages. Once it done the `callback` will be invoked. ### Method `Editor.watchPackages(callback)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * `callback` (function) ``` -------------------------------- ### ParticleSystem Runtime Customization Source: https://docs.cocos.com/creator/2.4/api/zh/classes/ParticleSystem.html Demonstrates how to customize ParticleSystem properties at runtime, such as radial acceleration and start spin. ```APIDOC ## ParticleSystem Runtime Customization ### Description This section shows how to modify ParticleSystem properties directly in your code to dynamically alter particle effects. ### Properties - `radialAccel` (Number) - Sets the radial acceleration of particles. - `startSpin` (Number) - Sets the initial spin of particles. ### Example ```javascript emitter.radialAccel = 15; emitter.startSpin = 0; ``` ``` -------------------------------- ### Watch Packages Source: https://docs.cocos.com/creator/2.4/api/zh/editor/main/editor.html Starts watching all packages for changes. A callback function is invoked upon completion. ```javascript Editor.watchPackages(callback) ``` -------------------------------- ### Tween Example Usage Source: https://docs.cocos.com/creator/2.4/api/zh/classes/Tween.html Demonstrates how to create and control animations using the Tween API with chaining and callbacks. ```APIDOC ## Example ```javascript cc.tween(node) .to(1, {scale: 2, position: cc.v3(100, 100, 100)}) .call(() => { console.log('This is a callback'); }) .by(1, {scale: 3, position: cc.v3(200, 200, 200)}, {easing: 'sineOutIn'}) .start(cc.find('Canvas/cocos')); ``` ``` -------------------------------- ### Editor.Package.queryInfos Source: https://docs.cocos.com/creator/2.4/api/zh/editor/renderer/package.html Queries information for all installed packages and returns the information via a callback function. This sends a message to the main process. ```APIDOC ## Editor.Package.queryInfos (cb) ### Description Queries information for all installed packages and returns the information via a callback function. This sends a message to the main process. ### Method Not applicable (this is an SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **cb** (function) - Required - The callback function to receive the package information. ``` -------------------------------- ### Editor.UI.installDownUpEvent Source: https://docs.cocos.com/creator/2.4/api/zh/editor/renderer/ui/dom-utils.html Installs event listeners for mouse down and up events on an element, typically for button-like behavior. ```APIDOC ## Editor.UI.installDownUpEvent (element) ### Description Handle mouse down and up event for button like element. ### Parameters #### Path Parameters - **element** (HTMLElement) - Required - The HTML element to install the events on. ``` -------------------------------- ### Get All Asset Infos in Directory Source: https://docs.cocos.com/creator/2.4/api/zh/classes/Bundle.html Fetches configuration information for all assets within a specified folder. The `type` parameter can filter assets, and results can be appended to an `out` array. Paths should use forward slashes. ```javascript var infos = []; bundle.getDirWithPath('images', cc.Texture2D, infos); ``` -------------------------------- ### Get Scene Info by Name Source: https://docs.cocos.com/creator/2.4/api/zh/classes/Bundle.html Retrieves the configuration information for a scene using its name. The name should typically include the '.fire' extension if applicable. ```javascript var info = bundle.getSceneInfo('first.fire'); ``` -------------------------------- ### Getting Layer Property Source: https://docs.cocos.com/creator/2.4/api/zh/classes/TiledLayer.html Demonstrates how to fetch the value of a specific property associated with the tile layer. ```javascript let property = tiledLayer.getProperty("info"); cc.log(property); ``` -------------------------------- ### Get Asset Info by Path Source: https://docs.cocos.com/creator/2.4/api/zh/classes/Bundle.html Retrieves configuration information for a specific asset using its relative path and type. Ensure the path is relative to the bundle's folder and extensions are omitted. ```javascript var info = bundle.getInfoWithPath('image/a', cc.Texture2D); ``` -------------------------------- ### Customize Particle System Properties at Runtime Source: https://docs.cocos.com/creator/2.4/api/zh/classes/ParticleSystem.html Demonstrates how to modify radial acceleration and starting spin of a particle emitter during runtime. Ensure the emitter object is properly initialized before setting these properties. ```javascript emitter.radialAccel = 15; emitter.startSpin = 0; ``` -------------------------------- ### Getting and Setting Layer Name Source: https://docs.cocos.com/creator/2.4/api/zh/classes/TiledLayer.html Shows how to retrieve the current name of a tile layer and how to set a new name for it. ```javascript let layerName = tiledLayer.getLayerName(); cc.log(layerName); tiledLayer.setLayerName("New Layer"); ``` -------------------------------- ### Update Method Example Source: https://docs.cocos.com/creator/2.4/api/zh/classes/PrismaticJoint.html Illustrates the signature of the update method, which is called every frame if the component is enabled. This is a lifecycle method. ```javascript // dt: the delta time in seconds it took to complete the last frame update(dt) { } ``` -------------------------------- ### Instantiate ActionManager Source: https://docs.cocos.com/creator/2.4/api/zh/classes/ActionManager.html Demonstrates how to create a new instance of the ActionManager. This is typically not needed as it's a singleton. ```javascript var mng = new cc.ActionManager(); ``` -------------------------------- ### Getting Tile Pixel Position Source: https://docs.cocos.com/creator/2.4/api/zh/classes/TiledLayer.html Illustrates how to get the pixel coordinates of a tile using either a Vec2 or separate x and y coordinates. ```javascript let pos = tiledLayer.getPositionAt(cc.v2(0, 0)); cc.log("Pos: " + pos); let pos = tiledLayer.getPositionAt(0, 0); cc.log("Pos: " + pos); ``` -------------------------------- ### getMusicVolume Source: https://docs.cocos.com/creator/2.4/api/zh/classes/audioEngine.html Gets the volume of the background music. ```APIDOC ## getMusicVolume ### Description Gets the volume of the background music. ### Method `getMusicVolume` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example ```javascript cc.audioEngine.getMusicVolume(); ``` ### Response #### Success Response (200) - **volume** (Number) - The current volume level (0.0 to 1.0). #### Response Example ```json { "volume": 0.8 } ``` ``` -------------------------------- ### Editor.loadAllPackages(callback) Source: https://docs.cocos.com/creator/2.4/api/zh/editor/main/editor.html Loads all packages specified in the `package-search-path` from `Editor.init`. ```APIDOC ## Editor.loadAllPackages(callback) ### Description Load all packages under the `package-search-path` which specified in `Editor.init`. Once it done the `callback` will be invoked. ### Method `Editor.loadAllPackages(callback)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * `callback` (function) ``` -------------------------------- ### Load All Packages Source: https://docs.cocos.com/creator/2.4/api/zh/editor/main/editor.html Loads all packages defined in the `package-search-path` during `Editor.init`. A callback function is invoked upon completion. ```javascript Editor.loadAllPackages(callback) ``` -------------------------------- ### getDuration Source: https://docs.cocos.com/creator/2.4/api/zh/classes/audioEngine.html Gets the total duration of the audio. ```APIDOC ## getDuration ### Description Gets the total duration of the audio. ### Method `getDuration` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **audioID** (Number) - The ID of the audio. ### Request Example ```javascript var time = cc.audioEngine.getDuration(id); ``` ### Response #### Success Response (200) - **duration** (Number) - The total duration of the audio in seconds. #### Response Example ```json { "duration": 180.5 } ``` ``` -------------------------------- ### AssetDB.init Source: https://docs.cocos.com/creator/2.4/api/zh/editor/asset-db.html Initializes the AssetDB by scanning mounted directories and importing unimported assets. It returns a list of assets that were imported during the initialization process. ```APIDOC ## AssetDB.init([cb]) ### Description Init assetdb, it will scan the mounted directories, and import unimported assets. ### Method static ### Parameters - **[cb]** (function) - Optional callback function that receives an error and a results array. ### Request Example ```javascript Editor.assetdb.init(function (err, results) { // assets that imported during init results.forEach(function ( result ) { // result.uuid // result.parentUuid // result.url // result.path // result.type }); }); ``` ``` -------------------------------- ### Create and Run a Tween Animation Source: https://docs.cocos.com/creator/2.4/api/zh/classes/Tween.html This snippet demonstrates creating a chained tween animation with 'to', 'call', and 'by' actions, and then starting it. It targets a specific node found by its path. ```javascript cc.tween(node) .to(1, {scale: 2, position: cc.v3(100, 100, 100)}) .call(() => { console.log('This is a callback'); }) .by(1, {scale: 3, position: cc.v3(200, 200, 200)}, {easing: 'sineOutIn'}) .start(cc.find('Canvas/cocos')); ``` -------------------------------- ### getVolume Source: https://docs.cocos.com/creator/2.4/api/zh/classes/audioEngine.html Gets the current volume of the audio. ```APIDOC ## getVolume ### Description Gets the current volume of the audio. ### Method `getVolume` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **audioID** (Number) - The ID of the audio. ### Request Example ```javascript var volume = cc.audioEngine.getVolume(id); ``` ### Response #### Success Response (200) - **volume** (Number) - The current volume level (0.0 to 1.0). #### Response Example ```json { "volume": 0.5 } ``` ``` -------------------------------- ### Load Packages at Path Source: https://docs.cocos.com/creator/2.4/api/zh/editor/main/editor.html Loads all packages located under a specified directory path. A callback function is invoked upon completion. ```javascript Editor.loadPackagesAt(path, callback) ``` -------------------------------- ### isLoop Source: https://docs.cocos.com/creator/2.4/api/zh/classes/audioEngine.html Gets the loop state of the audio. ```APIDOC ## isLoop ### Description Gets the loop state of the audio. ### Method `isLoop` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **audioID** (Number) - The ID of the audio. ### Request Example ```javascript cc.audioEngine.isLoop(id); ``` ### Response #### Success Response (200) - **loopState** (Boolean) - The loop state of the audio. #### Response Example ```json { "loopState": true } ``` ``` -------------------------------- ### getEffectsVolume Source: https://docs.cocos.com/creator/2.4/api/zh/classes/audioEngine.html Gets the current volume for all sound effects. ```APIDOC ## getEffectsVolume ### Description Gets the current volume for all sound effects. ### Method `getEffectsVolume` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example ```javascript cc.audioEngine.getEffectsVolume(); ``` ### Response #### Success Response (200) - **volume** (Number) - The current volume level for sound effects (0.0 to 1.0). #### Response Example ```json { "volume": 0.5 } ``` ``` -------------------------------- ### win.show Source: https://docs.cocos.com/creator/2.4/api/zh/editor/main/window.html Makes the editor window visible. ```APIDOC ## win.show () ### Description Shows the editor window if it was previously hidden. ``` -------------------------------- ### getCurrentTime Source: https://docs.cocos.com/creator/2.4/api/zh/classes/audioEngine.html Gets the current playback time of the audio. ```APIDOC ## getCurrentTime ### Description Gets the current playback time of the audio. ### Method `getCurrentTime` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **audioID** (Number) - The ID of the audio. ### Request Example ```javascript var time = cc.audioEngine.getCurrentTime(id); ``` ### Response #### Success Response (200) - **currentTime** (Number) - The current playback time in seconds. #### Response Example ```json { "currentTime": 2.5 } ``` ``` -------------------------------- ### Initialize AssetDB Source: https://docs.cocos.com/creator/2.4/api/zh/editor/asset-db.html Initializes the AssetDB, scanning mounted directories and importing unimported assets. The callback receives an array of imported assets. ```javascript Editor.assetdb.init(function (err, results) { // assets that imported during init results.forEach(function ( result ) { // result.uuid // result.parentUuid // result.url // result.path // result.type }); }); ``` -------------------------------- ### Editor.init(opts) Source: https://docs.cocos.com/creator/2.4/api/zh/editor/main/editor.html Initializes and configures the Editor module with provided options. ```APIDOC ## Editor.init(opts) ### Description Init and config the Editor module. For more details about `Editor.init` options, read Editor Configuration ### Method `Editor.init(opts)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * `opts` (object) - Options * `i18n` (array) - Specify i18n phrases for your application * `layout` (string) - Specify the layout file used as default layout for your application * `main-menu` (function) - A function returns the main menu template * `profile` (object) - Register profile name to path table used in `Editor.Profile` module * `package-search-path` (array) - Paths to search packages * `panel-window` (string) - Specify a html file that used as panel window entry page * `selection` (object) - Register selection type that used in `Editor.Selection` module * `theme` (string) - The name of the theme we would like to search for in `theme://` protocol * `theme-search-path` (array) - Paths to search in `theme://` protocol ``` -------------------------------- ### AssetDB.getRelativePath Source: https://docs.cocos.com/creator/2.4/api/zh/editor/asset-db.html Gets the relative path of a file system path. ```APIDOC ## AssetDB.getRelativePath ### Description Gets the relative path of a file system path. ### Method `AssetDB.getRelativePath(fspath) ⇒ string` ### Parameters * **fspath** (string) - The file system path. ``` -------------------------------- ### win.load Source: https://docs.cocos.com/creator/2.4/api/zh/editor/main/window.html Loads a new page into the window and passes arguments to the renderer process. ```APIDOC ## win.load (editorUrl, argv) ### Description Loads a specified URL into the window and passes arguments to the renderer process. ### Parameters * `editorUrl` (string) - The URL to load. * `argv` (object) - Arguments to be passed to the renderer process, which will be available in `Editor.argv`. ``` -------------------------------- ### AssetDB.getAssetBackupPath Source: https://docs.cocos.com/creator/2.4/api/zh/editor/asset-db.html Gets the backup path for a given asset file path. ```APIDOC ## AssetDB.getAssetBackupPath ### Description Gets the backup path for a given asset file path. ### Method `AssetDB.getAssetBackupPath(filePath)` ### Parameters * **filePath** (string) - The path of the asset file. ``` -------------------------------- ### AssetDB.init Source: https://docs.cocos.com/creator/2.4/api/zh/editor/asset-db.html Initializes the AssetDB module. An optional callback can be provided to be executed after initialization. ```APIDOC ## AssetDB.init ### Description Initializes the AssetDB module. An optional callback can be provided to be executed after initialization. ### Method `AssetDB.init([cb])` ### Parameters * **cb** (function) - Optional - The callback function to execute after initialization. ``` -------------------------------- ### get Source: https://docs.cocos.com/creator/2.4/api/zh/modules/js.html Defines a getter accessor for a property on an object using Object.defineProperty. ```APIDOC ## get ### Description Define get accessor, just help to call Object.defineProperty(...). ### Parameters - **obj** (Object) - The object on which to define the property. - **prop** (String) - The name of the property to define. - **getter** (Function) - The function to use as a getter. - **enumerable** (Boolean) - Whether the property will be included in for...in loops. - **configurable** (Boolean) - Whether the property can be deleted or its attributes changed. ``` -------------------------------- ### Editor.UI.index Source: https://docs.cocos.com/creator/2.4/api/zh/editor/renderer/ui/dom-utils.html Gets the index of a given HTML element within its parent. ```APIDOC ## Editor.UI.index (element) ### Description Get the index of the `element`. ### Parameters #### Path Parameters - **element** (HTMLElement) - Required - The HTML element to get the index of. ``` -------------------------------- ### Load Custom Asset with Downloader and Parser Source: https://docs.cocos.com/creator/2.4/api/zh/classes/AssetManager.html Loads a custom '.asset' file using the registered downloader and parser. Custom parameters like skin, model, username, and password are provided. ```javascript cc.assetManager.loadAny({ url: 'http://example.com/my.asset', skin: 'xxx', model: 'xxx', userName: 'xxx', password: 'xxx' }); ``` -------------------------------- ### getMass Source: https://docs.cocos.com/creator/2.4/api/zh/classes/RigidBody.html Gets the mass of the rigidbody. Returns a Number. Defined in cocos2d/core/physics/CCRigidBody.js. ```APIDOC ## getMass ### Description Gets the mass of the rigidbody. ### Returns * `Number` ``` -------------------------------- ### getMaxAudioInstance Source: https://docs.cocos.com/creator/2.4/api/zh/classes/audioEngine.html Gets the maximum number of instances allowed for a single audio clip. ```APIDOC ## getMaxAudioInstance ### Description Gets the maximum number of instances allowed for a single audio clip. ### Method `getMaxAudioInstance` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example ```javascript cc.audioEngine.getMaxAudioInstance(); ``` ### Response #### Success Response (200) - **maxInstances** (Number) - The maximum number of instances. #### Response Example ```json { "maxInstances": 3 } ``` ``` -------------------------------- ### resumeAll Source: https://docs.cocos.com/creator/2.4/api/zh/classes/audioEngine.html Resumes playback of all previously paused audio instances. ```APIDOC ## resumeAll ### Description Resumes playback of all previously paused audio instances. ### Method `resumeAll` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example ```javascript cc.audioEngine.resumeAll(); ``` ### Response #### Success Response (200) - None #### Response Example ```json {} ``` ``` -------------------------------- ### getJointList Source: https://docs.cocos.com/creator/2.4/api/zh/classes/RigidBody.html Gets all joints connected to this rigidbody. Returns an array of Joints. Defined in cocos2d/core/physics/CCRigidBody.js. ```APIDOC ## getJointList ### Description Gets all joints connected to this rigidbody. ### Returns * `[Joint]` ``` -------------------------------- ### getClassName Source: https://docs.cocos.com/creator/2.4/api/zh/modules/js.html Gets the class name of an object. If the object is a plain object ({}), it returns an empty string. ```APIDOC ## getClassName ### Description Get class name of the object, if object is just a {} (and which class named 'Object'), it will return "". (modified from the code from this stackoverflow post) ### Parameters - **objOrCtor** (Object | Function) - The instance or constructor of the object. ### Returns - String: The class name of the object. ``` -------------------------------- ### Editor.run(url, opts) Source: https://docs.cocos.com/creator/2.4/api/zh/editor/main/editor.html Runs the Editor by restoring the last window or opening a new one. ```APIDOC ## Editor.run(url, opts) ### Description Run the Editor by restoring last window or openning the a new one. ### Method `Editor.run(url, opts)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * `url` (string) - The url to load for default main window * `opts` (object) - The opts to used when constructing the default main window ``` -------------------------------- ### _initMetas Source: https://docs.cocos.com/creator/2.4/api/zh/editor/asset-db.html Pre-caches UUIDs from meta files. If a meta file does not exist, it will be created. This function requires the asset database, a file system path, and a callback function. ```APIDOC ## _initMetas(assetdb, fspath, cb) ### Description Pre-caches UUIDs from meta files. If a meta file does not exist, it will be created. ### Parameters #### Path Parameters - **assetdb** (object) - asset database - **fspath** (string) - file system path - **cb** (function) - callback function ``` -------------------------------- ### Get registered class by name Source: https://docs.cocos.com/creator/2.4/api/zh/modules/js.html Retrieves a class constructor that was previously registered by its class name. ```javascript cc.js.getClassByName(classname); ``` -------------------------------- ### Editor.UI.parentElement Source: https://docs.cocos.com/creator/2.4/api/zh/editor/renderer/ui/dom-utils.html Gets the parent element of a given HTML element, traversing shadow elements if necessary. ```APIDOC ## Editor.UI.parentElement (element) ### Description Get the parent element, it will go through the host if it is a shadow element. ### Parameters #### Path Parameters - **element** (HTMLElement) - Required - The HTML element to get the parent of. ``` -------------------------------- ### Editor.Window Static Methods Source: https://docs.cocos.com/creator/2.4/api/zh/editor/main/window.html Static methods for managing Editor.Window instances. ```APIDOC ## Editor.Window Static Methods ### `addWindow(win)` Adds an existing Editor.Window instance to the manager. ### `find(param)` Finds a window based on a given parameter. ### `removeWindow(win)` Removes an Editor.Window instance from the manager. ``` -------------------------------- ### resume Source: https://docs.cocos.com/creator/2.4/api/zh/classes/audioEngine.html Resumes playback of a specified audio instance. ```APIDOC ## resume ### Description Resumes playback of a specified audio instance. ### Method `resume` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **audioID** (Number) - The ID of the audio to resume (returned by `play`). ### Request Example ```javascript cc.audioEngine.resume(audioID); ``` ### Response #### Success Response (200) - None #### Response Example ```json {} ``` ``` -------------------------------- ### getInertia Source: https://docs.cocos.com/creator/2.4/api/zh/classes/RigidBody.html Gets the rotational inertia of the rigidbody about its local origin. Returns a Number. Defined in cocos2d/core/physics/CCRigidBody.js. ```APIDOC ## getInertia ### Description Gets the rotational inertia of the rigidbody about its local origin. ### Returns * `Number` ``` -------------------------------- ### getLinearVelocityFromWorldPoint Source: https://docs.cocos.com/creator/2.4/api/zh/classes/RigidBody.html Gets the linear velocity of a specified point on the rigidbody. Returns a Vec2. Defined in cocos2d/core/physics/CCRigidBody.js. ```APIDOC ## getLinearVelocityFromWorldPoint ### Description Gets the linear velocity of a specified point on the rigidbody. ### Returns * `Vec2` ### Parameters * `worldPoint` (Vec2) - a point in world coordinates. * `out` (Vec2, optional) - the receiving point ``` -------------------------------- ### Import Raw Files Source: https://docs.cocos.com/creator/2.4/api/zh/editor/asset-db.html Use the import method to bring raw files into the asset database at a specified URL. The callback function processes the results for each imported file. ```javascript Editor.assetdb.import( ['/User/user/foo.js', '/User/user/bar.js'], 'db://assets/foobar', function ( err, results ) { results.forEach(function ( result ) { // result.uuid // result.parentUuid // result.url // result.path // result.type }); }); ``` -------------------------------- ### getWorldCenter Source: https://docs.cocos.com/creator/2.4/api/zh/classes/RigidBody.html Gets the center of mass of the rigidbody in world coordinates. Returns a Vec2. Defined in cocos2d/core/physics/CCRigidBody.js. ```APIDOC ## getWorldCenter ### Description Gets the center of mass of the rigidbody in world coordinates. ### Returns * `Vec2` ``` -------------------------------- ### getLocalCenter Source: https://docs.cocos.com/creator/2.4/api/zh/classes/RigidBody.html Gets the center of mass of the rigidbody in local coordinates. Returns a Vec2. Defined in cocos2d/core/physics/CCRigidBody.js. ```APIDOC ## getLocalCenter ### Description Gets the center of mass of the rigidbody in local coordinates. ### Returns * `Vec2` ``` -------------------------------- ### Initialize Editor Source: https://docs.cocos.com/creator/2.4/api/zh/editor/main/editor.html Initializes the Editor module with various configuration options. Use this to set up internationalization, layout, main menu, profile paths, panel windows, selection types, and themes. ```javascript Editor.init(opts) ``` -------------------------------- ### getWorldRotation Source: https://docs.cocos.com/creator/2.4/api/zh/classes/RigidBody.html Gets the rotation value of the rigidbody in world coordinates. Returns a Number. Defined in cocos2d/core/physics/CCRigidBody.js. ```APIDOC ## getWorldRotation ### Description Gets the rotation value of the rigidbody in world coordinates. ### Returns * `Number` ``` -------------------------------- ### getWorldPosition Source: https://docs.cocos.com/creator/2.4/api/zh/classes/RigidBody.html Gets the origin value of the rigidbody in world coordinates. Returns a Vec2. Defined in cocos2d/core/physics/CCRigidBody.js. ```APIDOC ## getWorldPosition ### Description Gets the origin value of the rigidbody in world coordinates. ### Returns * `Vec2` ### Parameters * `out` (Vec2, optional) - the receiving point ``` -------------------------------- ### win.popupMenu Source: https://docs.cocos.com/creator/2.4/api/zh/editor/main/window.html Displays a context menu at the specified coordinates. ```APIDOC ## win.popupMenu (template[, x, y]) ### Description Shows a context menu at the given screen coordinates. ### Parameters * `template` (object) - The structure of the menu to display. * `x` (number, optional) - The x-coordinate for the menu popup. * `y` (number, optional) - The y-coordinate for the menu popup. ``` -------------------------------- ### Get Components in Children (Type) Source: https://docs.cocos.com/creator/2.4/api/zh/classes/BoxCollider3D.html Recursively finds all components of a specific type in the node and its children. ```javascript var sprites = node.getComponentsInChildren(cc.Sprite); ``` -------------------------------- ### Editor.loadPackagesAt(path, callback) Source: https://docs.cocos.com/creator/2.4/api/zh/editor/main/editor.html Loads all packages located at the specified path. ```APIDOC ## Editor.loadPackagesAt(path, callback) ### Description Load all packages under `path`. Once it done the `callback` will be invoked. ### Method `Editor.loadPackagesAt(path, callback)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * `path` (string) * `callback` (function) ``` -------------------------------- ### _getClassId Source: https://docs.cocos.com/creator/2.4/api/zh/modules/js.html Gets the class ID of an object or constructor. Can optionally return a temporary ID if available in the editor. ```APIDOC ## _getClassId ### Description Get class id of the object. ### Parameters - **obj** (Object | Function) - The instance or constructor of the object. - **allowTempId** (Boolean) - Whether to return a temporary ID if available in the editor. ### Returns - String: The class ID of the object. ``` -------------------------------- ### win.openDevTools Source: https://docs.cocos.com/creator/2.4/api/zh/editor/main/window.html Opens the developer tools for the window with specified options. ```APIDOC ## win.openDevTools (options) ### Description Opens the developer tools panel for this window. ### Parameters * `options` (object) - Configuration for opening devtools: * `mode` (string) - The dock state for the devtools. Can be `right`, `bottom`, `undocked`, or `detach`. Defaults to the last used state. ``` -------------------------------- ### Get registered class by ID Source: https://docs.cocos.com/creator/2.4/api/zh/modules/js.html Retrieves a class constructor that was previously registered using its unique ID. ```javascript cc.js._getClassById(classId); ``` -------------------------------- ### Director Methods Source: https://docs.cocos.com/creator/2.4/api/zh/classes/Director.html This section details the methods available on the cc.director singleton object for managing game flow, scenes, and rendering. ```APIDOC ## Director Methods ### Description Provides methods for managing game logic, scene transitions, rendering, and event handling. ### Methods * `convertToGL(point)`: Converts screen coordinates to WebGL View coordinates. * `convertToUI(point)`: Converts WebGL View coordinates to screen coordinates. * `end()`: Ends the director's life in the next frame. * `getWinSize()`: Gets the view size in points. * `getWinSizeInPixels()`: Gets the view size in pixels (resource resolution). * `pause()`: Pauses the running scene, stopping game logic but not rendering or UI response. * `runSceneImmediate(scene)`: Immediately switches to the specified scene. * `runScene(scene)`: Runs the specified scene. * `loadScene(sceneName)`: Loads a scene by its name. * `preloadScene(sceneName)`: Preloads a scene. * `resume()`: Resumes the game logic of a paused scene. * `setDepthTest(enable)`: Enables/disables depth testing (ineffective in Canvas mode). * `setClearColor(color)`: Sets the default clear color for the scene. * `getRunningScene()`: Gets the current running scene. * `getScene()`: Gets the current running scene. * `getAnimationInterval()`: Gets the time interval per frame. * `setAnimationInterval(interval)`: Sets the animation interval. This does not control the main loop. * `getDeltaTime()`: Gets the delta time of the previous frame. * `getTotalTime()`: Gets the total time elapsed since the game started in ms. * `getTotalFrames()`: Gets the total number of frames rendered since the director started. * `isPaused()`: Checks if the game is currently paused. * `getScheduler()`: Gets the cc.Scheduler associated with the director. * `setScheduler(scheduler)`: Sets the cc.Scheduler associated with the director. * `getActionManager()`: Gets the cc.ActionManager associated with the director. * `setActionManager(actionManager)`: Sets the cc.ActionManager associated with the director. * `getCollisionManager()`: Gets the cc.CollisionManager associated with the director. * `getPhysicsManager()`: Gets the cc.PhysicsManager associated with the director. * `getPhysics3DManager()`: Gets the cc.Physics3DManager associated with the director. * `hasEventListener(type)`: Checks if the event target has a callback registered for a specific event type. * `on(type, callback, target)`: Registers a callback for a specific event type on the event target. * `off(type, callback, target)`: Removes a previously registered event listener. * `targetOff(target)`: Removes all event listeners registered on the current EventTarget for a specific target. * `once(type, callback, target)`: Registers a callback for a specific event type that will be triggered and removed after the first invocation. * `dispatchEvent(event)`: Dispatches an event through the event object. * `clear()`: Clears recorded events. * `removeAll(type, target)`: Removes all callbacks registered for a specific event type or all callbacks registered for a specific target. * `emit(type, data)`: Emits a custom event by its type. ``` -------------------------------- ### Get property descriptor Source: https://docs.cocos.com/creator/2.4/api/zh/modules/js.html Retrieves the property descriptor for a given property name, searching up the prototype chain. ```javascript cc.js.getPropertyDescriptor(obj, name); ``` -------------------------------- ### Editor.Package.load Source: https://docs.cocos.com/creator/2.4/api/zh/editor/main/package.html Loads a package from the specified absolute path. A callback function is executed upon completion. ```APIDOC ## Editor.Package.load (path, callback) ### Description Loads a package at the given absolute path. The callback function is invoked once the loading process is finished. ### Parameters * `path` (string) - An absolute path pointing to the package folder. * `callback` (function) - A callback function to be executed upon completion. ``` -------------------------------- ### Get Components in Children (String) Source: https://docs.cocos.com/creator/2.4/api/zh/classes/BoxCollider3D.html Recursively finds all components with a specific class name in the node and its children. ```javascript var tests = node.getComponentsInChildren("Test"); ``` -------------------------------- ### Get Component in Children (Type) Source: https://docs.cocos.com/creator/2.4/api/zh/classes/BoxCollider3D.html Finds the first component of a specific type in the node's children. ```javascript var sprite = node.getComponentInChildren(cc.Sprite); ``` -------------------------------- ### AssetDB.create Source: https://docs.cocos.com/creator/2.4/api/zh/editor/asset-db.html Creates a new asset at the specified URL with the given data. An optional callback can be provided. ```APIDOC ## AssetDB.create ### Description Creates a new asset at the specified URL with the given data. An optional callback can be provided. ### Method `AssetDB.create(url, data, [cb])` ### Parameters * **url** (string) - The URL where the new asset will be created. * **data** (object) - The data for the new asset. * **cb** (function) - Optional - The callback function to execute after the asset is created. ``` -------------------------------- ### Get Asset Info by UUID Source: https://docs.cocos.com/creator/2.4/api/zh/classes/Bundle.html Retrieves the configuration information for an asset using its unique identifier (UUID). ```javascript var info = bundle.getAssetInfo('fcmR3XADNLgJ1ByKhqcC5Z'); ``` -------------------------------- ### AudioClip Methods Source: https://docs.cocos.com/creator/2.4/api/zh/classes/AudioClip.html This section outlines the methods available for interacting with AudioClip objects, including event handling, resource management, and destruction. ```APIDOC ## AudioClip Methods ### Description Provides methods for managing audio clips, including event handling, reference counting, and object destruction. ### Methods - **hasEventListener**(type: String): Boolean - Checks if the event target object has a callback registered for a specific event type. - **on**(type: String, callback: Function, target?: Object): void - Registers a callback for a specific event type on the event target. - **off**(type: String, callback?: Function, target?: Object): void - Removes an event listener previously registered with the same type, callback, target, or useCapture. If only the type is passed, all event listeners of that type will be removed. - **targetOff**(target: Object): void - Removes all event listeners registered on the current EventTarget for the specified target. - **once**(type: String, callback: Function, target?: Object): void - Registers a callback for a specific event type on the event target. The callback will be removed after being triggered the first time. - **dispatchEvent**(event: Event): void - Dispatches an event through the event object. - **clear**(): void - Clears all registered events. - **toString**(): String - Returns the URL of the resource. - **serialize**(): Object - Provides serialization data as required by AssetDB. - **createNode**(): Node - Creates a new node in the scene using this resource. - **_setRawAsset**(url: String): void - Sets the native filename for this resource. - **addRef**(): void - Increments the reference count of the resource. - **decRef**(): void - Decrements the reference count of the resource and attempts to auto-release it. - **destroy**(): Boolean - Destroys the object and releases all references it holds to other objects. - **_destruct**(): void - Clears all references within the instance. - **_onPreDestroy**(): void - Called before the object is destroyed. - **_serialize**(): Object - Customizes the serialization for this object. - **_deserialize**(data: Object): void - Initializes this object from custom serialized data. ``` -------------------------------- ### AssetDB~loadMetaByPath Source: https://docs.cocos.com/creator/2.4/api/zh/editor/asset-db.html Loads and returns the meta instance for a given file system path. ```APIDOC ## AssetDB~loadMetaByPath(fspath) ### Description Return meta instance by a given path. ### Method `AssetDB.loadMetaByPath(fspath)` ### Parameters #### Path Parameters - **fspath** (string) - Required - The file system path of the asset. ### Returns - `object` - The meta instance of the asset. ``` -------------------------------- ### Editor.UI.createStyleElement Source: https://docs.cocos.com/creator/2.4/api/zh/editor/renderer/ui/dom-utils.html Loads content from a URL and creates a style element to wrap it. ```APIDOC ## Editor.UI.createStyleElement (url) ### Description Loads `url` content and creates a style element to wrap it. ### Parameters #### Path Parameters - **url** (string) - Required - The URL of the style content to load. ``` -------------------------------- ### Get object class name Source: https://docs.cocos.com/creator/2.4/api/zh/modules/js.html Retrieves the class name of an object. Returns an empty string for plain objects. ```javascript cc.js.getClassName(objOrCtor); ``` -------------------------------- ### Editor.Window Instance Methods Source: https://docs.cocos.com/creator/2.4/api/zh/editor/main/window.html Methods available on an Editor.Window instance for controlling and interacting with a specific window. ```APIDOC ## Editor.Window Instance Methods ### `adjust(x, y, w, h)` Adjusts the window's position and size. ### `close()` Closes the window. ### `closeDevTools()` Closes the developer tools for the window. ### `dispose()` Disposes of the window resources. ### `emptyLayout()` Clears the current layout of the window. ### `focus()` Brings the window into focus. ### `forceClose()` Forces the closure of the window, bypassing confirmation. ### `hide()` Hides the window. ### `load(editorUrl, argv)` Loads a new URL within the window, optionally passing arguments. ### `minimize()` Minimizes the window. ### `openDevTools(options)` Opens the developer tools for the window with optional settings. ### `popupMenu(template[, x, y])` Displays a context menu at the specified coordinates. ### `resetLayout([url])` Resets the window's layout to a default or specified URL. ### `restore()` Restores the window from a minimized or maximized state. ### `show()` Shows the window. ### `send(message[, ...args])` Sends a message to the window, optionally with arguments. ``` -------------------------------- ### Get Audio State Source: https://docs.cocos.com/creator/2.4/api/zh/classes/audioEngine.html Retrieves the current playback state of an audio instance. Use the audioID returned from `play`. ```javascript var state = cc.audioEngine.getState(id); ``` -------------------------------- ### Get Audio Duration Source: https://docs.cocos.com/creator/2.4/api/zh/classes/audioEngine.html Retrieves the total duration in seconds of an audio clip. Use the audioID returned from `play`. ```javascript var time = cc.audioEngine.getDuration(id); ``` -------------------------------- ### Setting and Logging Object Name Source: https://docs.cocos.com/creator/2.4/api/zh/classes/CircleCollider.html Illustrates how to set a custom name for an object and then log it. This is useful for identifying objects in the scene or during debugging. ```javascript obj.name = "New Obj"; ``` ```javascript cc.log(obj.name); ``` -------------------------------- ### Load Any Asset with URL Source: https://docs.cocos.com/creator/2.4/api/zh/classes/AssetManager.html Loads a single asset using its URL. A callback function is provided to log the result. ```javascript cc.assetManager.loadAny({url: 'http://example.com/a.png'}, (err, img) => cc.log(img)); ``` -------------------------------- ### Get Component in Children (String) Source: https://docs.cocos.com/creator/2.4/api/zh/classes/BoxCollider3D.html Finds the first component of a specific class name in the node's children. ```javascript var Test = node.getComponentInChildren("Test"); ``` -------------------------------- ### AssetDB.import Source: https://docs.cocos.com/creator/2.4/api/zh/editor/asset-db.html Imports raw files into the asset database at a specified URL. ```APIDOC ## AssetDB.import(rawfiles, url, [cb]) ### Description Imports raw files into the asset database at a specified URL. ### Method `static` of `AssetDB` ### Parameters #### Path Parameters - **rawfiles** (`array`) - An array of file paths to import. - **url** (`string`) - The destination URL within the asset database. #### Callback - **cb** (`function`) - The callback function to handle the results. ### Example ```javascript Editor.assetdb.import( ['/User/user/foo.js', '/User/user/bar.js'], 'db://assets/foobar', function ( err, results ) { results.forEach(function ( result ) { // result.uuid // result.parentUuid // result.url // result.path // result.type }); }); ``` ``` -------------------------------- ### Get Audio Volume Source: https://docs.cocos.com/creator/2.4/api/zh/classes/audioEngine.html Retrieves the current volume of a specific audio playback instance. Use the audioID returned from `play`. ```javascript var volume = cc.audioEngine.getVolume(id); ``` -------------------------------- ### AssetDB.create Source: https://docs.cocos.com/creator/2.4/api/zh/editor/asset-db.html Creates a new asset at the specified URL with the given data. ```APIDOC ## AssetDB.create(url, data, [cb]) ### Description Creates a new asset at the specified URL with the given data. ### Method `static` of `AssetDB` ### Parameters #### Path Parameters - **url** (`string`) - The URL where the asset will be created. - **data** (`string`) - The data content for the new asset. #### Callback - **cb** (`function`) - The callback function to handle the results. ### Example ```javascript Editor.assetdb.create( 'db://assets/foo/bar.js', data, function ( err, results ) { results.forEach(function ( result ) { // result.uuid // result.parentUuid // result.url // result.path // result.type }); }); ``` ``` -------------------------------- ### Get Node Position Source: https://docs.cocos.com/creator/2.4/api/zh/classes/PrivateNode.html Retrieves the node's position in the parent's coordinate system. This property is of type Vec3. ```javascript cc.log("Node Position: " + node.position); ```