From d22eea9db3ba420a2612d1863bcb25f218d75b50 Mon Sep 17 00:00:00 2001 From: ivanYYH <971586529@qq.com> Date: Tue, 29 Nov 2022 23:19:03 +0800 Subject: [PATCH] change ts name --- ...ndView.ts => EndView_L5R3_GuessingGame.ts} | 2 +- ...meta => EndView_L5R3_GuessingGame.ts.meta} | 0 ...board.ts => Keyboard_L5R3_GuessingGame.ts} | 0 ...eta => Keyboard_L5R3_GuessingGame.ts.meta} | 0 .../scene/L5R3_GuessingGame.ts | 19 +- .../script/{AI.ts => AI_L5R3_GuessingGame.ts} | 8 +- ...I.ts.meta => AI_L5R3_GuessingGame.ts.meta} | 0 ...r.ts => LoadingLayer_L5R3_GuessingGame.ts} | 4 +- ...=> LoadingLayer_L5R3_GuessingGame.ts.meta} | 0 .../script/MyCocosSceneComponent.ts | 4 +- .../script/MyCocosSceneComponent.ts.meta | 2 +- ...MyCocosSceneComponent_L5R3_GuessingGame.ts | 184 + ...osSceneComponent_L5R3_GuessingGame.ts.meta | 9 + ....ts => NetworkHelper_L5R3_GuessingGame.ts} | 2 +- ...> NetworkHelper_L5R3_GuessingGame.ts.meta} | 0 ...> PlayerOffLineLayer_L5R3_GuessingGame.js} | 0 ...yerOffLineLayer_L5R3_GuessingGame.js.meta} | 0 ...{Server.ts => Server_L5R3_GuessingGame.ts} | 12 +- ....meta => Server_L5R3_GuessingGame.ts.meta} | 0 ...ta.ts => defaultData_L5R3_GuessingGame.ts} | 0 ... => defaultData_L5R3_GuessingGame.ts.meta} | 0 ...sgDate.ts => msgDate_L5R3_GuessingGame.ts} | 2 +- ...meta => msgDate_L5R3_GuessingGame.ts.meta} | 0 ...sgType.ts => msgType_L5R3_GuessingGame.ts} | 0 ...meta => msgType_L5R3_GuessingGame.ts.meta} | 0 .../{util.ts => util_L5R3_GuessingGame.ts} | 0 ...ts.meta => util_L5R3_GuessingGame.ts.meta} | 0 creator.d.ts | 17855 ++++++++-------- tsconfig.json | 1 - 29 files changed, 9062 insertions(+), 9042 deletions(-) rename assets/L5R3_GuessingGame/prefabs/endView/{EndView.ts => EndView_L5R3_GuessingGame.ts} (97%) rename assets/L5R3_GuessingGame/prefabs/endView/{EndView.ts.meta => EndView_L5R3_GuessingGame.ts.meta} (100%) rename assets/L5R3_GuessingGame/prefabs/keyboards/{Keyboard.ts => Keyboard_L5R3_GuessingGame.ts} (100%) rename assets/L5R3_GuessingGame/prefabs/keyboards/{Keyboard.ts.meta => Keyboard_L5R3_GuessingGame.ts.meta} (100%) rename assets/L5R3_GuessingGame/script/{AI.ts => AI_L5R3_GuessingGame.ts} (88%) rename assets/L5R3_GuessingGame/script/{AI.ts.meta => AI_L5R3_GuessingGame.ts.meta} (100%) rename assets/L5R3_GuessingGame/script/{BoardGame_yyh_LoadingLayer.ts => LoadingLayer_L5R3_GuessingGame.ts} (97%) rename assets/L5R3_GuessingGame/script/{BoardGame_yyh_LoadingLayer.ts.meta => LoadingLayer_L5R3_GuessingGame.ts.meta} (100%) create mode 100644 assets/L5R3_GuessingGame/script/MyCocosSceneComponent_L5R3_GuessingGame.ts create mode 100644 assets/L5R3_GuessingGame/script/MyCocosSceneComponent_L5R3_GuessingGame.ts.meta rename assets/L5R3_GuessingGame/script/{NetworkHelper.ts => NetworkHelper_L5R3_GuessingGame.ts} (99%) rename assets/L5R3_GuessingGame/script/{NetworkHelper.ts.meta => NetworkHelper_L5R3_GuessingGame.ts.meta} (100%) rename assets/L5R3_GuessingGame/script/{BoardGame_yyh_PlayerOffLineLayer.js => PlayerOffLineLayer_L5R3_GuessingGame.js} (100%) rename assets/L5R3_GuessingGame/script/{BoardGame_yyh_PlayerOffLineLayer.js.meta => PlayerOffLineLayer_L5R3_GuessingGame.js.meta} (100%) rename assets/L5R3_GuessingGame/script/{Server.ts => Server_L5R3_GuessingGame.ts} (95%) rename assets/L5R3_GuessingGame/script/{Server.ts.meta => Server_L5R3_GuessingGame.ts.meta} (100%) rename assets/L5R3_GuessingGame/script/{defaultData.ts => defaultData_L5R3_GuessingGame.ts} (100%) rename assets/L5R3_GuessingGame/script/{defaultData.ts.meta => defaultData_L5R3_GuessingGame.ts.meta} (100%) rename assets/L5R3_GuessingGame/script/{msgDate.ts => msgDate_L5R3_GuessingGame.ts} (95%) rename assets/L5R3_GuessingGame/script/{msgDate.ts.meta => msgDate_L5R3_GuessingGame.ts.meta} (100%) rename assets/L5R3_GuessingGame/script/{msgType.ts => msgType_L5R3_GuessingGame.ts} (100%) rename assets/L5R3_GuessingGame/script/{msgType.ts.meta => msgType_L5R3_GuessingGame.ts.meta} (100%) rename assets/L5R3_GuessingGame/script/{util.ts => util_L5R3_GuessingGame.ts} (100%) rename assets/L5R3_GuessingGame/script/{util.ts.meta => util_L5R3_GuessingGame.ts.meta} (100%) diff --git a/assets/L5R3_GuessingGame/prefabs/endView/EndView.ts b/assets/L5R3_GuessingGame/prefabs/endView/EndView_L5R3_GuessingGame.ts similarity index 97% rename from assets/L5R3_GuessingGame/prefabs/endView/EndView.ts rename to assets/L5R3_GuessingGame/prefabs/endView/EndView_L5R3_GuessingGame.ts index a066375..7fb555b 100644 --- a/assets/L5R3_GuessingGame/prefabs/endView/EndView.ts +++ b/assets/L5R3_GuessingGame/prefabs/endView/EndView_L5R3_GuessingGame.ts @@ -5,7 +5,7 @@ // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html -import { asyncDelay } from "../../script/util"; +import { asyncDelay } from "../../script/util_L5R3_GuessingGame"; const { ccclass, property } = cc._decorator; diff --git a/assets/L5R3_GuessingGame/prefabs/endView/EndView.ts.meta b/assets/L5R3_GuessingGame/prefabs/endView/EndView_L5R3_GuessingGame.ts.meta similarity index 100% rename from assets/L5R3_GuessingGame/prefabs/endView/EndView.ts.meta rename to assets/L5R3_GuessingGame/prefabs/endView/EndView_L5R3_GuessingGame.ts.meta diff --git a/assets/L5R3_GuessingGame/prefabs/keyboards/Keyboard.ts b/assets/L5R3_GuessingGame/prefabs/keyboards/Keyboard_L5R3_GuessingGame.ts similarity index 100% rename from assets/L5R3_GuessingGame/prefabs/keyboards/Keyboard.ts rename to assets/L5R3_GuessingGame/prefabs/keyboards/Keyboard_L5R3_GuessingGame.ts diff --git a/assets/L5R3_GuessingGame/prefabs/keyboards/Keyboard.ts.meta b/assets/L5R3_GuessingGame/prefabs/keyboards/Keyboard_L5R3_GuessingGame.ts.meta similarity index 100% rename from assets/L5R3_GuessingGame/prefabs/keyboards/Keyboard.ts.meta rename to assets/L5R3_GuessingGame/prefabs/keyboards/Keyboard_L5R3_GuessingGame.ts.meta diff --git a/assets/L5R3_GuessingGame/scene/L5R3_GuessingGame.ts b/assets/L5R3_GuessingGame/scene/L5R3_GuessingGame.ts index 7dd1f47..1d4ecfb 100644 --- a/assets/L5R3_GuessingGame/scene/L5R3_GuessingGame.ts +++ b/assets/L5R3_GuessingGame/scene/L5R3_GuessingGame.ts @@ -1,14 +1,13 @@ -import { res } from "../../../form_angular/src/app/play/resources"; -import EndView from "../prefabs/endView/EndView"; -import Keyboard from "../prefabs/keyboards/Keyboard"; -import LoadingLayer from "../script/BoardGame_yyh_LoadingLayer"; -import MsgData from "../script/msgDate"; -import { MsgType, PlayerData, resultType } from "../script/msgType"; -import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent"; -import { NetworkHelper } from "../script/NetworkHelper"; -import { GameServer } from "../script/Server"; -import { asyncTweenTo, asyncDelay, onHomeworkFinish, asyncPlayDragonBoneAnimation } from "../script/util"; +import EndView from "../prefabs/endView/EndView_L5R3_GuessingGame"; +import Keyboard from "../prefabs/keyboards/Keyboard_L5R3_GuessingGame"; +import LoadingLayer from "../script/LoadingLayer_L5R3_GuessingGame"; +import MsgData from "../script/msgDate_L5R3_GuessingGame"; +import { MsgType, PlayerData, resultType } from "../script/msgType_L5R3_GuessingGame"; +import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent_L5R3_GuessingGame"; +import { NetworkHelper } from "../script/NetworkHelper_L5R3_GuessingGame"; +import { GameServer } from "../script/Server_L5R3_GuessingGame"; +import { asyncTweenTo, asyncDelay, onHomeworkFinish, asyncPlayDragonBoneAnimation } from "../script/util_L5R3_GuessingGame"; const DOLOG = false; diff --git a/assets/L5R3_GuessingGame/script/AI.ts b/assets/L5R3_GuessingGame/script/AI_L5R3_GuessingGame.ts similarity index 88% rename from assets/L5R3_GuessingGame/script/AI.ts rename to assets/L5R3_GuessingGame/script/AI_L5R3_GuessingGame.ts index c7ec72b..cb73019 100644 --- a/assets/L5R3_GuessingGame/script/AI.ts +++ b/assets/L5R3_GuessingGame/script/AI_L5R3_GuessingGame.ts @@ -1,7 +1,7 @@ -import MsgData from "./msgDate"; -import { MsgType } from "./msgType"; -import { NetworkHelper } from "./NetworkHelper"; -import { asyncDelay } from "./util"; +import MsgData from "./msgDate_L5R3_GuessingGame"; +import { MsgType } from "./msgType_L5R3_GuessingGame"; +import { NetworkHelper } from "./NetworkHelper_L5R3_GuessingGame"; +import { asyncDelay } from "./util_L5R3_GuessingGame"; const countDelay = 4; // è·ç¦»ä¸Šæ¬¡ç”对 é—´éš”4s 开始ç”题下一题 export class AI { diff --git a/assets/L5R3_GuessingGame/script/AI.ts.meta b/assets/L5R3_GuessingGame/script/AI_L5R3_GuessingGame.ts.meta similarity index 100% rename from assets/L5R3_GuessingGame/script/AI.ts.meta rename to assets/L5R3_GuessingGame/script/AI_L5R3_GuessingGame.ts.meta diff --git a/assets/L5R3_GuessingGame/script/BoardGame_yyh_LoadingLayer.ts b/assets/L5R3_GuessingGame/script/LoadingLayer_L5R3_GuessingGame.ts similarity index 97% rename from assets/L5R3_GuessingGame/script/BoardGame_yyh_LoadingLayer.ts rename to assets/L5R3_GuessingGame/script/LoadingLayer_L5R3_GuessingGame.ts index ef3778c..3c112fb 100644 --- a/assets/L5R3_GuessingGame/script/BoardGame_yyh_LoadingLayer.ts +++ b/assets/L5R3_GuessingGame/script/LoadingLayer_L5R3_GuessingGame.ts @@ -1,4 +1,4 @@ -import { asyncPlayDragonBoneAnimation } from "./util"; +import { asyncPlayDragonBoneAnimation } from "./util_L5R3_GuessingGame"; const { ccclass, property } = cc._decorator; @@ -225,7 +225,7 @@ export default class LoadingLayer extends cc.Component { } this.stopCurrentPlayedAudio(); cc.assetManager.loadRemote(audio_url.toLowerCase(), (err, audioClip) => { - const audioId = cc.audioEngine.play(audioClip, false, 0.8); + const audioId = cc.audioEngine.play(<cc.AudioClip>audioClip, false, 0.8); this.currentPlayedAudioId = audioId; if (cb) { cc.audioEngine.setFinishCallback(audioId, cb); diff --git a/assets/L5R3_GuessingGame/script/BoardGame_yyh_LoadingLayer.ts.meta b/assets/L5R3_GuessingGame/script/LoadingLayer_L5R3_GuessingGame.ts.meta similarity index 100% rename from assets/L5R3_GuessingGame/script/BoardGame_yyh_LoadingLayer.ts.meta rename to assets/L5R3_GuessingGame/script/LoadingLayer_L5R3_GuessingGame.ts.meta diff --git a/assets/L5R3_GuessingGame/script/MyCocosSceneComponent.ts b/assets/L5R3_GuessingGame/script/MyCocosSceneComponent.ts index e57b408..7a779a2 100644 --- a/assets/L5R3_GuessingGame/script/MyCocosSceneComponent.ts +++ b/assets/L5R3_GuessingGame/script/MyCocosSceneComponent.ts @@ -1,4 +1,4 @@ -import { defaultData } from "../script/defaultData"; +import { defaultData } from "../script/defaultData_L5R3_GuessingGame"; export class MyCocosSceneComponent extends cc.Component { @@ -170,7 +170,7 @@ export class MyCocosSceneComponent extends cc.Component { playAudioByUrl(audio_url, cb = null) { if (audio_url) { cc.assetManager.loadRemote(audio_url, (err, audioClip) => { - const audioId = cc.audioEngine.play(audioClip, false, 0.8); + const audioId = cc.audioEngine.play(<cc.AudioClip>audioClip, false, 0.8); if (cb) { cc.audioEngine.setFinishCallback(audioId, () => { cb(); diff --git a/assets/L5R3_GuessingGame/script/MyCocosSceneComponent.ts.meta b/assets/L5R3_GuessingGame/script/MyCocosSceneComponent.ts.meta index 336cd49..3922c88 100644 --- a/assets/L5R3_GuessingGame/script/MyCocosSceneComponent.ts.meta +++ b/assets/L5R3_GuessingGame/script/MyCocosSceneComponent.ts.meta @@ -1,6 +1,6 @@ { "ver": "1.0.8", - "uuid": "8bee291d-4fce-43b1-87b2-0937d33242fa", + "uuid": "a6164f0e-b19d-4b21-86b1-57f714db3ba1", "isPlugin": false, "loadPluginInWeb": true, "loadPluginInNative": true, diff --git a/assets/L5R3_GuessingGame/script/MyCocosSceneComponent_L5R3_GuessingGame.ts b/assets/L5R3_GuessingGame/script/MyCocosSceneComponent_L5R3_GuessingGame.ts new file mode 100644 index 0000000..7a779a2 --- /dev/null +++ b/assets/L5R3_GuessingGame/script/MyCocosSceneComponent_L5R3_GuessingGame.ts @@ -0,0 +1,184 @@ +import { defaultData } from "../script/defaultData_L5R3_GuessingGame"; + +export class MyCocosSceneComponent extends cc.Component { + + // 生命周期 onLoad + onLoad() { + this.initSceneData(); + this.initSize(); + } + + _imageResList = null; + _audioResList = null; + _animaResList = null; + initSceneData() { + this._imageResList = []; + this._audioResList = []; + this._animaResList = []; + } + + _designSize = null; // 设计分辨率 + _frameSize = null; // å±å¹•分辨率 + _mapScaleMin = null; // 场景ä¸å¸¸ç”¨ç¼©æ”¾ï¼ˆå–大值) + _mapScaleMax = null; // 场景ä¸å¸¸ç”¨ç¼©æ”¾ï¼ˆå–å°å€¼ï¼‰ + _cocosScale = null; // cocos 自缩放 (较少用到) + initSize() { + // 注æ„cc.winSizeåªæœ‰åœ¨é€‚é…åŽ(修改fitHeight/fitWidthåŽ)æ‰èƒ½èŽ·å–到æ£ç¡®çš„值,å› æ¤ä½¿ç”¨cc.getFrameSize()æ¥èŽ·å–åˆå§‹çš„å±å¹•å¤§å° + let screen_size = cc.view.getFrameSize().width / cc.view.getFrameSize().height + let design_size = cc.Canvas.instance.designResolution.width / cc.Canvas.instance.designResolution.height + let f = screen_size >= design_size + cc.Canvas.instance.fitHeight = f + cc.Canvas.instance.fitWidth = !f + + const frameSize = cc.view.getFrameSize(); + this._frameSize = frameSize; + + this._designSize = cc.view.getDesignResolutionSize(); + + let sx = cc.winSize.width / frameSize.width; + let sy = cc.winSize.height / frameSize.height; + this._cocosScale = Math.min(sx, sy); + + sx = frameSize.width / this._designSize.width; + sy = frameSize.height / this._designSize.height; + this._mapScaleMin = Math.min(sx, sy) * this._cocosScale; + this._mapScaleMax = Math.max(sx, sy) * this._cocosScale; + + cc.director['_scene'].width = frameSize.width; + cc.director['_scene'].height = frameSize.height; + } + + data = null; + + // 生命周期 start + start() { + if (window && (<any>window).courseware && (<any>window).courseware.getData) { + (<any>window).courseware.getData((data) => { + this.log('data:' + data); + this.data = data || this.getDefaultData(); + this.data = JSON.parse(JSON.stringify(this.data)); + this.preloadItem(); + }) + } else { + this.data = this.getDefaultData(); + this.preloadItem(); + } + } + + getDefaultData() { + return defaultData; + } + + preloadItem() { + this.addPreloadImage(); + this.addPreloadAudio(); + this.addPreloadAnima(); + this.preload(); + } + + addPreloadImage() { + } + + addPreloadAudio() { + } + + addPreloadAnima() { + } + + preload() { + const preloadArr = this._imageResList.concat(this._audioResList).concat(this._animaResList); + cc.assetManager.loadAny(preloadArr, null, null, (err, data) => { + + if (window && window["air"]) { + // window["air"].onCourseInScreen = (next) => { + // window["air"].isCourseInScreen = true; + // this.onLoadEnd(); + // next(); + // }; + this.onLoadEnd(); + window["air"].hideAirClassLoading(); + } else { + this.onLoadEnd(); + } + + cc.debug.setDisplayStats(false); + }); + } + + log(str) { + const node = cc.find('middleLayer'); + if (node) { + node.getComponent('middleLayer').log(str); + } else { + cc.log(str); + } + } + + onLoadEnd() { + + } + + + + + + + + + + + + + + + + + // ------------------------------------------------ + getSprNode(resName) { + let nodef = cc.find('Canvas/res/img/' + resName) + if (!nodef) { + console.warn("no name res = " + resName); + return; + } + const sf = nodef.getComponent(cc.Sprite).spriteFrame; + const node = new cc.Node(); + node.addComponent(cc.Sprite).spriteFrame = sf; + return node; + } + + + getSpriteFrimeByUrl(url, cb) { + cc.loader.load({ url }, (err, img) => { + const spriteFrame = new cc.SpriteFrame(img) + if (cb) { + cb(spriteFrame); + } + }) + } + + getSprNodeByUrl(url, cb) { + const node = new cc.Node(); + const spr = node.addComponent(cc.Sprite); + this.getSpriteFrimeByUrl(url, (sf) => { + spr.spriteFrame = sf; + if (cb) { + cb(node); + } + }) + } + + playAudioByUrl(audio_url, cb = null) { + if (audio_url) { + cc.assetManager.loadRemote(audio_url, (err, audioClip) => { + const audioId = cc.audioEngine.play(<cc.AudioClip>audioClip, false, 0.8); + if (cb) { + cc.audioEngine.setFinishCallback(audioId, () => { + cb(); + }); + } + }); + } else { + cb && cb(); + } + } +} \ No newline at end of file diff --git a/assets/L5R3_GuessingGame/script/MyCocosSceneComponent_L5R3_GuessingGame.ts.meta b/assets/L5R3_GuessingGame/script/MyCocosSceneComponent_L5R3_GuessingGame.ts.meta new file mode 100644 index 0000000..336cd49 --- /dev/null +++ b/assets/L5R3_GuessingGame/script/MyCocosSceneComponent_L5R3_GuessingGame.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.8", + "uuid": "8bee291d-4fce-43b1-87b2-0937d33242fa", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/assets/L5R3_GuessingGame/script/NetworkHelper.ts b/assets/L5R3_GuessingGame/script/NetworkHelper_L5R3_GuessingGame.ts similarity index 99% rename from assets/L5R3_GuessingGame/script/NetworkHelper.ts rename to assets/L5R3_GuessingGame/script/NetworkHelper_L5R3_GuessingGame.ts index c936e23..9f4c340 100644 --- a/assets/L5R3_GuessingGame/script/NetworkHelper.ts +++ b/assets/L5R3_GuessingGame/script/NetworkHelper_L5R3_GuessingGame.ts @@ -1,4 +1,4 @@ -import { RandomInt } from "./util"; +import { RandomInt } from "./util_L5R3_GuessingGame"; export class NetworkHelper { _eventListeners: any = {}; diff --git a/assets/L5R3_GuessingGame/script/NetworkHelper.ts.meta b/assets/L5R3_GuessingGame/script/NetworkHelper_L5R3_GuessingGame.ts.meta similarity index 100% rename from assets/L5R3_GuessingGame/script/NetworkHelper.ts.meta rename to assets/L5R3_GuessingGame/script/NetworkHelper_L5R3_GuessingGame.ts.meta diff --git a/assets/L5R3_GuessingGame/script/BoardGame_yyh_PlayerOffLineLayer.js b/assets/L5R3_GuessingGame/script/PlayerOffLineLayer_L5R3_GuessingGame.js similarity index 100% rename from assets/L5R3_GuessingGame/script/BoardGame_yyh_PlayerOffLineLayer.js rename to assets/L5R3_GuessingGame/script/PlayerOffLineLayer_L5R3_GuessingGame.js diff --git a/assets/L5R3_GuessingGame/script/BoardGame_yyh_PlayerOffLineLayer.js.meta b/assets/L5R3_GuessingGame/script/PlayerOffLineLayer_L5R3_GuessingGame.js.meta similarity index 100% rename from assets/L5R3_GuessingGame/script/BoardGame_yyh_PlayerOffLineLayer.js.meta rename to assets/L5R3_GuessingGame/script/PlayerOffLineLayer_L5R3_GuessingGame.js.meta diff --git a/assets/L5R3_GuessingGame/script/Server.ts b/assets/L5R3_GuessingGame/script/Server_L5R3_GuessingGame.ts similarity index 95% rename from assets/L5R3_GuessingGame/script/Server.ts rename to assets/L5R3_GuessingGame/script/Server_L5R3_GuessingGame.ts index 797c6fe..a537d61 100644 --- a/assets/L5R3_GuessingGame/script/Server.ts +++ b/assets/L5R3_GuessingGame/script/Server_L5R3_GuessingGame.ts @@ -1,13 +1,13 @@ -import { asyncDelay, RandomInt } from "../script/util"; -import { AI } from "./AI"; -import MsgData from "./msgDate"; -import { MsgType, PlayerData, resultType } from "./msgType"; -import { NetworkHelper } from "./NetworkHelper"; +import { asyncDelay, RandomInt } from "../script/util_L5R3_GuessingGame"; +import { AI } from "./AI_L5R3_GuessingGame"; +import MsgData from "./msgDate_L5R3_GuessingGame"; +import { MsgType, PlayerData, resultType } from "./msgType_L5R3_GuessingGame"; +import { NetworkHelper } from "./NetworkHelper_L5R3_GuessingGame"; export class GameServer { playerList = []; playerMaxNumber = 0; - networkHelper: NetworkHelper = null; + networkHelper: NetworkHelper; nameList = [ "Chris", "Benny", diff --git a/assets/L5R3_GuessingGame/script/Server.ts.meta b/assets/L5R3_GuessingGame/script/Server_L5R3_GuessingGame.ts.meta similarity index 100% rename from assets/L5R3_GuessingGame/script/Server.ts.meta rename to assets/L5R3_GuessingGame/script/Server_L5R3_GuessingGame.ts.meta diff --git a/assets/L5R3_GuessingGame/script/defaultData.ts b/assets/L5R3_GuessingGame/script/defaultData_L5R3_GuessingGame.ts similarity index 100% rename from assets/L5R3_GuessingGame/script/defaultData.ts rename to assets/L5R3_GuessingGame/script/defaultData_L5R3_GuessingGame.ts diff --git a/assets/L5R3_GuessingGame/script/defaultData.ts.meta b/assets/L5R3_GuessingGame/script/defaultData_L5R3_GuessingGame.ts.meta similarity index 100% rename from assets/L5R3_GuessingGame/script/defaultData.ts.meta rename to assets/L5R3_GuessingGame/script/defaultData_L5R3_GuessingGame.ts.meta diff --git a/assets/L5R3_GuessingGame/script/msgDate.ts b/assets/L5R3_GuessingGame/script/msgDate_L5R3_GuessingGame.ts similarity index 95% rename from assets/L5R3_GuessingGame/script/msgDate.ts rename to assets/L5R3_GuessingGame/script/msgDate_L5R3_GuessingGame.ts index 455e7d4..2f46794 100644 --- a/assets/L5R3_GuessingGame/script/msgDate.ts +++ b/assets/L5R3_GuessingGame/script/msgDate_L5R3_GuessingGame.ts @@ -1,4 +1,4 @@ -import { MsgType, PlayerData } from "./msgType"; +import { MsgType, PlayerData } from "./msgType_L5R3_GuessingGame"; export default class MsgData { diff --git a/assets/L5R3_GuessingGame/script/msgDate.ts.meta b/assets/L5R3_GuessingGame/script/msgDate_L5R3_GuessingGame.ts.meta similarity index 100% rename from assets/L5R3_GuessingGame/script/msgDate.ts.meta rename to assets/L5R3_GuessingGame/script/msgDate_L5R3_GuessingGame.ts.meta diff --git a/assets/L5R3_GuessingGame/script/msgType.ts b/assets/L5R3_GuessingGame/script/msgType_L5R3_GuessingGame.ts similarity index 100% rename from assets/L5R3_GuessingGame/script/msgType.ts rename to assets/L5R3_GuessingGame/script/msgType_L5R3_GuessingGame.ts diff --git a/assets/L5R3_GuessingGame/script/msgType.ts.meta b/assets/L5R3_GuessingGame/script/msgType_L5R3_GuessingGame.ts.meta similarity index 100% rename from assets/L5R3_GuessingGame/script/msgType.ts.meta rename to assets/L5R3_GuessingGame/script/msgType_L5R3_GuessingGame.ts.meta diff --git a/assets/L5R3_GuessingGame/script/util.ts b/assets/L5R3_GuessingGame/script/util_L5R3_GuessingGame.ts similarity index 100% rename from assets/L5R3_GuessingGame/script/util.ts rename to assets/L5R3_GuessingGame/script/util_L5R3_GuessingGame.ts diff --git a/assets/L5R3_GuessingGame/script/util.ts.meta b/assets/L5R3_GuessingGame/script/util_L5R3_GuessingGame.ts.meta similarity index 100% rename from assets/L5R3_GuessingGame/script/util.ts.meta rename to assets/L5R3_GuessingGame/script/util_L5R3_GuessingGame.ts.meta diff --git a/creator.d.ts b/creator.d.ts index baca55f..72c6e91 100644 --- a/creator.d.ts +++ b/creator.d.ts @@ -101,115 +101,6 @@ declare namespace cc { */ export function catmullRomBy(dt: number, points: any[]): ActionInterval; /** - !#en Show the Node. - !#zh ç«‹å³æ˜¾ç¤ºã€‚ - - @example - ```js - // example - var showAction = cc.show(); - ``` - */ - export function show(): ActionInstant; - /** - !#en Hide the node. - !#zh ç«‹å³éšè—。 - - @example - ```js - // example - var hideAction = cc.hide(); - ``` - */ - export function hide(): ActionInstant; - /** - !#en Toggles the visibility of a node. - !#zh 显éšçжæ€åˆ‡æ¢ã€‚ - - @example - ```js - // example - var toggleVisibilityAction = cc.toggleVisibility(); - ``` - */ - export function toggleVisibility(): ActionInstant; - /** - !#en Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing. - !#zh 从父节点移除自身。 - @param isNeedCleanUp isNeedCleanUp - - @example - ```js - // example - var removeSelfAction = cc.removeSelf(); - ``` - */ - export function removeSelf(isNeedCleanUp ?: boolean): ActionInstant; - /** - !#en Destroy self - !#zh 创建一个销æ¯è‡ªèº«çš„动作。 - - @example - ```js - var destroySelfAction = cc.destroySelf(); - ``` - */ - export function destroySelf(): ActionInstant; - /** - !#en Create a FlipX action to flip or unflip the target. - !#zh X轴翻转。 - @param flip Indicate whether the target should be flipped or not - - @example - ```js - var flipXAction = cc.flipX(true); - ``` - */ - export function flipX(flip: boolean): ActionInstant; - /** - !#en Create a FlipY action to flip or unflip the target. - !#zh Y轴翻转。 - @param flip flip - - @example - ```js - var flipYAction = cc.flipY(true); - ``` - */ - export function flipY(flip: boolean): ActionInstant; - /** - !#en Creates a Place action with a position. - !#zh æ”¾ç½®åœ¨ç›®æ ‡ä½ç½®ã€‚ - @param pos pos - @param y y - - @example - ```js - // example - var placeAction = cc.place(cc.v2(200, 200)); - var placeAction = cc.place(200, 200); - ``` - */ - export function place(pos: Vec2|number, y?: number): ActionInstant; - /** - !#en Creates the action with the callback. - !#zh 执行回调函数。 - @param selector selector - @param selectorTarget selectorTarget - @param data data for function, it accepts all data types. - - @example - ```js - // example - // CallFunc without data - var finish = cc.callFunc(this.removeSprite, this); - - // CallFunc with data - var finish = cc.callFunc(this.removeFromParentAndCleanup, this._grossini, true); - ``` - */ - export function callFunc(selector: Function, selectorTarget?: any, data?: any): ActionInstant; - /** !#en Creates the action easing object with the rate parameter. <br /> From slow to fast. @@ -751,6 +642,115 @@ declare namespace cc { */ export function easeCubicActionInOut(): any; /** + !#en Show the Node. + !#zh ç«‹å³æ˜¾ç¤ºã€‚ + + @example + ```js + // example + var showAction = cc.show(); + ``` + */ + export function show(): ActionInstant; + /** + !#en Hide the node. + !#zh ç«‹å³éšè—。 + + @example + ```js + // example + var hideAction = cc.hide(); + ``` + */ + export function hide(): ActionInstant; + /** + !#en Toggles the visibility of a node. + !#zh 显éšçжæ€åˆ‡æ¢ã€‚ + + @example + ```js + // example + var toggleVisibilityAction = cc.toggleVisibility(); + ``` + */ + export function toggleVisibility(): ActionInstant; + /** + !#en Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing. + !#zh 从父节点移除自身。 + @param isNeedCleanUp isNeedCleanUp + + @example + ```js + // example + var removeSelfAction = cc.removeSelf(); + ``` + */ + export function removeSelf(isNeedCleanUp ?: boolean): ActionInstant; + /** + !#en Destroy self + !#zh 创建一个销æ¯è‡ªèº«çš„动作。 + + @example + ```js + var destroySelfAction = cc.destroySelf(); + ``` + */ + export function destroySelf(): ActionInstant; + /** + !#en Create a FlipX action to flip or unflip the target. + !#zh X轴翻转。 + @param flip Indicate whether the target should be flipped or not + + @example + ```js + var flipXAction = cc.flipX(true); + ``` + */ + export function flipX(flip: boolean): ActionInstant; + /** + !#en Create a FlipY action to flip or unflip the target. + !#zh Y轴翻转。 + @param flip flip + + @example + ```js + var flipYAction = cc.flipY(true); + ``` + */ + export function flipY(flip: boolean): ActionInstant; + /** + !#en Creates a Place action with a position. + !#zh æ”¾ç½®åœ¨ç›®æ ‡ä½ç½®ã€‚ + @param pos pos + @param y y + + @example + ```js + // example + var placeAction = cc.place(cc.v2(200, 200)); + var placeAction = cc.place(200, 200); + ``` + */ + export function place(pos: Vec2|number, y?: number): ActionInstant; + /** + !#en Creates the action with the callback. + !#zh 执行回调函数。 + @param selector selector + @param selectorTarget selectorTarget + @param data data for function, it accepts all data types. + + @example + ```js + // example + // CallFunc without data + var finish = cc.callFunc(this.removeSprite, this); + + // CallFunc with data + var finish = cc.callFunc(this.removeFromParentAndCleanup, this._grossini, true); + ``` + */ + export function callFunc(selector: Function, selectorTarget?: any, data?: any): ActionInstant; + /** !#en Helper constructor to create an array of sequenceable actions The created action will run actions sequentially, one after another. @@ -804,7 +804,7 @@ declare namespace cc { ```js // example var action = cc.spawn(cc.jumpBy(2, cc.v2(300, 0), 50, 4), cc.rotateBy(2, 720)); - todo:It should be the direct use new + todo: It should be the direct use new ``` */ export function spawn(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): FiniteTimeAction; @@ -1217,6 +1217,15 @@ declare namespace cc { !#zh 系统事件å•例,方便全局使用 */ export var systemEvent: SystemEvent; /** + Finds a node by hierarchy path, the path is case-sensitive. + It will traverse the hierarchy by splitting the path using '/' character. + This function will still returns the node even if it is inactive. + It is recommended to not use this function every frame instead cache the result at startup. + @param path path + @param referenceNode referenceNode + */ + export function find(path: string, referenceNode?: Node): Node; + /** !#en Defines a CCClass using the given specification, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class.html) for details. !#zh 定义一个 CCClassï¼Œä¼ å…¥å‚æ•°å¿…须是一个包å«ç±»åž‹å‚æ•°çš„å—é¢é‡å¯¹è±¡ï¼Œå…·ä½“用法请查阅[类型定义](/docs/creator/scripting/class.html)。 @param options options @@ -1475,15 +1484,6 @@ declare namespace cc { export function instantiate(original: Prefab): Node; export function instantiate<T>(original: T): T; /** - Finds a node by hierarchy path, the path is case-sensitive. - It will traverse the hierarchy by splitting the path using '/' character. - This function will still returns the node even if it is inactive. - It is recommended to not use this function every frame instead cache the result at startup. - @param path path - @param referenceNode referenceNode - */ - export function find(path: string, referenceNode?: Node): Node; - /** !#en The convenience method to create a new {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}} Alpha channel is optional. Default value is 255. @@ -1968,20 +1968,17 @@ declare namespace cc { update(dt: number): void; } /** !#en - Tween provide a simple and flexible way to create action. - Tween's api is more flexible than cc.Action: - - Support creating an action sequence in chained api, - - Support animate any objects' any properties, not limited to node's properties. - By contrast, cc.Action needs to create a new action class to support new node property. - - Support working with cc.Action, + Tween provide a simple and flexible way to create action. Tween's api is more flexible than `cc.Action`: + - Support creating an action sequence in chained api. + - Support animate any objects' any properties, not limited to node's properties. By contrast, `cc.Action` needs to create a new action class to support new node property. + - Support working with `cc.Action`. - Support easing and progress function. !#zh - Tween æä¾›äº†ä¸€ä¸ªç®€å•çµæ´»çš„æ–¹æ³•æ¥åˆ›å»º action。 - 相对于 Cocos ä¼ ç»Ÿçš„ cc.Action,cc.Tween 在创建动画上è¦çµæ´»éžå¸¸å¤šï¼š + Tween æä¾›äº†ä¸€ä¸ªç®€å•çµæ´»çš„æ–¹æ³•æ¥åˆ›å»º action。相对于 Cocos ä¼ ç»Ÿçš„ `cc.Action`,`cc.Tween` 在创建动画上è¦çµæ´»éžå¸¸å¤šï¼š - 支æŒä»¥é“¾å¼ç»“构的方å¼åˆ›å»ºä¸€ä¸ªåŠ¨ç”»åºåˆ—。 - - 支æŒå¯¹ä»»æ„对象的任æ„属性进行缓动,ä¸å†å±€é™äºŽèŠ‚ç‚¹ä¸Šçš„å±žæ€§ï¼Œè€Œ cc.Action æ·»åŠ ä¸€ä¸ªå±žæ€§çš„æ”¯æŒæ—¶è¿˜éœ€è¦æ·»åŠ ä¸€ä¸ªæ–°çš„ action 类型。 - - 支æŒä¸Ž cc.Action 混用 - - 支æŒè®¾ç½® {{#crossLink "Easing"}}{{/crossLink}} 或者 progress 函数 */ + - 支æŒå¯¹ä»»æ„对象的任æ„属性进行缓动,ä¸å†å±€é™äºŽèŠ‚ç‚¹ä¸Šçš„å±žæ€§ï¼Œè€Œ `cc.Action` æ·»åŠ ä¸€ä¸ªå±žæ€§çš„æ”¯æŒæ—¶è¿˜éœ€è¦æ·»åŠ ä¸€ä¸ªæ–°çš„ action 类型。 + - 支æŒä¸Ž `cc.Action` 混用。 + - 支æŒè®¾ç½® {{#crossLink "Easing"}}{{/crossLink}} 或者 progress 函数。 */ export class Tween<T = any> { /** @@ -2133,9 +2130,10 @@ declare namespace cc { Add an callback action !#zh æ·»åŠ ä¸€ä¸ªå›žè°ƒ action - @param callback callback + @param callback callback + @param selectTarget selectTarget */ - call(callback: Function): Tween<T>; + call(callback: Function, selectTarget?: object): Tween<T>; /** !#en Add an hide action @@ -2177,8 +2175,7 @@ declare namespace cc { parallel(action: Action|Tween<T>, ...actions: (Action|Tween<T>)[]): Tween<T>; /** !#en - Add an repeat action. - This action will integrate before actions to a sequence action as their parameters. + Add an repeat action. This action will integrate before actions to a sequence action as their parameters. !#zh æ·»åŠ ä¸€ä¸ªé‡å¤ action,这个 action 会将å‰ä¸€ä¸ªåŠ¨ä½œä½œä¸ºä»–çš„å‚æ•°ã€‚ @param repeatTimes repeatTimes @@ -2187,8 +2184,7 @@ declare namespace cc { repeat(repeatTimes: number, action?: Action|Tween<T>): Tween<T>; /** !#en - Add an repeat forever action - This action will integrate before actions to a sequence action as their parameters. + Add an repeat forever action. This action will integrate before actions to a sequence action as their parameters. !#zh æ·»åŠ ä¸€ä¸ªæ°¸ä¹…é‡å¤ action,这个 action 会将å‰ä¸€ä¸ªåŠ¨ä½œä½œä¸ºä»–çš„å‚æ•°ã€‚ @param action action @@ -2196,564 +2192,418 @@ declare namespace cc { repeatForever(action?: Action|Tween<T>): Tween<T>; /** !#en - Add an reverse time action. - This action will integrate before actions to a sequence action as their parameters. + Add an reverse time action. This action will integrate before actions to a sequence action as their parameters. !#zh æ·»åŠ ä¸€ä¸ªå€’ç½®æ—¶é—´ action,这个 action 会将å‰ä¸€ä¸ªåŠ¨ä½œä½œä¸ºä»–çš„å‚æ•°ã€‚ @param action action */ reverseTime(action?: Action|Tween<T>): Tween<T>; } - /** cc.TMXLayerInfo contains the information about the layers like: - - Layer name - - Layer size - - Layer opacity at creation time (it can be modified at runtime) - - Whether the layer is visible (if it's not visible, then the CocosNode won't be created) - This information is obtained from the TMX file. */ - export class TMXLayerInfo { - /** Properties of the layer info. */ - properties: any; - } - /** cc.TMXImageLayerInfo contains the information about the image layers. - This information is obtained from the TMX file. */ - export class TMXImageLayerInfo { - } - /** <p>cc.TMXObjectGroupInfo contains the information about the object group like: - - group name - - group size - - group opacity at creation time (it can be modified at runtime) - - Whether the group is visible - - This information is obtained from the TMX file.</p> */ - export class TMXObjectGroupInfo { - /** Properties of the ObjectGroup info. */ - properties: any[]; - } - /** <p>cc.TMXTilesetInfo contains the information about the tilesets like: <br /> - - Tileset name<br /> - - Tileset spacing<br /> - - Tileset margin<br /> - - size of the tiles<br /> - - Image used for the tiles<br /> - - Image size<br /> - - This information is obtained from the TMX file. </p> */ - export class TMXTilesetInfo { - /** Tileset name */ - name: string; - /** First grid */ - firstGid: number; - /** Spacing */ - spacing: number; - /** Margin */ - margin: number; - /** Texture containing the tiles (should be sprite sheet / texture atlas) */ - sourceImage: any; - /** Size in pixels of the image */ - imageSize: Size; - } - /** <p>cc.TMXMapInfo contains the information about the map like: <br/> - - Map orientation (hexagonal, isometric or orthogonal)<br/> - - Tile size<br/> - - Map size</p> - - <p>And it also contains: <br/> - - Layers (an array of TMXLayerInfo objects)<br/> - - Tilesets (an array of TMXTilesetInfo objects) <br/> - - ObjectGroups (an array of TMXObjectGroupInfo objects) </p> - - <p>This information is obtained from the TMX file. </p> */ - export class TMXMapInfo { - /** Properties of the map info. */ - properties: any[]; - /** Map orientation. */ - orientation: number; - /** Parent element. */ - parentElement: any; - /** Parent GID. */ - parentGID: number; - /** Layer attributes. */ - layerAttrs: any; - /** Is reading storing characters stream. */ - storingCharacters: boolean; - /** Current string stored from characters stream. */ - currentString: string; - /** Width of the map */ - mapWidth: number; - /** Height of the map */ - mapHeight: number; - /** Width of a tile */ - tileWidth: number; - /** Height of a tile */ - tileHeight: number; - static ATTRIB_NONE: number; - static ATTRIB_BASE64: number; - static ATTRIB_GZIP: number; - static ATTRIB_ZLIB: number; - } - /** !#en Render the TMX layer. - !#zh 渲染 TMX layer。 */ - export class TiledLayer extends Component { - /** - !#en enable or disable culling - !#zh 开坿ˆ–å…³é—è£å‰ªã€‚ - @param value value - */ - enableCulling(value: any): void; - /** - !#en Adds user's node into layer. - !#zh æ·»åŠ ç”¨æˆ·èŠ‚ç‚¹ã€‚ - @param node node - */ - addUserNode(node: Node): boolean; + /** !#en `cc.audioEngine` is the singleton object, it provide simple audio APIs. + !#zh + cc.audioengine是å•例对象。<br/> + 主è¦ç”¨æ¥æ’æ”¾éŸ³é¢‘ï¼Œæ’æ”¾çš„æ—¶å€™ä¼šè¿”回一个 audioID,之åŽéƒ½å¯ä»¥é€šè¿‡è¿™ä¸ª audioID æ¥æ“作这个音频对象。<br/> + ä¸ä½¿ç”¨çš„æ—¶å€™ï¼Œè¯·ä½¿ç”¨ `cc.audioEngine.uncache(filePath);` 进行资æºé‡Šæ”¾ <br/> + 注æ„:<br/> + 在 Android 系统æµè§ˆå™¨ä¸Šï¼Œä¸åŒæµè§ˆå™¨ï¼Œä¸åŒç‰ˆæœ¬çš„æ•ˆæžœä¸å°½ç›¸åŒã€‚<br/> + 比如说:大多数æµè§ˆå™¨éƒ½éœ€è¦ç”¨æˆ·ç‰©ç†äº¤äº’æ‰å¯ä»¥å¼€å§‹æ’æ”¾éŸ³æ•ˆï¼Œæœ‰ä¸€äº›ä¸æ”¯æŒ WebAudioï¼Œæœ‰ä¸€äº›ä¸æ”¯æŒå¤šéŸ³è½¨æ’放。总之如果对音ä¹ä¾èµ–比较强,请åšå°½å¯èƒ½å¤šçš„æµ‹è¯•。 */ + export class audioEngine { /** - !#en Removes user's node. - !#zh 移除用户节点。 - @param node node + !#en Play audio. + !#zh æ’æ”¾éŸ³é¢‘ + @param clip The audio clip to play. + @param loop Whether the music loop or not. + @param volume Volume size. + + @example + ```js + cc.resources.load(path, cc.AudioClip, null, function (err, clip) { + var audioID = cc.audioEngine.play(clip, false, 0.5); + }); + ``` */ - removeUserNode(node: Node): boolean; + static play(clip: AudioClip, loop: boolean, volume: number): number; /** - !#en Destroy user's node. - !#zh 销æ¯ç”¨æˆ·èŠ‚ç‚¹ã€‚ - @param node node + !#en Set audio loop. + !#zh 设置音频是å¦å¾ªçŽ¯ã€‚ + @param audioID audio id. + @param loop Whether cycle. + + @example + ```js + cc.audioEngine.setLoop(id, true); + ``` */ - destroyUserNode(node: Node): void; + static setLoop(audioID: number, loop: boolean): void; /** - !#en Gets the layer name. - !#zh 获å–层的å称。 + !#en Get audio cycle state. + !#zh 获å–音频的循环状æ€ã€‚ + @param audioID audio id. @example ```js - let layerName = tiledLayer.getLayerName(); - cc.log(layerName); + cc.audioEngine.isLoop(id); ``` */ - getLayerName(): string; + static isLoop(audioID: number): boolean; /** - !#en Set the layer name. - !#zh 设置层的åç§° - @param layerName layerName + !#en Set the volume of audio. + !#zh 设置音é‡ï¼ˆ0.0 ~ 1.0)。 + @param audioID audio id. + @param volume Volume must be in 0.0~1.0 . @example ```js - tiledLayer.setLayerName("New Layer"); + cc.audioEngine.setVolume(id, 0.5); ``` */ - SetLayerName(layerName: string): void; + static setVolume(audioID: number, volume: number): void; /** - !#en Return the value for the specific property name. - !#zh èŽ·å–æŒ‡å®šå±žæ€§å的值。 - @param propertyName propertyName + !#en The volume of the music max value is 1.0,the min value is 0.0 . + !#zh 获å–音é‡ï¼ˆ0.0 ~ 1.0)。 + @param audioID audio id. @example ```js - let property = tiledLayer.getProperty("info"); - cc.log(property); + var volume = cc.audioEngine.getVolume(id); ``` */ - getProperty(propertyName: string): any; + static getVolume(audioID: number): number; /** - !#en Returns the position in pixels of a given tile coordinate. - !#zh èŽ·å–æŒ‡å®š tile çš„åƒç´ åæ ‡ã€‚ - @param pos position or x - @param y y + !#en Set current time + !#zh 设置当å‰çš„音频时间。 + @param audioID audio id. + @param sec current time. @example ```js - let pos = tiledLayer.getPositionAt(cc.v2(0, 0)); - cc.log("Pos: " + pos); - let pos = tiledLayer.getPositionAt(0, 0); - cc.log("Pos: " + pos); + cc.audioEngine.setCurrentTime(id, 2); ``` */ - getPositionAt(pos: Vec2|number, y?: number): Vec2; + static setCurrentTime(audioID: number, sec: number): boolean; /** - !#en - Sets the tiles gid (gid = tile global id) at a given tiles rect. - !#zh - 设置给定区域的 tile çš„ gid (gid = tile 全局 id), - @param gids an array contains gid - @param beginCol begin col number - @param beginRow begin row number - @param totalCols count of column + !#en Get current time + !#zh 获å–当å‰çš„éŸ³é¢‘æ’æ”¾æ—¶é—´ã€‚ + @param audioID audio id. @example ```js - tiledLayer.setTilesGIDAt([1, 1, 1, 1], 10, 10, 2) + var time = cc.audioEngine.getCurrentTime(id); ``` */ - setTilesGIDAt(gids: any[], beginCol: number, beginRow: number, totalCols: number): void; + static getCurrentTime(audioID: number): number; /** - !#en - Sets the tile gid (gid = tile global id) at a given tile coordinate.<br /> - The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor . Tileset Mgr +1.<br /> - If a tile is already placed at that position, then it will be removed. - !#zh - è®¾ç½®ç»™å®šåæ ‡çš„ tile çš„ gid (gid = tile 全局 id), - tile çš„ GID å¯ä»¥ä½¿ç”¨æ–¹æ³• “tileGIDAt†æ¥èŽ·å¾—ã€‚<br /> - 如果一个 tile å·²ç»æ”¾åœ¨é‚£ä¸ªä½ç½®ï¼Œé‚£ä¹ˆå®ƒå°†è¢«åˆ 除。 - @param gid gid - @param posOrX position or x - @param flagsOrY flags or y - @param flags flags + !#en Get audio duration + !#zh 获å–音频总时长。 + @param audioID audio id. @example ```js - tiledLayer.setTileGIDAt(1001, 10, 10, 1) + var time = cc.audioEngine.getDuration(id); ``` */ - setTileGIDAt(gid: number, posOrX: Vec2|number, flagsOrY: number, flags?: number): void; + static getDuration(audioID: number): number; /** - !#en - Returns the tile gid at a given tile coordinate. <br /> - if it returns 0, it means that the tile is empty. <br /> - !#zh - 通过给定的 tile åæ ‡ã€flags(å¯é€‰ï¼‰è¿”回 tile çš„ GID. <br /> - 如果它返回 0,则表示该 tile 为空。<br /> - @param pos or x - @param y y + !#en Get audio state + !#zh 获å–音频状æ€ã€‚ + @param audioID audio id. @example ```js - let tileGid = tiledLayer.getTileGIDAt(0, 0); + var state = cc.audioEngine.getState(id); ``` */ - getTileGIDAt(pos: Vec2|number, y?: number): number; + static getState(audioID: number): audioEngine.AudioState; /** - !#en Layer orientation, which is the same as the map orientation. - !#zh èŽ·å– Layer æ–¹å‘(åŒåœ°å›¾æ–¹å‘)。 + !#en Set Audio finish callback + !#zh 设置一个音频结æŸåŽçš„回调 + @param audioID audio id. + @param callback loaded callback. @example ```js - let orientation = tiledLayer.getLayerOrientation(); - cc.log("Layer Orientation: " + orientation); + cc.audioEngine.setFinishCallback(id, function () {}); ``` */ - getLayerOrientation(): number; + static setFinishCallback(audioID: number, callback: Function): void; /** - !#en properties from the layer. They can be added using Tiled. - !#zh èŽ·å– layer 的属性,å¯ä»¥ä½¿ç”¨ Tiled ç¼–è¾‘å™¨æ·»åŠ å±žæ€§ã€‚ + !#en Pause playing audio. + !#zh æš‚åœæ£åœ¨æ’放音频。 + @param audioID The return value of function play. @example ```js - let properties = tiledLayer.getProperties(); - cc.log("Properties: " + properties); + cc.audioEngine.pause(audioID); ``` */ - getProperties(): any; + static pause(audioID: number): void; /** - !#en - Get the TiledTile with the tile coordinate.<br/> - If there is no tile in the specified coordinate and forceCreate parameter is true, <br/> - then will create a new TiledTile at the coordinate. - The renderer will render the tile with the rotation, scale, position and color property of the TiledTile. - !#zh - 通过指定的 tile åæ ‡èŽ·å–对应的 TiledTile。 <br/> - å¦‚æžœæŒ‡å®šçš„åæ ‡æ²¡æœ‰ tile,并且设置了 forceCreate é‚£ä¹ˆå°†ä¼šåœ¨æŒ‡å®šçš„åæ ‡åˆ›å»ºä¸€ä¸ªæ–°çš„ TiledTile 。<br/> - 在渲染这个 tile 的时候,将会使用 TiledTile 的节点的旋转ã€ç¼©æ”¾ã€ä½ç§»ã€é¢œè‰²å±žæ€§ã€‚<br/> - @param x x - @param y y - @param forceCreate forceCreate + !#en Pause all playing audio + !#zh æš‚åœçŽ°åœ¨æ£åœ¨æ’放的所有音频。 @example ```js - let tile = tiledLayer.getTiledTileAt(100, 100, true); - cc.log(tile); + cc.audioEngine.pauseAll(); ``` */ - getTiledTileAt(x: number, y: number, forceCreate: boolean): TiledTile; - /** - !#en - Change tile to TiledTile at the specified coordinate. - !#zh - 将指定的 tile åæ ‡æ›¿æ¢ä¸ºæŒ‡å®šçš„ TiledTile。 - @param x x - @param y y - @param tiledTile tiledTile - */ - setTiledTileAt(x: number, y: number, tiledTile: TiledTile): TiledTile; - /** - !#en Return texture. - !#zh 获å–纹ç†ã€‚ - @param index The index of textures - */ - getTexture(index: any): Texture2D; - /** - !#en Return texture. - !#zh 获å–纹ç†ã€‚ - */ - getTextures(): Texture2D; - /** - !#en Set the texture. - !#zh 设置纹ç†ã€‚ - @param texture texture - */ - setTexture(texture: Texture2D): void; - /** - !#en Set the texture. - !#zh 设置纹ç†ã€‚ - @param textures textures - */ - setTexture(textures: Texture2D): void; + static pauseAll(): void; /** - !#en Gets layer size. - !#zh 获得层大å°ã€‚ + !#en Resume playing audio. + !#zh æ¢å¤æ’放指定的音频。 + @param audioID The return value of function play. @example ```js - let size = tiledLayer.getLayerSize(); - cc.log("layer size: " + size); + cc.audioEngine.resume(audioID); ``` */ - getLayerSize(): Size; + static resume(audioID: number): void; /** - !#en Size of the map's tile (could be different from the tile's size). - !#zh èŽ·å– tile 的大å°( tile 的大å°å¯èƒ½ä¼šæœ‰æ‰€ä¸åŒ)。 + !#en Resume all playing audio. + !#zh æ¢å¤æ’æ”¾æ‰€æœ‰ä¹‹å‰æš‚åœçš„æ‰€æœ‰éŸ³é¢‘。 @example ```js - let mapTileSize = tiledLayer.getMapTileSize(); - cc.log("MapTile size: " + mapTileSize); + cc.audioEngine.resumeAll(); ``` */ - getMapTileSize(): Size; - /** - !#en Gets Tile set first information for the layer. - !#zh èŽ·å– layer 索引ä½ç½®ä¸º0çš„ Tileset ä¿¡æ¯ã€‚ - @param index The index of tilesets - */ - getTileSet(index: any): TMXTilesetInfo; - /** - !#en Gets tile set all information for the layer. - !#zh èŽ·å– layer 所有的 Tileset ä¿¡æ¯ã€‚ - */ - getTileSet(): TMXTilesetInfo; - /** - !#en Sets tile set information for the layer. - !#zh 设置 layer çš„ tileset ä¿¡æ¯ã€‚ - @param tileset tileset - */ - setTileSet(tileset: TMXTilesetInfo): void; - /** - !#en Sets Tile set information for the layer. - !#zh 设置 layer çš„ Tileset ä¿¡æ¯ã€‚ - @param tilesets tilesets - */ - setTileSets(tilesets: TMXTilesetInfo): void; - } - /** Class for tiled map asset handling. */ - export class TiledMapAsset extends Asset { - textures: Texture2D[]; - textureNames: string[]; - textureSizes: Size[]; - imageLayerTextures: Texture2D[]; - imageLayerTextureNames: string[]; - } - /** !#en Renders the TMX object group. - !#zh 渲染 tmx object group。 */ - export class TiledObjectGroup extends Component { + static resumeAll(): void; /** - !#en Offset position of child objects. - !#zh 获å–å对象的åç§»ä½ç½®ã€‚ + !#en Stop playing audio. + !#zh åœæ¢æ’放指定音频。 + @param audioID The return value of function play. @example ```js - let offset = tMXObjectGroup.getPositionOffset(); + cc.audioEngine.stop(audioID); ``` */ - getPositionOffset(): Vec2; + static stop(audioID: number): void; /** - !#en List of properties stored in a dictionary. - !#zh ä»¥æ˜ å°„çš„å½¢å¼èŽ·å–属性列表。 + !#en Stop all playing audio. + !#zh åœæ¢æ£åœ¨æ’放的所有音频。 @example ```js - let offset = tMXObjectGroup.getProperties(); + cc.audioEngine.stopAll(); ``` */ - getProperties(): any; + static stopAll(): void; /** - !#en Gets the Group name. - !#zh 获å–组å称。 + !#en Set up an audio can generate a few examples. + !#zh 设置一个音频å¯ä»¥è®¾ç½®å‡ 个实例 + @param num a number of instances to be created from within an audio @example ```js - let groupName = tMXObjectGroup.getGroupName; + cc.audioEngine.setMaxAudioInstance(20); ``` */ - getGroupName(): string; + static setMaxAudioInstance(num: number): void; /** - !#en - Return the object for the specific object name. <br /> - It will return the 1st object found on the array for the given name. - !#zh èŽ·å–æŒ‡å®šçš„对象。 - @param objectName objectName + !#en Getting audio can produce several examples. + !#zh 获å–一个音频å¯ä»¥è®¾ç½®å‡ 个实例 @example ```js - let object = tMXObjectGroup.getObject("Group"); + cc.audioEngine.getMaxAudioInstance(); ``` */ - getObject(objectName: string): any; + static getMaxAudioInstance(): number; /** - !#en Gets the objects. - !#zh 获å–对象数组。 + !#en Unload the preloaded audio from internal buffer. + !#zh å¸è½½é¢„åŠ è½½çš„éŸ³é¢‘ã€‚ + @param clip clip @example ```js - let objects = tMXObjectGroup.getObjects(); + cc.audioEngine.uncache(filePath); ``` */ - getObjects(): any[]; - } - /** !#en Renders a TMX Tile Map in the scene. - !#zh åœ¨åœºæ™¯ä¸æ¸²æŸ“一个 tmx æ ¼å¼çš„ Tile Map。 */ - export class TiledMap extends Component { - /** !#en The TiledMap Asset. - !#zh TiledMap 资æºã€‚ */ - tmxAsset: TiledMapAsset; + static uncache(clip: AudioClip): void; /** - !#en Gets the map size. - !#zh 获å–地图大å°ã€‚ + !#en Unload all audio from internal buffer. + !#zh å¸è½½æ‰€æœ‰éŸ³é¢‘。 @example ```js - let mapSize = tiledMap.getMapSize(); - cc.log("Map Size: " + mapSize); + cc.audioEngine.uncacheAll(); ``` */ - getMapSize(): Size; + static uncacheAll(): void; /** - !#en Gets the tile size. - !#zh 获å–åœ°å›¾èƒŒæ™¯ä¸ tile å…ƒç´ çš„å¤§å°ã€‚ + !#en Play background music + !#zh æ’æ”¾èƒŒæ™¯éŸ³ä¹ + @param clip The audio clip to play. + @param loop Whether the music loop or not. @example ```js - let tileSize = tiledMap.getTileSize(); - cc.log("Tile Size: " + tileSize); + cc.resources.load(path, cc.AudioClip, null, function (err, clip) { + var audioID = cc.audioEngine.playMusic(clip, false); + }); ``` */ - getTileSize(): Size; + static playMusic(clip: AudioClip, loop: boolean): number; /** - !#en map orientation. - !#zh 获å–地图方å‘。 + !#en Stop background music. + !#zh åœæ¢æ’放背景音ä¹ã€‚ @example ```js - let mapOrientation = tiledMap.getMapOrientation(); - cc.log("Map Orientation: " + mapOrientation); + cc.audioEngine.stopMusic(); ``` */ - getMapOrientation(): number; + static stopMusic(): void; /** - !#en object groups. - !#zh èŽ·å–æ‰€æœ‰çš„对象层。 + !#en Pause the background music. + !#zh æš‚åœæ’放背景音ä¹ã€‚ @example ```js - let objGroups = titledMap.getObjectGroups(); - for (let i = 0; i < objGroups.length; ++i) { - cc.log("obj: " + objGroups[i]); - } + cc.audioEngine.pauseMusic(); ``` */ - getObjectGroups(): TiledObjectGroup[]; + static pauseMusic(): void; /** - !#en Return the TMXObjectGroup for the specific group. - !#zh èŽ·å–æŒ‡å®šçš„ TMXObjectGroup。 - @param groupName groupName + !#en Resume playing background music. + !#zh æ¢å¤æ’放背景音ä¹ã€‚ @example ```js - let group = titledMap.getObjectGroup("Players"); - cc.log("ObjectGroup: " + group); + cc.audioEngine.resumeMusic(); ``` */ - getObjectGroup(groupName: string): TiledObjectGroup; - /** - !#en enable or disable culling - !#zh 开坿ˆ–å…³é—è£å‰ªã€‚ - @param value value - */ - enableCulling(value: any): void; + static resumeMusic(): void; /** - !#en Gets the map properties. - !#zh 获å–地图的属性。 + !#en Get the volume(0.0 ~ 1.0). + !#zh 获å–音é‡ï¼ˆ0.0 ~ 1.0)。 @example ```js - let properties = titledMap.getProperties(); - for (let i = 0; i < properties.length; ++i) { - cc.log("Properties: " + properties[i]); - } + var volume = cc.audioEngine.getMusicVolume(); ``` */ - getProperties(): any[]; + static getMusicVolume(): number; /** - !#en Return All layers array. - !#zh è¿”å›žåŒ…å«æ‰€æœ‰ layer 的数组。 + !#en Set the background music volume. + !#zh 设置背景音ä¹éŸ³é‡ï¼ˆ0.0 ~ 1.0)。 + @param volume Volume must be in 0.0~1.0. @example ```js - let layers = titledMap.getLayers(); - for (let i = 0; i < layers.length; ++i) { - cc.log("Layers: " + layers[i]); - } + cc.audioEngine.setMusicVolume(0.5); ``` */ - getLayers(): TiledLayer[]; + static setMusicVolume(volume: number): void; /** - !#en return the cc.TiledLayer for the specific layer. - !#zh èŽ·å–æŒ‡å®šåç§°çš„ layer。 - @param layerName layerName + !#en Background music playing state + !#zh èƒŒæ™¯éŸ³ä¹æ˜¯å¦æ£åœ¨æ’放 @example ```js - let layer = titledMap.getLayer("Player"); - cc.log(layer); + cc.audioEngine.isMusicPlaying(); ``` */ - getLayer(layerName: string): TiledLayer; + static isMusicPlaying(): boolean; /** - !#en Return the value for the specific property name. - !#zh 通过属性åç§°ï¼ŒèŽ·å–æŒ‡å®šçš„属性。 - @param propertyName propertyName + !#en Play effect audio. + !#zh æ’æ”¾éŸ³æ•ˆ + @param clip The audio clip to play. + @param loop Whether the music loop or not. @example ```js - let property = titledMap.getProperty("info"); - cc.log("Property: " + property); + cc.resources.load(path, cc.AudioClip, null, function (err, clip) { + var audioID = cc.audioEngine.playEffect(clip, false); + }); ``` */ - getProperty(propertyName: string): string; + static playEffect(clip: AudioClip, loop: boolean): number; /** - !#en Return properties dictionary for tile GID. - !#zh 通过 GID ï¼ŒèŽ·å–æŒ‡å®šçš„属性。 - @param GID GID + !#en Set the volume of effect audio. + !#zh 设置音效音é‡ï¼ˆ0.0 ~ 1.0)。 + @param volume Volume must be in 0.0~1.0. @example ```js - let properties = titledMap.getPropertiesForGID(GID); - cc.log("Properties: " + properties); + cc.audioEngine.setEffectsVolume(0.5); ``` */ - getPropertiesForGID(GID: number): any; - } - /** !#en TiledTile can control the specified map tile. - It will apply the node rotation, scale, translate to the map tile. - You can change the TiledTile's gid to change the map tile's style. - !#zh TiledTile å¯ä»¥å•独对æŸä¸€ä¸ªåœ°å›¾å—进行æ“作。 - 他会将节点的旋转,缩放,平移æ“作应用在这个地图å—上,并å¯ä»¥é€šè¿‡æ›´æ¢å½“å‰åœ°å›¾å—çš„ gid æ¥æ›´æ¢åœ°å›¾å—çš„æ˜¾ç¤ºæ ·å¼ã€‚ */ - export class TiledTile extends Component { - /** !#en Specify the TiledTile horizontal coordinate,use map tile as the unit. - !#zh 指定 TiledTile 的横å‘åæ ‡ï¼Œä»¥åœ°å›¾å—为å•ä½ */ - x: number; - /** !#en Specify the TiledTile vertical coordinate,use map tile as the unit. - !#zh 指定 TiledTile 的纵å‘åæ ‡ï¼Œä»¥åœ°å›¾å—为å•ä½ */ - y: number; - /** !#en Specify the TiledTile gid. - !#zh 指定 TiledTile çš„ gid 值 */ - gid: number; + static setEffectsVolume(volume: number): void; + /** + !#en The volume of the effect audio max value is 1.0,the min value is 0.0 . + !#zh 获å–音效音é‡ï¼ˆ0.0 ~ 1.0)。 + + @example + ```js + var volume = cc.audioEngine.getEffectsVolume(); + ``` + */ + static getEffectsVolume(): number; + /** + !#en Pause effect audio. + !#zh æš‚åœæ’放音效。 + @param audioID audio id. + + @example + ```js + cc.audioEngine.pauseEffect(audioID); + ``` + */ + static pauseEffect(audioID: number): void; + /** + !#en Stop playing all the sound effects. + !#zh æš‚åœæ’放所有音效。 + + @example + ```js + cc.audioEngine.pauseAllEffects(); + ``` + */ + static pauseAllEffects(): void; + /** + !#en Resume effect audio. + !#zh æ¢å¤æ’放音效音频。 + @param audioID The return value of function play. + + @example + ```js + cc.audioEngine.resumeEffect(audioID); + ``` + */ + static resumeEffect(audioID: number): void; + /** + !#en Resume all effect audio. + !#zh æ¢å¤æ’æ”¾æ‰€æœ‰ä¹‹å‰æš‚åœçš„音效。 + + @example + ```js + cc.audioEngine.resumeAllEffects(); + ``` + */ + static resumeAllEffects(): void; + /** + !#en Stop playing the effect audio. + !#zh åœæ¢æ’放音效。 + @param audioID audio id. + + @example + ```js + cc.audioEngine.stopEffect(id); + ``` + */ + static stopEffect(audioID: number): void; + /** + !#en Stop playing all the effects. + !#zh åœæ¢æ’放所有音效。 + + @example + ```js + cc.audioEngine.stopAllEffects(); + ``` + */ + static stopAllEffects(): void; } /** !#en Class for animation data handling. !#zh 动画剪辑,用于å˜å‚¨åŠ¨ç”»æ•°æ®ã€‚ */ @@ -2790,59 +2640,6 @@ declare namespace cc { static createWithSpriteFrames(spriteFrames: SpriteFrame[], sample: number): AnimationClip; } /** !#en - The AnimationState gives full control over animation playback process. - In most cases the Animation Component is sufficient and easier to use. Use the AnimationState if you need full control. - !#zh - AnimationState å®Œå…¨æŽ§åˆ¶åŠ¨ç”»æ’æ”¾è¿‡ç¨‹ã€‚<br/> - 大多数情况下 动画组件 æ˜¯è¶³å¤Ÿå’Œæ˜“äºŽä½¿ç”¨çš„ã€‚å¦‚æžœæ‚¨éœ€è¦æ›´å¤šçš„动画控制接å£ï¼Œè¯·ä½¿ç”¨ AnimationState。 */ - export class AnimationState extends Playable { - /** - - @param clip clip - @param name name - */ - constructor(clip: AnimationClip, name?: string); - /** !#en The curves list. - !#zh 曲线列表。 */ - curves: any[]; - /** !#en The start delay which represents the number of seconds from an animation's start time to the start of - the active interval. - !#zh å»¶è¿Ÿå¤šå°‘ç§’æ’æ”¾ã€‚ */ - delay: number; - /** !#en The animation's iteration count property. - - A real number greater than or equal to zero (including positive infinity) representing the number of times - to repeat the animation node. - - Values less than zero and NaN values are treated as the value 1.0 for the purpose of timing model - calculations. - - !#zh è¿ä»£æ¬¡æ•°ï¼ŒæŒ‡åŠ¨ç”»æ’æ”¾å¤šå°‘次åŽç»“æŸ, normalize time。 如 2.5(2次åŠï¼‰ */ - repeatCount: number; - /** !#en The iteration duration of this animation in seconds. (length) - !#zh 啿¬¡åŠ¨ç”»çš„æŒç»æ—¶é—´ï¼Œç§’。 */ - duration: number; - /** !#en The animation's playback speed. 1 is normal playback speed. - !#zh æ’æ”¾é€ŸçŽ‡ã€‚ */ - speed: number; - /** !#en - Wrapping mode of the playing animation. - Notice : dynamic change wrapMode will reset time and repeatCount property - !#zh - 动画循环方å¼ã€‚ - éœ€è¦æ³¨æ„的是,动æ€ä¿®æ”¹ wrapMode 时,会é‡ç½® time ä»¥åŠ repeatCount */ - wrapMode: WrapMode; - /** !#en The current time of this animation in seconds. - !#zh 动画当å‰çš„æ—¶é—´ï¼Œç§’。 */ - time: number; - /** !#en The clip that is being played by this animation state. - !#zh æ¤åŠ¨ç”»çŠ¶æ€æ£åœ¨æ’放的剪辑。 */ - clip: AnimationClip; - /** !#en The name of the playing animation. - !#zh 动画的åå— */ - name: string; - } - /** !#en This class provide easing methods for {{#crossLink "tween"}}{{/crossLink}} class.<br> Demonstratio: https://easings.net/ !#zh @@ -3042,6 +2839,59 @@ declare namespace cc { */ fade(t: number): number; } + /** !#en + The AnimationState gives full control over animation playback process. + In most cases the Animation Component is sufficient and easier to use. Use the AnimationState if you need full control. + !#zh + AnimationState å®Œå…¨æŽ§åˆ¶åŠ¨ç”»æ’æ”¾è¿‡ç¨‹ã€‚<br/> + 大多数情况下 动画组件 æ˜¯è¶³å¤Ÿå’Œæ˜“äºŽä½¿ç”¨çš„ã€‚å¦‚æžœæ‚¨éœ€è¦æ›´å¤šçš„动画控制接å£ï¼Œè¯·ä½¿ç”¨ AnimationState。 */ + export class AnimationState extends Playable { + /** + + @param clip clip + @param name name + */ + constructor(clip: AnimationClip, name?: string); + /** !#en The curves list. + !#zh 曲线列表。 */ + curves: any[]; + /** !#en The start delay which represents the number of seconds from an animation's start time to the start of + the active interval. + !#zh å»¶è¿Ÿå¤šå°‘ç§’æ’æ”¾ã€‚ */ + delay: number; + /** !#en The animation's iteration count property. + + A real number greater than or equal to zero (including positive infinity) representing the number of times + to repeat the animation node. + + Values less than zero and NaN values are treated as the value 1.0 for the purpose of timing model + calculations. + + !#zh è¿ä»£æ¬¡æ•°ï¼ŒæŒ‡åŠ¨ç”»æ’æ”¾å¤šå°‘次åŽç»“æŸ, normalize time。 如 2.5(2次åŠï¼‰ */ + repeatCount: number; + /** !#en The iteration duration of this animation in seconds. (length) + !#zh 啿¬¡åŠ¨ç”»çš„æŒç»æ—¶é—´ï¼Œç§’。 */ + duration: number; + /** !#en The animation's playback speed. 1 is normal playback speed. + !#zh æ’æ”¾é€ŸçŽ‡ã€‚ */ + speed: number; + /** !#en + Wrapping mode of the playing animation. + Notice : dynamic change wrapMode will reset time and repeatCount property + !#zh + 动画循环方å¼ã€‚ + éœ€è¦æ³¨æ„的是,动æ€ä¿®æ”¹ wrapMode 时,会é‡ç½® time ä»¥åŠ repeatCount */ + wrapMode: WrapMode; + /** !#en The current time of this animation in seconds. + !#zh 动画当å‰çš„æ—¶é—´ï¼Œç§’。 */ + time: number; + /** !#en The clip that is being played by this animation state. + !#zh æ¤åŠ¨ç”»çŠ¶æ€æ£åœ¨æ’放的剪辑。 */ + clip: AnimationClip; + /** !#en The name of the playing animation. + !#zh 动画的åå— */ + name: string; + } /** undefined */ export class Playable { /** !#en Is playing or paused in play mode? @@ -3087,2497 +2937,2848 @@ declare namespace cc { PingPong = 0, PingPongReverse = 0, } - /** Class for particle asset handling. */ - export class ParticleAsset extends Asset { + /** !#en An object to boot the game. + !#zh åŒ…å«æ¸¸æˆä¸»ä½“ä¿¡æ¯å¹¶è´Ÿè´£é©±åŠ¨æ¸¸æˆçš„æ¸¸æˆå¯¹è±¡ã€‚ */ + export class debug { + /** + !#en Gets error message with the error id and possible parameters. + !#zh 通过 error id 和必è¦çš„傿•°æ¥èŽ·å–错误信æ¯ã€‚ + @param errorId errorId + @param param param + */ + static getError(errorId: number, param?: any): string; + /** + !#en Returns whether or not to display the FPS informations. + !#zh æ˜¯å¦æ˜¾ç¤º FPS ä¿¡æ¯ã€‚ + */ + static isDisplayStats(): boolean; + /** + !#en Sets whether display the FPS on the bottom-left corner. + !#zh 设置是å¦åœ¨å·¦ä¸‹è§’显示 FPS。 + @param displayStats displayStats + */ + static setDisplayStats(displayStats: boolean): void; } - /** Particle System base class. <br/> - Attributes of a Particle System:<br/> - - emmision rate of the particles<br/> - - Gravity Mode (Mode A): <br/> - - gravity <br/> - - direction <br/> - - speed +- variance <br/> - - tangential acceleration +- variance<br/> - - radial acceleration +- variance<br/> - - Radius Mode (Mode B): <br/> - - startRadius +- variance <br/> - - endRadius +- variance <br/> - - rotate +- variance <br/> - - Properties common to all modes: <br/> - - life +- life variance <br/> - - start spin +- variance <br/> - - end spin +- variance <br/> - - start size +- variance <br/> - - end size +- variance <br/> - - start color +- variance <br/> - - end color +- variance <br/> - - life +- variance <br/> - - blending function <br/> - - texture <br/> - <br/> - cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).<br/> - 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d, <br/> - cocos2d uses a another approach, but the results are almost identical.<br/> - cocos2d supports all the variables used by Particle Designer plus a bit more: <br/> - - spinning particles (supported when using ParticleSystem) <br/> - - tangential acceleration (Gravity mode) <br/> - - radial acceleration (Gravity mode) <br/> - - radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only) <br/> - It is possible to customize any of the above mentioned properties in runtime. Example: <br/> */ - export class ParticleSystem extends RenderComponent implements BlendFunc { - /** !#en Play particle in edit mode. - !#zh 在编辑器模å¼ä¸‹é¢„览粒å,å¯ç”¨åŽé€‰ä¸ç²’åæ—¶ï¼Œç²’åå°†è‡ªåŠ¨æ’æ”¾ã€‚ */ - preview: boolean; - /** !#en - If set custom to true, then use custom properties insteadof read particle file. - !#zh 是å¦è‡ªå®šä¹‰ç²’å属性。 */ - custom: boolean; - /** !#en The plist file. - !#zh plist æ ¼å¼çš„ç²’åé…置文件。 */ - file: ParticleAsset; - /** !#en SpriteFrame used for particles display - !#zh 用于粒å呈现的 SpriteFrame */ - spriteFrame: SpriteFrame; - /** !#en Texture of Particle System, readonly, please use spriteFrame to setup new texture。 - !#zh ç²’å贴图,åªè¯»å±žæ€§ï¼Œè¯·ä½¿ç”¨ spriteFrame å±žæ€§æ¥æ›¿æ¢è´´å›¾ã€‚ */ - texture: string; - /** !#en Current quantity of particles that are being simulated. - !#zh 当剿’æ”¾çš„ç²’åæ•°é‡ã€‚ */ - particleCount: number; - /** !#en Indicate whether the system simulation have stopped. - !#zh æŒ‡ç¤ºç²’åæ’æ”¾æ˜¯å¦å®Œæ¯•。 */ - stopped: boolean; - /** !#en If set to true, the particle system will automatically start playing on onLoad. - !#zh 如果设置为 true è¿è¡Œæ—¶ä¼šè‡ªåЍå‘å°„ç²’å。 */ - playOnLoad: boolean; - /** !#en Indicate whether the owner node will be auto-removed when it has no particles left. - !#zh ç²’åæ’æ”¾å®Œæ¯•åŽè‡ªåŠ¨é”€æ¯æ‰€åœ¨çš„节点。 */ - autoRemoveOnFinish: boolean; - /** !#en Indicate whether the particle system is activated. - !#zh æ˜¯å¦æ¿€æ´»ç²’å。 */ - active: boolean; - /** !#en Maximum particles of the system. - !#zh ç²’åæœ€å¤§æ•°é‡ã€‚ */ - totalParticles: number; - /** !#en How many seconds the emitter wil run. -1 means 'forever'. - !#zh å‘å°„å™¨ç”Ÿå˜æ—¶é—´ï¼Œå•ä½ç§’,-1表示æŒç»å‘射。 */ - duration: number; - /** !#en Emission rate of the particles. - !#zh æ¯ç§’å‘å°„çš„ç²’åæ•°ç›®ã€‚ */ - emissionRate: number; - /** !#en Life of each particle setter. - !#zh ç²’åçš„è¿è¡Œæ—¶é—´ã€‚ */ - life: number; - /** !#en Variation of life. - !#zh ç²’åçš„è¿è¡Œæ—¶é—´å˜åŒ–范围。 */ - lifeVar: number; - /** !#en Start color of each particle. - !#zh ç²’ååˆå§‹é¢œè‰²ã€‚ */ - startColor: Color; - /** !#en Variation of the start color. - !#zh ç²’ååˆå§‹é¢œè‰²å˜åŒ–范围。 */ - startColorVar: Color; - /** !#en Ending color of each particle. - !#zh ç²’å结æŸé¢œè‰²ã€‚ */ - endColor: Color; - /** !#en Variation of the end color. - !#zh ç²’å结æŸé¢œè‰²å˜åŒ–范围。 */ - endColorVar: Color; - /** !#en Angle of each particle setter. - !#zh ç²’å角度。 */ - angle: number; - /** !#en Variation of angle of each particle setter. - !#zh ç²’å角度å˜åŒ–范围。 */ - angleVar: number; - /** !#en Start size in pixels of each particle. - !#zh ç²’åçš„åˆå§‹å¤§å°ã€‚ */ - startSize: number; - /** !#en Variation of start size in pixels. - !#zh ç²’ååˆå§‹å¤§å°çš„å˜åŒ–范围。 */ - startSizeVar: number; - /** !#en End size in pixels of each particle. - !#zh ç²’åç»“æŸæ—¶çš„大å°ã€‚ */ - endSize: number; - /** !#en Variation of end size in pixels. - !#zh ç²’å结æŸå¤§å°çš„å˜åŒ–范围。 */ - endSizeVar: number; - /** !#en Start angle of each particle. - !#zh ç²’å开始自旋角度。 */ - startSpin: number; - /** !#en Variation of start angle. - !#zh ç²’å开始自旋角度å˜åŒ–范围。 */ - startSpinVar: number; - /** !#en End angle of each particle. - !#zh ç²’å结æŸè‡ªæ—‹è§’度。 */ - endSpin: number; - /** !#en Variation of end angle. - !#zh ç²’å结æŸè‡ªæ—‹è§’度å˜åŒ–范围。 */ - endSpinVar: number; - /** !#en Source position of the emitter. - !#zh å‘射器ä½ç½®ã€‚ */ - sourcePos: Vec2; - /** !#en Variation of source position. - !#zh å‘射器ä½ç½®çš„å˜åŒ–范围。(横å‘和纵å‘) */ - posVar: Vec2; - /** !#en Particles movement type. - !#zh ç²’åä½ç½®ç±»åž‹ã€‚ */ - positionType: ParticleSystem.PositionType; - /** !#en Particles emitter modes. - !#zh å‘射器类型。 */ - emitterMode: ParticleSystem.EmitterMode; - /** !#en Gravity of the emitter. - !#zh é‡åŠ›ã€‚ */ - gravity: Vec2; - /** !#en Speed of the emitter. - !#zh 速度。 */ - speed: number; - /** !#en Variation of the speed. - !#zh 速度å˜åŒ–范围。 */ - speedVar: number; - /** !#en Tangential acceleration of each particle. Only available in 'Gravity' mode. - !#zh æ¯ä¸ªç²’å的切å‘åŠ é€Ÿåº¦ï¼Œå³åž‚直于é‡åŠ›æ–¹å‘çš„åŠ é€Ÿåº¦ï¼Œåªæœ‰åœ¨é‡åŠ›æ¨¡å¼ä¸‹å¯ç”¨ã€‚ */ - tangentialAccel: number; - /** !#en Variation of the tangential acceleration. - !#zh æ¯ä¸ªç²’å的切å‘åŠ é€Ÿåº¦å˜åŒ–范围。 */ - tangentialAccelVar: number; - /** !#en Acceleration of each particle. Only available in 'Gravity' mode. - !#zh ç²’å径å‘åŠ é€Ÿåº¦ï¼Œå³å¹³è¡ŒäºŽé‡åŠ›æ–¹å‘çš„åŠ é€Ÿåº¦ï¼Œåªæœ‰åœ¨é‡åŠ›æ¨¡å¼ä¸‹å¯ç”¨ã€‚ */ - radialAccel: number; - /** !#en Variation of the radial acceleration. - !#zh ç²’å径å‘åŠ é€Ÿåº¦å˜åŒ–范围。 */ - radialAccelVar: number; - /** !#en Indicate whether the rotation of each particle equals to its direction. Only available in 'Gravity' mode. - !#zh æ¯ä¸ªç²’å的旋转是å¦ç‰äºŽå…¶æ–¹å‘ï¼Œåªæœ‰åœ¨é‡åŠ›æ¨¡å¼ä¸‹å¯ç”¨ã€‚ */ - rotationIsDir: boolean; - /** !#en Starting radius of the particles. Only available in 'Radius' mode. - !#zh åˆå§‹åŠå¾„,表示粒å出生时相对å‘射器的è·ç¦»ï¼Œåªæœ‰åœ¨åŠå¾„模å¼ä¸‹å¯ç”¨ã€‚ */ - startRadius: number; - /** !#en Variation of the starting radius. - !#zh åˆå§‹åŠå¾„å˜åŒ–范围。 */ - startRadiusVar: number; - /** !#en Ending radius of the particles. Only available in 'Radius' mode. - !#zh 结æŸåŠå¾„ï¼Œåªæœ‰åœ¨åŠå¾„模å¼ä¸‹å¯ç”¨ã€‚ */ - endRadius: number; - /** !#en Variation of the ending radius. - !#zh 结æŸåŠå¾„å˜åŒ–范围。 */ - endRadiusVar: number; - /** !#en Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode. - !#zh ç²’åæ¯ç§’å›´ç»•èµ·å§‹ç‚¹çš„æ—‹è½¬è§’åº¦ï¼Œåªæœ‰åœ¨åŠå¾„模å¼ä¸‹å¯ç”¨ã€‚ */ - rotatePerS: number; - /** !#en Variation of the degress to rotate a particle around the source pos per second. - !#zh ç²’åæ¯ç§’å›´ç»•èµ·å§‹ç‚¹çš„æ—‹è½¬è§’åº¦å˜åŒ–范围。 */ - rotatePerSVar: number; - /** !#en The Particle emitter lives forever. - !#zh 表示å‘射器永久å˜åœ¨ */ - static DURATION_INFINITY: number; - /** !#en The starting size of the particle is equal to the ending size. - !#zh 表示粒å的起始大å°ç‰äºŽç»“æŸå¤§å°ã€‚ */ - static START_SIZE_EQUAL_TO_END_SIZE: number; - /** !#en The starting radius of the particle is equal to the ending radius. - !#zh 表示粒å的起始åŠå¾„ç‰äºŽç»“æŸåŠå¾„。 */ - static START_RADIUS_EQUAL_TO_END_RADIUS: number; + /** !#en + <p> + ATTENTION: USE cc.director INSTEAD OF cc.Director.<br/> + cc.director is a singleton object which manage your game's logic flow.<br/> + Since the cc.director is a singleton, you don't need to call any constructor or create functions,<br/> + the standard way to use it is by calling:<br/> + - cc.director.methodName(); <br/> + + It creates and handle the main Window and manages how and when to execute the Scenes.<br/> + <br/> + The cc.director is also responsible for:<br/> + - initializing the OpenGL context<br/> + - setting the OpenGL pixel format (default on is RGB565)<br/> + - setting the OpenGL buffer depth (default on is 0-bit)<br/> + - setting the color for clear screen (default one is BLACK)<br/> + - setting the projection (default one is 3D)<br/> + - setting the orientation (default one is Portrait)<br/> + <br/> + <br/> + The cc.director also sets the default OpenGL context:<br/> + - GL_TEXTURE_2D is enabled<br/> + - GL_VERTEX_ARRAY is enabled<br/> + - GL_COLOR_ARRAY is enabled<br/> + - GL_TEXTURE_COORD_ARRAY is enabled<br/> + </p> + <p> + cc.director also synchronizes timers with the refresh rate of the display.<br/> + Features and Limitations:<br/> + - Scheduled timers & drawing are synchronizes with the refresh rate of the display<br/> + - Only supports animation intervals of 1/60 1/30 & 1/15<br/> + </p> + + !#zh + <p> + 注æ„:用 cc.director 代替 cc.Director。<br/> + cc.director 一个管ç†ä½ 的游æˆçš„逻辑æµç¨‹çš„å•例对象。<br/> + 由于 cc.director 是一个å•ä¾‹ï¼Œä½ ä¸éœ€è¦è°ƒç”¨ä»»ä½•æž„é€ å‡½æ•°æˆ–åˆ›å»ºå‡½æ•°ï¼Œ<br/> + ä½¿ç”¨å®ƒçš„æ ‡å‡†æ–¹æ³•æ˜¯é€šè¿‡è°ƒç”¨ï¼š<br/> + - cc.director.methodName(); + <br/> + 它创建和处ç†ä¸»çª—å£å¹¶ä¸”管ç†ä»€ä¹ˆæ—¶å€™æ‰§è¡Œåœºæ™¯ã€‚<br/> + <br/> + cc.director 还负责:<br/> + - åˆå§‹åŒ– OpenGL 环境。<br/> + - 设置OpenGLåƒç´ æ ¼å¼ã€‚(默认是 RGB565)<br/> + - 设置OpenGL缓冲区深度 (默认是 0-bit)<br/> + - 设置空白场景的颜色 (默认是 黑色)<br/> + - 设置投影 (默认是 3D)<br/> + - è®¾ç½®æ–¹å‘ (默认是 Portrait)<br/> + <br/> + cc.director 设置了 OpenGL 默认环境 <br/> + - GL_TEXTURE_2D å¯ç”¨ã€‚<br/> + - GL_VERTEX_ARRAY å¯ç”¨ã€‚<br/> + - GL_COLOR_ARRAY å¯ç”¨ã€‚<br/> + - GL_TEXTURE_COORD_ARRAY å¯ç”¨ã€‚<br/> + </p> + <p> + cc.director ä¹ŸåŒæ¥å®šæ—¶å™¨ä¸Žæ˜¾ç¤ºå™¨çš„刷新速率。 + <br/> + ç‰¹ç‚¹å’Œå±€é™æ€§: <br/> + - 将计时器 & æ¸²æŸ“ä¸Žæ˜¾ç¤ºå™¨çš„åˆ·æ–°é¢‘çŽ‡åŒæ¥ã€‚<br/> + - åªæ”¯æŒåŠ¨ç”»çš„é—´éš” 1/60 1/30 & 1/15。<br/> + </p> */ + export class Director extends EventTarget { /** - !#en Stop emitting particles. Running particles will continue to run until they die. - !#zh åœæ¢å‘射器å‘å°„ç²’å,å‘射出去的粒å将继ç»è¿è¡Œï¼Œç›´è‡³ç²’å生命结æŸã€‚ - - @example - ```js - // stop particle system. - myParticleSystem.stopSystem(); - ``` + !#en + Converts a view coordinate to an WebGL coordinate<br/> + Useful to convert (multi) touches coordinates to the current layout (portrait or landscape)<br/> + Implementation can be found in CCDirectorWebGL. + !#zh 将触摸点的å±å¹•åæ ‡è½¬æ¢ä¸º WebGL View ä¸‹çš„åæ ‡ã€‚ + @param uiPoint uiPoint */ - stopSystem(): void; + convertToGL(uiPoint: Vec2): Vec2; /** - !#en Kill all living particles. - !#zh æ€æ»æ‰€æœ‰å˜åœ¨çš„ç²’å,然åŽé‡æ–°å¯åŠ¨ç²’åå‘射器。 - - @example - ```js - // play particle system. - myParticleSystem.resetSystem(); - ``` + !#en + Converts an OpenGL coordinate to a view coordinate<br/> + Useful to convert node points to window points for calls such as glScissor<br/> + Implementation can be found in CCDirectorWebGL. + !#zh 将触摸点的 WebGL View åæ ‡è½¬æ¢ä¸ºå±å¹•åæ ‡ã€‚ + @param glPoint glPoint */ - resetSystem(): void; + convertToUI(glPoint: Vec2): Vec2; /** - !#en Whether or not the system is full. - !#zh å‘射器ä¸ç²’åæ˜¯å¦å¤§äºŽç‰äºŽè®¾ç½®çš„æ€»ç²’åæ•°é‡ã€‚ + End the life of director in the next frame */ - isFull(): boolean; + end(): void; /** - !#en Sets a new texture with a rect. The rect is in texture position and size. - Please use spriteFrame property instead, this function is deprecated since v1.9 - !#zh è®¾ç½®ä¸€å¼ æ–°è´´å›¾å’Œå…³è”的矩形。 - 请直接设置 spriteFrame 属性,这个函数从 v1.9 版本开始已ç»è¢«åºŸå¼ƒ - @param texture texture - @param rect rect + !#en + Returns the size of the WebGL view in points.<br/> + It takes into account any possible rotation (device orientation) of the window. + !#zh 获å–视图的大å°ï¼Œä»¥ç‚¹ä¸ºå•ä½ã€‚ */ - setTextureWithRect(texture: Texture2D, rect: Rect): void; - /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. - !#zh æŒ‡å®šåŽŸå›¾çš„æ··åˆæ¨¡å¼ï¼Œè¿™ä¼šå…‹éš†ä¸€ä¸ªæ–°çš„æè´¨å¯¹è±¡ï¼Œæ³¨æ„这带æ¥çš„开销 */ - srcBlendFactor: macro.BlendFactor; - /** !#en specify the destination Blend Factor. - !#zh æŒ‡å®šç›®æ ‡çš„æ··åˆæ¨¡å¼ */ - dstBlendFactor: macro.BlendFactor; - } - /** !#en cc.audioEngine is the singleton object, it provide simple audio APIs. - !#zh - cc.audioengine是å•例对象。<br/> - 主è¦ç”¨æ¥æ’æ”¾éŸ³é¢‘ï¼Œæ’æ”¾çš„æ—¶å€™ä¼šè¿”回一个 audioID,之åŽéƒ½å¯ä»¥é€šè¿‡è¿™ä¸ª audioID æ¥æ“作这个音频对象。<br/> - ä¸ä½¿ç”¨çš„æ—¶å€™ï¼Œè¯·ä½¿ç”¨ cc.audioEngine.uncache(filePath); 进行资æºé‡Šæ”¾ <br/> - 注æ„:<br/> - 在 Android 系统æµè§ˆå™¨ä¸Šï¼Œä¸åŒæµè§ˆå™¨ï¼Œä¸åŒç‰ˆæœ¬çš„æ•ˆæžœä¸å°½ç›¸åŒã€‚<br/> - 比如说:大多数æµè§ˆå™¨éƒ½éœ€è¦ç”¨æˆ·ç‰©ç†äº¤äº’æ‰å¯ä»¥å¼€å§‹æ’æ”¾éŸ³æ•ˆï¼Œæœ‰ä¸€äº›ä¸æ”¯æŒ WebAudio,<br/> - æœ‰ä¸€äº›ä¸æ”¯æŒå¤šéŸ³è½¨æ’放。总之如果对音ä¹ä¾èµ–比较强,请åšå°½å¯èƒ½å¤šçš„æµ‹è¯•。 */ - export class audioEngine { + getWinSize(): Size; /** - !#en Play audio. - !#zh æ’æ”¾éŸ³é¢‘ - @param clip The audio clip to play. - @param loop Whether the music loop or not. - @param volume Volume size. - - @example - ```js - cc.resources.load(path, cc.AudioClip, null, function (err, clip) { - var audioID = cc.audioEngine.play(clip, false, 0.5); - }); - ``` + !#en + Returns the size of the OpenGL view in pixels.<br/> + It takes into account any possible rotation (device orientation) of the window.<br/> + On Mac winSize and winSizeInPixels return the same value. + (The pixel here refers to the resource resolution. If you want to get the physics resolution of device, you need to use cc.view.getFrameSize()) + !#zh + 获å–视图大å°ï¼Œä»¥åƒç´ 为å•ä½ï¼ˆè¿™é‡Œçš„åƒç´ 指的是资æºåˆ†è¾¨çŽ‡ã€‚ + 如果è¦èŽ·å–å±å¹•物ç†åˆ†è¾¨çŽ‡ï¼Œéœ€è¦ç”¨ cc.view.getFrameSize()) */ - static play(clip: AudioClip, loop: boolean, volume: number): number; + getWinSizeInPixels(): Size; /** - !#en Set audio loop. - !#zh 设置音频是å¦å¾ªçŽ¯ã€‚ - @param audioID audio id. - @param loop Whether cycle. - - @example - ```js - cc.audioEngine.setLoop(id, true); - ``` + !#en Pause the director's ticker, only involve the game logic execution. + It won't pause the rendering process nor the event manager. + If you want to pause the entier game including rendering, audio and event, + please use {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}} + !#zh æš‚åœæ£åœ¨è¿è¡Œçš„场景,该暂åœåªä¼šåœæ¢æ¸¸æˆé€»è¾‘执行,但是ä¸ä¼šåœæ¢æ¸²æŸ“å’Œ UI å“应。 + å¦‚æžœæƒ³è¦æ›´å½»åº•å¾—æš‚åœæ¸¸æˆï¼ŒåŒ…嫿¸²æŸ“,音频和事件,请使用 {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}。 */ - static setLoop(audioID: number, loop: boolean): void; + pause(): void; /** - !#en Get audio cycle state. - !#zh 获å–音频的循环状æ€ã€‚ - @param audioID audio id. - - @example - ```js - cc.audioEngine.isLoop(id); - ``` + !#en + Run a scene. Replaces the running scene with a new one or enter the first scene.<br/> + The new scene will be launched immediately. + !#zh ç«‹åˆ»åˆ‡æ¢æŒ‡å®šåœºæ™¯ã€‚ + @param scene The need run scene. + @param onBeforeLoadScene The function invoked at the scene before loading. + @param onLaunched The function invoked at the scene after launch. */ - static isLoop(audioID: number): boolean; + runSceneImmediate(scene: Scene|SceneAsset, onBeforeLoadScene?: Function, onLaunched?: Function): void; /** - !#en Set the volume of audio. - !#zh 设置音é‡ï¼ˆ0.0 ~ 1.0)。 - @param audioID audio id. - @param volume Volume must be in 0.0~1.0 . - - @example - ```js - cc.audioEngine.setVolume(id, 0.5); - ``` + !#en + Run a scene. Replaces the running scene with a new one or enter the first scene. + The new scene will be launched at the end of the current frame. + !#zh è¿è¡ŒæŒ‡å®šåœºæ™¯ã€‚ + @param scene The need run scene. + @param onBeforeLoadScene The function invoked at the scene before loading. + @param onLaunched The function invoked at the scene after launch. */ - static setVolume(audioID: number, volume: number): void; + runScene(scene: Scene|SceneAsset, onBeforeLoadScene?: Function, onLaunched?: Function): void; /** - !#en The volume of the music max value is 1.0,the min value is 0.0 . - !#zh 获å–音é‡ï¼ˆ0.0 ~ 1.0)。 - @param audioID audio id. - - @example - ```js - var volume = cc.audioEngine.getVolume(id); - ``` + !#en Loads the scene by its name. + !#zh 通过场景åç§°è¿›è¡ŒåŠ è½½åœºæ™¯ã€‚ + @param sceneName The name of the scene to load. + @param onLaunched callback, will be called after scene launched. */ - static getVolume(audioID: number): number; + loadScene(sceneName: string, onLaunched?: Function): boolean; /** - !#en Set current time - !#zh 设置当å‰çš„音频时间。 - @param audioID audio id. - @param sec current time. - - @example - ```js - cc.audioEngine.setCurrentTime(id, 2); - ``` + !#en + Preloads the scene to reduces loading time. You can call this method at any time you want. + After calling this method, you still need to launch the scene by `cc.director.loadScene`. + It will be totally fine to call `cc.director.loadScene` at any time even if the preloading is not + yet finished, the scene will be launched after loaded automatically. + !#zh é¢„åŠ è½½åœºæ™¯ï¼Œä½ å¯ä»¥åœ¨ä»»ä½•时候调用这个方法。 + 调用完åŽï¼Œä½ ä»ç„¶éœ€è¦é€šè¿‡ `cc.director.loadScene` æ¥å¯åŠ¨åœºæ™¯ï¼Œå› ä¸ºè¿™ä¸ªæ–¹æ³•ä¸ä¼šæ‰§è¡Œåœºæ™¯åŠ è½½æ“作。 + å°±ç®—é¢„åŠ è½½è¿˜æ²¡å®Œæˆï¼Œä½ 也å¯ä»¥ç›´æŽ¥è°ƒç”¨ `cc.director.loadScene`ï¼ŒåŠ è½½å®ŒæˆåŽåœºæ™¯å°±ä¼šå¯åŠ¨ã€‚ + @param sceneName The name of the scene to preload. + @param onProgress callback, will be called when the load progression change. + @param onLoaded callback, will be called after scene loaded. */ - static setCurrentTime(audioID: number, sec: number): boolean; + preloadScene(sceneName: string, onProgress?: (completedCount: number, totalCount: number, item: any) => void, onLoaded?: (error: Error) => void): void; /** - !#en Get current time - !#zh 获å–当å‰çš„éŸ³é¢‘æ’æ”¾æ—¶é—´ã€‚ - @param audioID audio id. - - @example - ```js - var time = cc.audioEngine.getCurrentTime(id); - ``` + !#en Resume game logic execution after pause, if the current scene is not paused, nothing will happen. + !#zh æ¢å¤æš‚åœåœºæ™¯çš„æ¸¸æˆé€»è¾‘,如果当å‰åœºæ™¯æ²¡æœ‰æš‚åœå°†æ²¡ä»»ä½•事情å‘生。 */ - static getCurrentTime(audioID: number): number; + resume(): void; /** - !#en Get audio duration - !#zh 获å–音频总时长。 - @param audioID audio id. - - @example - ```js - var time = cc.audioEngine.getDuration(id); - ``` + !#en + Enables or disables WebGL depth test.<br/> + Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js + !#zh å¯ç”¨/ç¦ç”¨æ·±åº¦æµ‹è¯•(在 Canvas 渲染模å¼ä¸‹ä¸ä¼šç”Ÿæ•ˆï¼‰ã€‚ + @param on on */ - static getDuration(audioID: number): number; + setDepthTest(on: boolean): void; /** - !#en Get audio state - !#zh 获å–音频状æ€ã€‚ - @param audioID audio id. + !#en + Set color for clear screen.<br/> + (Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js) + !#zh + 设置场景的默认擦除颜色。<br/> + 支æŒå…¨é€æ˜Žï¼Œä½†ä¸æ”¯æŒé€æ˜Žåº¦ä¸ºä¸é—´å€¼ã€‚è¦æ”¯æŒå…¨é€æ˜Žéœ€æ‰‹å·¥å¼€å¯ cc.macro.ENABLE_TRANSPARENT_CANVAS。 + @param clearColor clearColor + */ + setClearColor(clearColor: Color): void; + /** + !#en Returns current logic Scene. + !#zh 获å–当å‰é€»è¾‘场景。 @example ```js - var state = cc.audioEngine.getState(id); + // This will help you to get the Canvas node in scene + cc.director.getScene().getChildByName('Canvas'); ``` */ - static getState(audioID: number): audioEngine.AudioState; + getScene(): Scene; + /** + !#en Returns the FPS value. Please use {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} to control animation interval. + !#zh 获å–å•ä½å¸§æ‰§è¡Œæ—¶é—´ã€‚请使用 {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} æ¥æŽ§åˆ¶æ¸¸æˆå¸§çŽ‡ã€‚ + */ + getAnimationInterval(): number; + /** + Sets animation interval, this doesn't control the main loop. + To control the game's frame rate overall, please use {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} + @param value The animation interval desired. + */ + setAnimationInterval(value: number): void; + /** + !#en Returns the delta time since last frame. + !#zh 获å–ä¸Šä¸€å¸§çš„å¢žé‡æ—¶é—´ã€‚ + */ + getDeltaTime(): number; + /** + !#en Returns the total passed time since game start, unit: ms + !#zh 获å–从游æˆå¼€å§‹åˆ°çŽ°åœ¨æ€»å…±ç»è¿‡çš„æ—¶é—´ï¼Œå•ä½ä¸º ms + */ + getTotalTime(): number; + /** + !#en Returns how many frames were called since the director started. + !#zh èŽ·å– director å¯åŠ¨ä»¥æ¥æ¸¸æˆè¿è¡Œçš„æ€»å¸§æ•°ã€‚ + */ + getTotalFrames(): number; + /** + !#en Returns whether or not the Director is paused. + !#zh 是å¦å¤„于暂åœçжæ€ã€‚ + */ + isPaused(): boolean; + /** + !#en Returns the cc.Scheduler associated with this director. + !#zh 获å–å’Œ director 相关è”çš„ cc.Scheduler。 + */ + getScheduler(): Scheduler; + /** + !#en Sets the cc.Scheduler associated with this director. + !#zh 设置和 director 相关è”çš„ cc.Scheduler。 + @param scheduler scheduler + */ + setScheduler(scheduler: Scheduler): void; + /** + !#en Returns the cc.ActionManager associated with this director. + !#zh 获å–å’Œ director 相关è”çš„ cc.ActionManager(动作管ç†å™¨ï¼‰ã€‚ + */ + getActionManager(): ActionManager; /** - !#en Set Audio finish callback - !#zh 设置一个音频结æŸåŽçš„回调 - @param audioID audio id. - @param callback loaded callback. - - @example - ```js - cc.audioEngine.setFinishCallback(id, function () {}); - ``` + !#en Sets the cc.ActionManager associated with this director. + !#zh 设置和 director 相关è”çš„ cc.ActionManager(动作管ç†å™¨ï¼‰ã€‚ + @param actionManager actionManager */ - static setFinishCallback(audioID: number, callback: Function): void; + setActionManager(actionManager: ActionManager): void; /** - !#en Pause playing audio. - !#zh æš‚åœæ£åœ¨æ’放音频。 - @param audioID The return value of function play. - - @example - ```js - cc.audioEngine.pause(audioID); - ``` + !#en Returns the cc.CollisionManager associated with this director. + !#zh 获å–å’Œ director 相关è”çš„ cc.CollisionManager (碰撞管ç†å™¨ï¼‰ã€‚ */ - static pause(audioID: number): void; + getCollisionManager(): CollisionManager; /** - !#en Pause all playing audio - !#zh æš‚åœçŽ°åœ¨æ£åœ¨æ’放的所有音频。 - - @example - ```js - cc.audioEngine.pauseAll(); - ``` + !#en Returns the cc.PhysicsManager associated with this director. + !#zh 返回与 director 相关è”çš„ cc.PhysicsManager (物ç†ç®¡ç†å™¨ï¼‰ã€‚ */ - static pauseAll(): void; + getPhysicsManager(): PhysicsManager; /** - !#en Resume playing audio. - !#zh æ¢å¤æ’放指定的音频。 - @param audioID The return value of function play. - - @example - ```js - cc.audioEngine.resume(audioID); - ``` + !#en Returns the cc.Physics3DManager associated with this director. + !#zh 返回与 director 相关è”çš„ cc.Physics3DManager (物ç†ç®¡ç†å™¨ï¼‰ã€‚ */ - static resume(audioID: number): void; + getPhysics3DManager(): Physics3DManager; + /** !#en The event projection changed of cc.Director. This event will not get triggered since v2.0 + !#zh cc.Director 投影å˜åŒ–的事件。从 v2.0 开始这个事件ä¸ä¼šå†è¢«è§¦å‘ */ + static EVENT_PROJECTION_CHANGED: string; + /** !#en The event which will be triggered before loading a new scene. + !#zh åŠ è½½æ–°åœºæ™¯ä¹‹å‰æ‰€è§¦å‘的事件。 */ + static EVENT_BEFORE_SCENE_LOADING: string; + /** !#en The event which will be triggered before launching a new scene. + !#zh è¿è¡Œæ–°åœºæ™¯ä¹‹å‰æ‰€è§¦å‘的事件。 */ + static EVENT_BEFORE_SCENE_LAUNCH: string; + /** !#en The event which will be triggered after launching a new scene. + !#zh è¿è¡Œæ–°åœºæ™¯ä¹‹åŽæ‰€è§¦å‘的事件。 */ + static EVENT_AFTER_SCENE_LAUNCH: string; + /** !#en The event which will be triggered at the beginning of every frame. + !#zh æ¯ä¸ªå¸§çš„开始时所触å‘的事件。 */ + static EVENT_BEFORE_UPDATE: string; + /** !#en The event which will be triggered after engine and components update logic. + !#zh 将在引擎和组件 “updateâ€ é€»è¾‘ä¹‹åŽæ‰€è§¦å‘的事件。 */ + static EVENT_AFTER_UPDATE: string; + /** !#en The event is deprecated since v2.0, please use cc.Director.EVENT_BEFORE_DRAW instead + !#zh 这个事件从 v2.0 开始被废弃,请直接使用 cc.Director.EVENT_BEFORE_DRAW */ + static EVENT_BEFORE_VISIT: string; + /** !#en The event is deprecated since v2.0, please use cc.Director.EVENT_BEFORE_DRAW instead + !#zh 这个事件从 v2.0 开始被废弃,请直接使用 cc.Director.EVENT_BEFORE_DRAW */ + static EVENT_AFTER_VISIT: string; + /** !#en The event which will be triggered before the rendering process. + !#zh æ¸²æŸ“è¿‡ç¨‹ä¹‹å‰æ‰€è§¦å‘的事件。 */ + static EVENT_BEFORE_DRAW: string; + /** !#en The event which will be triggered after the rendering process. + !#zh æ¸²æŸ“è¿‡ç¨‹ä¹‹åŽæ‰€è§¦å‘的事件。 */ + static EVENT_AFTER_DRAW: string; + /** Constant for 2D projection (orthogonal projection) */ + static PROJECTION_2D: number; + /** Constant for 3D projection with a fovy=60, znear=0.5f and zfar=1500. */ + static PROJECTION_3D: number; + /** Constant for custom projection, if cc.Director's projection set to it, it calls "updateProjection" on the projection delegate. */ + static PROJECTION_CUSTOM: number; + /** Constant for default projection of cc.Director, default projection is 2D projection */ + static PROJECTION_DEFAULT: number; + } + /** !#en An object to boot the game. + !#zh åŒ…å«æ¸¸æˆä¸»ä½“ä¿¡æ¯å¹¶è´Ÿè´£é©±åŠ¨æ¸¸æˆçš„æ¸¸æˆå¯¹è±¡ã€‚ */ + export class Game extends EventTarget { + /** !#en Event triggered when game hide to background. + Please note that this event is not 100% guaranteed to be fired on Web platform, + on native platforms, it corresponds to enter background event, os status bar or notification center may not trigger this event. + !#zh 游æˆè¿›å…¥åŽå°æ—¶è§¦å‘的事件。 + 请注æ„,在 WEB å¹³å°ï¼Œè¿™ä¸ªäº‹ä»¶ä¸ä¸€å®šä¼š 100% 触å‘,这完全å–决于æµè§ˆå™¨çš„回调行为。 + 在原生平å°ï¼Œå®ƒå¯¹åº”的是应用被切æ¢åˆ°åŽå°äº‹ä»¶ï¼Œä¸‹æ‹‰èœå•å’Œä¸Šæ‹‰çŠ¶æ€æ ç‰ä¸ä¸€å®šä¼šè§¦å‘这个事件,这å–决于系统行为。 */ + EVENT_HIDE: string; + /** !#en Event triggered when game back to foreground + Please note that this event is not 100% guaranteed to be fired on Web platform, + on native platforms, it corresponds to enter foreground event. + !#zh 游æˆè¿›å…¥å‰å°è¿è¡Œæ—¶è§¦å‘的事件。 + 请注æ„,在 WEB å¹³å°ï¼Œè¿™ä¸ªäº‹ä»¶ä¸ä¸€å®šä¼š 100% 触å‘,这完全å–决于æµè§ˆå™¨çš„回调行为。 + 在原生平å°ï¼Œå®ƒå¯¹åº”的是应用被切æ¢åˆ°å‰å°äº‹ä»¶ã€‚ */ + EVENT_SHOW: string; + /** !#en Event triggered when game restart + !#zh 调用restartåŽï¼Œè§¦å‘事件。 */ + EVENT_RESTART: string; + /** Event triggered after game inited, at this point all engine objects and game scripts are loaded */ + EVENT_GAME_INITED: string; + /** Event triggered after engine inited, at this point you will be able to use all engine classes. + It was defined as EVENT_RENDERER_INITED in cocos creator v1.x and renamed in v2.0 */ + EVENT_ENGINE_INITED: string; + /** Web Canvas 2d API as renderer backend */ + RENDER_TYPE_CANVAS: number; + /** WebGL API as renderer backend */ + RENDER_TYPE_WEBGL: number; + /** OpenGL API as renderer backend */ + RENDER_TYPE_OPENGL: number; + /** !#en The outer frame of the game canvas, parent of game container. + !#zh 游æˆç”»å¸ƒçš„外框,container 的父容器。 */ + frame: any; + /** !#en The container of game canvas. + !#zh 游æˆç”»å¸ƒçš„容器。 */ + container: HTMLDivElement; + /** !#en The canvas of the game. + !#zh 游æˆçš„画布。 */ + canvas: HTMLCanvasElement; + /** !#en The renderer backend of the game. + !#zh 游æˆçš„æ¸²æŸ“器类型。 */ + renderType: number; + /** !#en + The current game configuration, including:<br/> + 1. debugMode<br/> + "debugMode" possible values :<br/> + 0 - No message will be printed. <br/> + 1 - cc.error, cc.assert, cc.warn, cc.log will print in console. <br/> + 2 - cc.error, cc.assert, cc.warn will print in console. <br/> + 3 - cc.error, cc.assert will print in console. <br/> + 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web.<br/> + 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web. <br/> + 6 - cc.error, cc.assert will print on canvas, available only on web. <br/> + 2. showFPS<br/> + Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide.<br/> + 3. exposeClassName<br/> + Expose class name to chrome debug tools, the class intantiate performance is a little bit slower when exposed.<br/> + 4. frameRate<br/> + "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment.<br/> + 5. id<br/> + "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web.<br/> + 6. renderMode<br/> + "renderMode" sets the renderer type, only useful on web :<br/> + 0 - Automatically chosen by engine<br/> + 1 - Forced to use canvas renderer<br/> + 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers<br/> + <br/> + Please DO NOT modify this object directly, it won't have any effect.<br/> + !#zh + 当å‰çš„æ¸¸æˆé…置,包括: <br/> + 1. debugMode(debug 模å¼ï¼Œä½†æ˜¯åœ¨æµè§ˆå™¨ä¸è¿™ä¸ªé€‰é¡¹ä¼šè¢«å¿½ç•¥ï¼‰ <br/> + "debugMode" å„ç§è®¾ç½®é€‰é¡¹çš„æ„ä¹‰ã€‚ <br/> + 0 - 没有消æ¯è¢«æ‰“å°å‡ºæ¥ã€‚ <br/> + 1 - cc.error,cc.assert,cc.warn,cc.log 将打å°åœ¨ console ä¸ã€‚ <br/> + 2 - cc.error,cc.assert,cc.warn 将打å°åœ¨ console ä¸ã€‚ <br/> + 3 - cc.error,cc.assert 将打å°åœ¨ console ä¸ã€‚ <br/> + 4 - cc.error,cc.assert,cc.warn,cc.log 将打å°åœ¨ canvas ä¸ï¼ˆä»…适用于 web 端)。 <br/> + 5 - cc.error,cc.assert,cc.warn 将打å°åœ¨ canvas ä¸ï¼ˆä»…适用于 web 端)。 <br/> + 6 - cc.error,cc.assert 将打å°åœ¨ canvas ä¸ï¼ˆä»…适用于 web 端)。 <br/> + 2. showFPS(显示 FPS) <br/> + 当 showFPS 为 true 的时候界é¢çš„左下角将显示 fps 的信æ¯ï¼Œå¦åˆ™è¢«éšè—。 <br/> + 3. exposeClassName <br/> + 暴露类å让 Chrome DevTools å¯ä»¥è¯†åˆ«ï¼Œå¦‚果开å¯ä¼šç¨ç¨é™ä½Žç±»çš„åˆ›å»ºè¿‡ç¨‹çš„æ€§èƒ½ï¼Œä½†å¯¹å¯¹è±¡æž„é€ æ²¡æœ‰å½±å“。 <br/> + 4. frameRate (帧率) <br/> + “frameRate†设置想è¦çš„å¸§çŽ‡ä½ çš„æ¸¸æˆï¼Œä½†çœŸæ£çš„FPSå–å†³äºŽä½ çš„æ¸¸æˆå®žçŽ°å’Œè¿è¡ŒçŽ¯å¢ƒã€‚ <br/> + 5. id <br/> + "gameCanvas" Web 页é¢ä¸Šçš„ Canvas Element ID,仅适用于 web 端。 <br/> + 6. renderMode(渲染模å¼ï¼‰ <br/> + “renderMode†设置渲染器类型,仅适用于 web 端: <br/> + 0 - 通过引擎自动选择。 <br/> + 1 - 强制使用 canvas 渲染。 + 2 - 强制使用 WebGL 渲染,但是在部分 Android æµè§ˆå™¨ä¸è¿™ä¸ªé€‰é¡¹ä¼šè¢«å¿½ç•¥ã€‚ <br/> + <br/> + 注æ„:请ä¸è¦ç›´æŽ¥ä¿®æ”¹è¿™ä¸ªå¯¹è±¡ï¼Œå®ƒä¸ä¼šæœ‰ä»»ä½•效果。 */ + config: any; /** - !#en Resume all playing audio. - !#zh æ¢å¤æ’æ”¾æ‰€æœ‰ä¹‹å‰æš‚åœçš„æ‰€æœ‰éŸ³é¢‘。 - - @example - ```js - cc.audioEngine.resumeAll(); - ``` + !#en Callback when the scripts of engine have been load. + !#zh 当引擎完æˆå¯åЍåŽçš„回调函数。 */ - static resumeAll(): void; + onStart(): void; /** - !#en Stop playing audio. - !#zh åœæ¢æ’放指定音频。 - @param audioID The return value of function play. - - @example - ```js - cc.audioEngine.stop(audioID); - ``` + !#en Set frame rate of game. + !#zh 设置游æˆå¸§çŽ‡ã€‚ + @param frameRate frameRate */ - static stop(audioID: number): void; + setFrameRate(frameRate: number): void; /** - !#en Stop all playing audio. - !#zh åœæ¢æ£åœ¨æ’放的所有音频。 - - @example - ```js - cc.audioEngine.stopAll(); - ``` + !#en Get frame rate set for the game, it doesn't represent the real frame rate. + !#zh 获å–设置的游æˆå¸§çŽ‡ï¼ˆä¸ç‰åŒäºŽå®žé™…帧率)。 */ - static stopAll(): void; + getFrameRate(): number; /** - !#en Set up an audio can generate a few examples. - !#zh 设置一个音频å¯ä»¥è®¾ç½®å‡ 个实例 - @param num a number of instances to be created from within an audio - - @example - ```js - cc.audioEngine.setMaxAudioInstance(20); - ``` + !#en Run the game frame by frame. + !#zh 执行一帧游æˆå¾ªçŽ¯ã€‚ */ - static setMaxAudioInstance(num: number): void; + step(): void; /** - !#en Getting audio can produce several examples. - !#zh 获å–一个音频å¯ä»¥è®¾ç½®å‡ 个实例 - - @example - ```js - cc.audioEngine.getMaxAudioInstance(); - ``` + !#en Pause the game main loop. This will pause: + game logic execution, rendering process, event manager, background music and all audio effects. + This is different with cc.director.pause which only pause the game logic execution. + !#zh æš‚åœæ¸¸æˆä¸»å¾ªçŽ¯ã€‚åŒ…å«ï¼šæ¸¸æˆé€»è¾‘,渲染,事件处ç†ï¼ŒèƒŒæ™¯éŸ³ä¹å’Œæ‰€æœ‰éŸ³æ•ˆã€‚è¿™ç‚¹å’Œåªæš‚åœæ¸¸æˆé€»è¾‘çš„ cc.director.pause ä¸åŒã€‚ */ - static getMaxAudioInstance(): number; + pause(): void; /** - !#en Unload the preloaded audio from internal buffer. - !#zh å¸è½½é¢„åŠ è½½çš„éŸ³é¢‘ã€‚ - @param clip clip - - @example - ```js - cc.audioEngine.uncache(filePath); - ``` + !#en Resume the game from pause. This will resume: + game logic execution, rendering process, event manager, background music and all audio effects. + !#zh æ¢å¤æ¸¸æˆä¸»å¾ªçŽ¯ã€‚åŒ…å«ï¼šæ¸¸æˆé€»è¾‘,渲染,事件处ç†ï¼ŒèƒŒæ™¯éŸ³ä¹å’Œæ‰€æœ‰éŸ³æ•ˆã€‚ */ - static uncache(clip: AudioClip): void; + resume(): void; /** - !#en Unload all audio from internal buffer. - !#zh å¸è½½æ‰€æœ‰éŸ³é¢‘。 - - @example - ```js - cc.audioEngine.uncacheAll(); - ``` + !#en Check whether the game is paused. + !#zh åˆ¤æ–æ¸¸æˆæ˜¯å¦æš‚åœã€‚ */ - static uncacheAll(): void; + isPaused(): boolean; /** - !#en Play background music - !#zh æ’æ”¾èƒŒæ™¯éŸ³ä¹ - @param clip The audio clip to play. - @param loop Whether the music loop or not. - - @example - ```js - cc.resources.load(path, cc.AudioClip, null, function (err, clip) { - var audioID = cc.audioEngine.playMusic(clip, false); - }); - ``` + !#en Restart game. + !#zh 釿–°å¼€å§‹æ¸¸æˆ */ - static playMusic(clip: AudioClip, loop: boolean): number; + restart(): void; /** - !#en Stop background music. - !#zh åœæ¢æ’放背景音ä¹ã€‚ - - @example - ```js - cc.audioEngine.stopMusic(); - ``` + !#en End game, it will close the game window + !#zh é€€å‡ºæ¸¸æˆ */ - static stopMusic(): void; + end(): void; /** - !#en Pause the background music. - !#zh æš‚åœæ’放背景音ä¹ã€‚ - - @example - ```js - cc.audioEngine.pauseMusic(); - ``` + !#en + Register an callback of a specific event type on the game object. + This type of event should be triggered via `emit`. + !#zh + 注册 game 的特定事件类型回调。这ç§ç±»åž‹çš„事件应该被 `emit` 触å‘。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null */ - static pauseMusic(): void; + on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T; /** - !#en Resume playing background music. - !#zh æ¢å¤æ’放背景音ä¹ã€‚ - - @example - ```js - cc.audioEngine.resumeMusic(); - ``` + !#en + Register an callback of a specific event type on the game object, + the callback will remove itself after the first time it is triggered. + !#zh + 注册 game 的特定事件类型回调,回调会在第一时间被触å‘åŽåˆ 除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null */ - static resumeMusic(): void; + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; /** - !#en Get the volume(0.0 ~ 1.0). - !#zh 获å–音é‡ï¼ˆ0.0 ~ 1.0)。 - - @example - ```js - var volume = cc.audioEngine.getMusicVolume(); - ``` + !#en Prepare game. + !#zh 准备引擎,请ä¸è¦ç›´æŽ¥è°ƒç”¨è¿™ä¸ªå‡½æ•°ã€‚ + @param cb cb */ - static getMusicVolume(): number; + prepare(cb: Function): void; /** - !#en Set the background music volume. - !#zh 设置背景音ä¹éŸ³é‡ï¼ˆ0.0 ~ 1.0)。 - @param volume Volume must be in 0.0~1.0. - - @example - ```js - cc.audioEngine.setMusicVolume(0.5); - ``` + !#en Run game with configuration object and onStart function. + !#zh è¿è¡Œæ¸¸æˆï¼Œå¹¶ä¸”指定引擎é…置和 onStart 的回调。 + @param config Pass configuration object or onStart function + @param onStart function to be executed after game initialized */ - static setMusicVolume(volume: number): void; + run(config: any, onStart: Function): void; /** - !#en Background music playing state - !#zh èƒŒæ™¯éŸ³ä¹æ˜¯å¦æ£åœ¨æ’放 - - @example - ```js - cc.audioEngine.isMusicPlaying(); - ``` + !#en + Add a persistent root node to the game, the persistent node won't be destroyed during scene transition.<br/> + The target node must be placed in the root level of hierarchy, otherwise this API won't have any effect. + !#zh + å£°æ˜Žå¸¸é©»æ ¹èŠ‚ç‚¹ï¼Œè¯¥èŠ‚ç‚¹ä¸ä¼šè¢«åœ¨åœºæ™¯åˆ‡æ¢ä¸è¢«é”€æ¯ã€‚<br/> + ç›®æ ‡èŠ‚ç‚¹å¿…é¡»ä½äºŽä¸ºå±‚çº§çš„æ ¹èŠ‚ç‚¹ï¼Œå¦åˆ™æ— 效。 + @param node The node to be made persistent */ - static isMusicPlaying(): boolean; + addPersistRootNode(node: Node): void; /** - !#en Play effect audio. - !#zh æ’æ”¾éŸ³æ•ˆ - @param clip The audio clip to play. - @param loop Whether the music loop or not. - - @example - ```js - cc.resources.load(path, cc.AudioClip, null, function (err, clip) { - var audioID = cc.audioEngine.playEffect(clip, false); - }); - ``` + !#en Remove a persistent root node. + !#zh å–æ¶ˆå¸¸é©»æ ¹èŠ‚ç‚¹ã€‚ + @param node The node to be removed from persistent node list */ - static playEffect(clip: AudioClip, loop: boolean): number; + removePersistRootNode(node: Node): void; /** - !#en Set the volume of effect audio. - !#zh 设置音效音é‡ï¼ˆ0.0 ~ 1.0)。 - @param volume Volume must be in 0.0~1.0. - - @example - ```js - cc.audioEngine.setEffectsVolume(0.5); - ``` + !#en Check whether the node is a persistent root node. + !#zh æ£€æŸ¥èŠ‚ç‚¹æ˜¯å¦æ˜¯å¸¸é©»æ ¹èŠ‚ç‚¹ã€‚ + @param node The node to be checked */ - static setEffectsVolume(volume: number): void; + isPersistRootNode(node: Node): boolean; + } + /** !#en + Class of all entities in Cocos Creator scenes.<br/> + For events supported by Node, please refer to {{#crossLink "Node.EventType"}}{{/crossLink}} + !#zh + Cocos Creator 场景ä¸çš„æ‰€æœ‰èŠ‚ç‚¹ç±»ã€‚<br/> + 支æŒçš„节点事件,请å‚阅 {{#crossLink "Node.EventType"}}{{/crossLink}}。 */ + export class Node extends _BaseNode { + /** !#en + Group index of node.<br/> + Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.<br/> + !#zh + 节点的分组索引。<br/> + 节点的分组将关系到节点的碰撞组件å¯ä»¥ä¸Žå“ªäº›ç¢°æ’žç»„件相碰撞。<br/> */ + groupIndex: number; + /** !#en + Group of node.<br/> + Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.<br/> + !#zh + 节点的分组。<br/> + 节点的分组将关系到节点的碰撞组件å¯ä»¥ä¸Žå“ªäº›ç¢°æ’žç»„件相碰撞。<br/> */ + group: string; + /** !#en The position (x, y) of the node in its parent's coordinates. + !#zh èŠ‚ç‚¹åœ¨çˆ¶èŠ‚ç‚¹åæ ‡ç³»ä¸çš„ä½ç½®ï¼ˆx, y)。 */ + position: Vec3; + /** !#en x axis position of node. + !#zh 节点 X è½´åæ ‡ã€‚ */ + x: number; + /** !#en y axis position of node. + !#zh 节点 Y è½´åæ ‡ã€‚ */ + y: number; + /** !#en z axis position of node. + !#zh 节点 Z è½´åæ ‡ã€‚ */ + z: number; + /** !#en Rotation of node. + !#zh 该节点旋转角度。 */ + rotation: number; + /** !#en + Angle of node, the positive value is anti-clockwise direction. + !#zh + 该节点的旋转角度,æ£å€¼ä¸ºé€†æ—¶é’ˆæ–¹å‘。 */ + angle: number; + /** !#en The rotation as Euler angles in degrees, used in 3D node. + !#zh 该节点的欧拉角度,用于 3D 节点。 */ + eulerAngles: Vec3; + /** !#en Rotation on x axis. + !#zh 该节点 X 轴旋转角度。 */ + rotationX: number; + /** !#en Rotation on y axis. + !#zh 该节点 Y 轴旋转角度。 */ + rotationY: number; + /** !#en The local scale relative to the parent. + !#zh 节点相对父节点的缩放。 */ + scale: number; + /** !#en Scale on x axis. + !#zh 节点 X 轴缩放。 */ + scaleX: number; + /** !#en Scale on y axis. + !#zh 节点 Y 轴缩放。 */ + scaleY: number; + /** !#en Scale on z axis. + !#zh 节点 Z 轴缩放。 */ + scaleZ: number; + /** !#en Skew x + !#zh 该节点 X 轴倾斜角度。 */ + skewX: number; + /** !#en Skew y + !#zh 该节点 Y 轴倾斜角度。 */ + skewY: number; + /** !#en Opacity of node, default value is 255. + !#zh èŠ‚ç‚¹é€æ˜Žåº¦ï¼Œé»˜è®¤å€¼ä¸º 255。 */ + opacity: number; + /** !#en Color of node, default value is white: (255, 255, 255). + !#zh 节点颜色。默认为白色,数值为:(255,255,255)。 */ + color: Color; + /** !#en Anchor point's position on x axis. + !#zh 节点 X 轴锚点ä½ç½®ã€‚ */ + anchorX: number; + /** !#en Anchor point's position on y axis. + !#zh 节点 Y 轴锚点ä½ç½®ã€‚ */ + anchorY: number; + /** !#en Width of node. + !#zh 节点宽度。 */ + width: number; + /** !#en Height of node. + !#zh 节点高度。 */ + height: number; + /** !#en zIndex is the 'key' used to sort the node relative to its siblings.<br/> + The value of zIndex should be in the range between cc.macro.MIN_ZINDEX and cc.macro.MAX_ZINDEX.<br/> + The Node's parent will sort all its children based on the zIndex value and the arrival order.<br/> + Nodes with greater zIndex will be sorted after nodes with smaller zIndex.<br/> + If two nodes have the same zIndex, then the node that was added first to the children's array will be in front of the other node in the array.<br/> + Node's order in children list will affect its rendering order. Parent is always rendering before all children. + !#zh zIndex 是用æ¥å¯¹èŠ‚ç‚¹è¿›è¡ŒæŽ’åºçš„关键属性,它决定一个节点在兄弟节点之间的ä½ç½®ã€‚<br/> + zIndex çš„å–值应该介于 cc.macro.MIN_ZINDEX å’Œ cc.macro.MAX_ZINDEX 之间 + çˆ¶èŠ‚ç‚¹ä¸»è¦æ ¹æ®èŠ‚ç‚¹çš„ zIndex å’Œæ·»åŠ æ¬¡åºæ¥æŽ’åºï¼Œæ‹¥æœ‰æ›´é«˜ zIndex 的节点将被排在åŽé¢ï¼Œå¦‚果两个节点的 zIndex ä¸€è‡´ï¼Œå…ˆæ·»åŠ çš„èŠ‚ç‚¹ä¼šç¨³å®šæŽ’åœ¨å¦ä¸€ä¸ªèŠ‚ç‚¹ä¹‹å‰ã€‚<br/> + 节点在 children ä¸çš„顺åºå†³å®šäº†å…¶æ¸²æŸ“顺åºã€‚父节点永远在所有å节点之å‰è¢«æ¸²æŸ“ */ + zIndex: number; + /** !#en + Switch 2D/3D node. The 2D nodes will run faster. + !#zh + åˆ‡æ¢ 2D/3D 节点,2D 节点会有更高的è¿è¡Œæ•ˆçއ */ + is3DNode: boolean; + /** !#en Returns a normalized vector representing the up direction (Y axis) of the node in world space. + !#zh 获å–节点æ£ä¸Šæ–¹ï¼ˆy 轴)é¢å¯¹çš„æ–¹å‘ï¼Œè¿”å›žå€¼ä¸ºä¸–ç•Œåæ ‡ç³»ä¸‹çš„归一化å‘é‡ */ + up: Vec3; + /** !#en Returns a normalized vector representing the right direction (X axis) of the node in world space. + !#zh 获å–节点æ£å³æ–¹ï¼ˆx 轴)é¢å¯¹çš„æ–¹å‘ï¼Œè¿”å›žå€¼ä¸ºä¸–ç•Œåæ ‡ç³»ä¸‹çš„归一化å‘é‡ */ + right: Vec3; + /** !#en Returns a normalized vector representing the forward direction (Z axis) of the node in world space. + !#zh 获å–节点æ£å‰æ–¹ï¼ˆz 轴)é¢å¯¹çš„æ–¹å‘ï¼Œè¿”å›žå€¼ä¸ºä¸–ç•Œåæ ‡ç³»ä¸‹çš„归一化å‘é‡ */ + forward: Vec3; /** - !#en The volume of the effect audio max value is 1.0,the min value is 0.0 . - !#zh 获å–音效音é‡ï¼ˆ0.0 ~ 1.0)。 - @example - ```js - var volume = cc.audioEngine.getEffectsVolume(); - ``` + @param name name */ - static getEffectsVolume(): number; + constructor(name?: string); /** - !#en Pause effect audio. - !#zh æš‚åœæ’放音效。 - @param audioID audio id. + !#en + Register a callback of a specific event type on Node.<br/> + Use this method to register touch or mouse event permit propagation based on scene graph,<br/> + These kinds of event are triggered with dispatchEvent, the dispatch process has three steps:<br/> + 1. Capturing phase: dispatch in capture targets (`_getCapturingTargets`), e.g. parents in node tree, from root to the real target<br/> + 2. At target phase: dispatch to the listeners of the real target<br/> + 3. Bubbling phase: dispatch in bubble targets (`_getBubblingTargets`), e.g. parents in node tree, from the real target to root<br/> + In any moment of the dispatching process, it can be stopped via `event.stopPropagation()` or `event.stopPropagationImmidiate()`.<br/> + It's the recommended way to register touch/mouse event for Node,<br/> + please do not use cc.eventManager directly for Node.<br/> + You can also register custom event and use `emit` to trigger custom event on Node.<br/> + For such events, there won't be capturing and bubbling phase, your event will be dispatched directly to its listeners registered on the same node.<br/> + You can also pass event callback parameters with `emit` by passing parameters after `type`. + !#zh + 在节点上注册指定类型的回调函数,也å¯ä»¥è®¾ç½® target 用于绑定å“应函数的 this 对象。<br/> + é¼ æ ‡æˆ–è§¦æ‘¸äº‹ä»¶ä¼šè¢«ç³»ç»Ÿè°ƒç”¨ dispatchEvent 方法触å‘,触å‘的过程包å«ä¸‰ä¸ªé˜¶æ®µï¼š<br/> + 1. æ•获阶段:派å‘事件给æ•èŽ·ç›®æ ‡ï¼ˆé€šè¿‡ `_getCapturingTargets` 获å–ï¼‰ï¼Œæ¯”å¦‚ï¼ŒèŠ‚ç‚¹æ ‘ä¸æ³¨å†Œäº†æ•èŽ·é˜¶æ®µçš„çˆ¶èŠ‚ç‚¹ï¼Œä»Žæ ¹èŠ‚ç‚¹å¼€å§‹æ´¾å‘ç›´åˆ°ç›®æ ‡èŠ‚ç‚¹ã€‚<br/> + 2. ç›®æ ‡é˜¶æ®µï¼šæ´¾å‘ç»™ç›®æ ‡èŠ‚ç‚¹çš„ç›‘å¬å™¨ã€‚<br/> + 3. 冒泡阶段:派å‘äº‹ä»¶ç»™å†’æ³¡ç›®æ ‡ï¼ˆé€šè¿‡ `_getBubblingTargets` 获å–ï¼‰ï¼Œæ¯”å¦‚ï¼ŒèŠ‚ç‚¹æ ‘ä¸æ³¨å†Œäº†å†’æ³¡é˜¶æ®µçš„çˆ¶èŠ‚ç‚¹ï¼Œä»Žç›®æ ‡èŠ‚ç‚¹å¼€å§‹æ´¾å‘ç›´åˆ°æ ¹èŠ‚ç‚¹ã€‚<br/> + åŒæ—¶æ‚¨å¯ä»¥å°†äº‹ä»¶æ´¾å‘到父节点或者通过调用 stopPropagation 拦截它。<br/> + 推èä½¿ç”¨è¿™ç§æ–¹å¼æ¥ç›‘å¬èŠ‚ç‚¹ä¸Šçš„è§¦æ‘¸æˆ–é¼ æ ‡äº‹ä»¶ï¼Œè¯·ä¸è¦åœ¨èŠ‚ç‚¹ä¸Šç›´æŽ¥ä½¿ç”¨ cc.eventManager。<br/> + ä½ ä¹Ÿå¯ä»¥æ³¨å†Œè‡ªå®šä¹‰äº‹ä»¶åˆ°èŠ‚ç‚¹ä¸Šï¼Œå¹¶é€šè¿‡ emit æ–¹æ³•è§¦å‘æ¤ç±»äº‹ä»¶ï¼Œå¯¹äºŽè¿™ç±»äº‹ä»¶ï¼Œä¸ä¼šå‘生æ•获冒泡阶段,åªä¼šç›´æŽ¥æ´¾å‘给注册在该节点上的监å¬å™¨<br/> + ä½ å¯ä»¥é€šè¿‡åœ¨ emit 方法调用时在 type 之åŽä¼ 递é¢å¤–çš„å‚æ•°ä½œä¸ºäº‹ä»¶å›žè°ƒçš„傿•°åˆ—表 + @param type A string representing the event type to listen for.<br>See {{#crossLink "Node/EventTyupe/POSITION_CHANGED"}}Node Events{{/crossLink}} for all builtin events. + @param callback The callback that will be invoked when the event is dispatched. The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase. @example ```js - cc.audioEngine.pauseEffect(audioID); + this.node.on(cc.Node.EventType.TOUCH_START, this.memberFunction, this); // if "this" is component and the "memberFunction" declared in CCClass. + node.on(cc.Node.EventType.TOUCH_START, callback, this); + node.on(cc.Node.EventType.TOUCH_MOVE, callback, this); + node.on(cc.Node.EventType.TOUCH_END, callback, this); + node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this); + node.on(cc.Node.EventType.ANCHOR_CHANGED, callback); + node.on(cc.Node.EventType.COLOR_CHANGED, callback); ``` */ - static pauseEffect(audioID: number): void; + on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T; /** - !#en Stop playing all the sound effects. - !#zh æš‚åœæ’放所有音效。 + !#en + Register an callback of a specific event type on the Node, + the callback will remove itself after the first time it is triggered. + !#zh + 注册节点的特定事件类型回调,回调会在第一时间被触å‘åŽåˆ 除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null @example ```js - cc.audioEngine.pauseAllEffects(); + node.once(cc.Node.EventType.ANCHOR_CHANGED, callback); ``` */ - static pauseAllEffects(): void; + once<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T; /** - !#en Resume effect audio. - !#zh æ¢å¤æ’放音效音频。 - @param audioID The return value of function play. + !#en + Removes the callback previously registered with the same type, callback, target and or useCapture. + This method is merely an alias to removeEventListener. + !#zh åˆ é™¤ä¹‹å‰ä¸ŽåŒç±»åž‹ï¼Œå›žè°ƒï¼Œç›®æ ‡æˆ– useCapture 注册的回调。 + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase. @example ```js - cc.audioEngine.resumeEffect(audioID); + this.node.off(cc.Node.EventType.TOUCH_START, this.memberFunction, this); + node.off(cc.Node.EventType.TOUCH_START, callback, this.node); + node.off(cc.Node.EventType.ANCHOR_CHANGED, callback, this); ``` */ - static resumeEffect(audioID: number): void; + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; /** - !#en Resume all effect audio. - !#zh æ¢å¤æ’æ”¾æ‰€æœ‰ä¹‹å‰æš‚åœçš„音效。 + !#en Removes all callbacks previously registered with the same target. + !#zh ç§»é™¤ç›®æ ‡ä¸Šçš„æ‰€æœ‰æ³¨å†Œäº‹ä»¶ã€‚ + @param target The target to be searched for all related callbacks @example ```js - cc.audioEngine.resumeAllEffects(); + node.targetOff(target); ``` */ - static resumeAllEffects(): void; + targetOff(target: any): void; /** - !#en Stop playing the effect audio. - !#zh åœæ¢æ’放音效。 - @param audioID audio id. - - @example - ```js - cc.audioEngine.stopEffect(id); - ``` + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh æ£€æŸ¥äº‹ä»¶ç›®æ ‡å¯¹è±¡æ˜¯å¦æœ‰ä¸ºç‰¹å®šç±»åž‹çš„事件注册的回调。 + @param type The type of event. */ - static stopEffect(audioID: number): void; + hasEventListener(type: string): boolean; /** - !#en Stop playing all the effects. - !#zh åœæ¢æ’放所有音效。 + !#en + Trigger an event directly with the event name and necessary arguments. + !#zh + 通过事件åå‘é€è‡ªå®šä¹‰äº‹ä»¶ + @param type event type + @param arg1 First argument in callback + @param arg2 Second argument in callback + @param arg3 Third argument in callback + @param arg4 Fourth argument in callback + @param arg5 Fifth argument in callback @example ```js - cc.audioEngine.stopAllEffects(); + eventTarget.emit('fire', event); + eventTarget.emit('fire', message, emitter); ``` */ - static stopAllEffects(): void; - } - /** !#en cc.WebView is a component for display web pages in the game. Because different platforms have different authorization, API and control methods for WebView component. And have not yet formed a unified standard, only Web, iOS, and Android platforms are currently supported. - !#zh WebView 组件,用于在游æˆä¸æ˜¾ç¤ºç½‘页。由于ä¸åŒå¹³å°å¯¹äºŽ WebView 组件的授æƒã€APIã€æŽ§åˆ¶æ–¹å¼éƒ½ä¸åŒï¼Œè¿˜æ²¡æœ‰å½¢æˆç»Ÿä¸€çš„æ ‡å‡†ï¼Œæ‰€ä»¥ç›®å‰åªæ”¯æŒ Webã€iOS å’Œ Android å¹³å°ã€‚ */ - export class WebView extends Component { - /** !#en A given URL to be loaded by the WebView, it should have a http or https prefix. - !#zh 指定 WebView åŠ è½½çš„ç½‘å€ï¼Œå®ƒåº”该是一个 http 或者 https 开头的å—符串 */ - url: string; - /** !#en The webview's event callback , it will be triggered when certain webview event occurs. - !#zh WebView çš„å›žè°ƒäº‹ä»¶ï¼Œå½“ç½‘é¡µåŠ è½½è¿‡ç¨‹ä¸ï¼ŒåŠ è½½å®ŒæˆåŽæˆ–è€…åŠ è½½å‡ºé”™æ—¶éƒ½ä¼šå›žè°ƒæ¤å‡½æ•° */ - webviewLoadedEvents: Component.EventHandler[]; - /** - !#en - Set javascript interface scheme (see also setOnJSCallback). <br/> - Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.<br/> - Please refer to the official documentation for more details. - !#zh - 设置 JavaScript æŽ¥å£æ–¹æ¡ˆï¼ˆä¸Ž 'setOnJSCallback' é…套使用)。<br/> - 注æ„ï¼šåªæ”¯æŒ Android å’Œ iOS ,Web 端用法请å‰å¾€å®˜æ–¹æ–‡æ¡£æŸ¥çœ‹ã€‚<br/> - 详情请å‚阅官方文档 - @param scheme scheme - */ - setJavascriptInterfaceScheme(scheme: string): void; - /** - !#en - This callback called when load URL that start with javascript - interface scheme (see also setJavascriptInterfaceScheme). <br/> - Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.<br/> - Please refer to the official documentation for more details. - !#zh - å½“åŠ è½½ URL 以 JavaScript æŽ¥å£æ–¹æ¡ˆå¼€å§‹æ—¶è°ƒç”¨è¿™ä¸ªå›žè°ƒå‡½æ•°ã€‚<br/> - 注æ„ï¼šåªæ”¯æŒ Android å’Œ iOS,Web 端用法请å‰å¾€å®˜æ–¹æ–‡æ¡£æŸ¥çœ‹ã€‚ - 详情请å‚阅官方文档 - @param callback callback - */ - setOnJSCallback(callback: Function): void; + emit(type: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any): void; /** !#en - Evaluates JavaScript in the context of the currently displayed page. <br/> - Please refer to the official document for more details <br/> - Note: Cross domain issues need to be resolved by yourself <br/> - !#zh - 执行 WebView 内部页é¢è„šæœ¬ï¼ˆè¯¦æƒ…è¯·å‚阅官方文档) <br/> - 注æ„:需è¦è‡ªè¡Œè§£å†³è·¨åŸŸé—®é¢˜ - @param str str + Dispatches an event into the event flow. + The event target is the EventTarget object upon which the dispatchEvent() method is called. + !#zh 分å‘事件到事件æµä¸ã€‚ + @param event The Event object that is dispatched into the event flow */ - evaluateJS(str: string): void; + dispatchEvent(event: Event): void; /** - !#en if you don't need the WebView and it isn't in any running Scene, you should - call the destroy method on this component or the associated node explicitly. - Otherwise, the created DOM element won't be removed from web page. - !#zh - å¦‚æžœä½ ä¸å†ä½¿ç”¨ WebViewï¼Œå¹¶ä¸”ç»„ä»¶æœªæ·»åŠ åˆ°åœºæ™¯ä¸ï¼Œé‚£ä¹ˆä½ 必须手动对组件或所在节点调用 destroy。 - è¿™æ ·æ‰èƒ½ç§»é™¤ç½‘页上的 DOM 节点,é¿å… Web å¹³å°å†…å˜æ³„露。 + !#en Pause node related system events registered with the current Node. Node system events includes touch and mouse events. + If recursive is set to true, then this API will pause the node system events for the node and all nodes in its sub node tree. + Reference: http://docs.cocos2d-x.org/editors_and_tools/creator-chapters/scripting/internal-events/ + !#zh æš‚åœå½“å‰èŠ‚ç‚¹ä¸Šæ³¨å†Œçš„æ‰€æœ‰èŠ‚ç‚¹ç³»ç»Ÿäº‹ä»¶ï¼ŒèŠ‚ç‚¹ç³»ç»Ÿäº‹ä»¶åŒ…å«è§¦æ‘¸å’Œé¼ æ ‡äº‹ä»¶ã€‚ + å¦‚æžœä¼ é€’ recursive 为 true,那么这个 API å°†æš‚åœæœ¬èŠ‚ç‚¹å’Œå®ƒçš„åæ ‘上所有节点的节点系统事件。 + å‚考:https://www.cocos.com/docs/creator/scripting/internal-events.html + @param recursive Whether to pause node system events on the sub node tree. @example ```js - webview.node.parent = null; // or webview.node.removeFromParent(false); - // when you don't need webview anymore - webview.node.destroy(); + node.pauseSystemEvents(true); ``` */ - destroy(): boolean; - } - /** !#en cc.VideoPlayer is a component for playing videos, you can use it for showing videos in your game. Because different platforms have different authorization, API and control methods for VideoPlayer component. And have not yet formed a unified standard, only Web, iOS, and Android platforms are currently supported. - !#zh Video 组件,用于在游æˆä¸æ’放视频。由于ä¸åŒå¹³å°å¯¹äºŽ VideoPlayer 组件的授æƒã€APIã€æŽ§åˆ¶æ–¹å¼éƒ½ä¸åŒï¼Œè¿˜æ²¡æœ‰å½¢æˆç»Ÿä¸€çš„æ ‡å‡†ï¼Œæ‰€ä»¥ç›®å‰åªæ”¯æŒ Webã€iOS å’Œ Android å¹³å°ã€‚ */ - export class VideoPlayer extends Component { - /** !#en The resource type of videoplayer, REMOTE for remote url and LOCAL for local file path. - !#zh è§†é¢‘æ¥æºï¼šREMOTE 表示远程视频 URL,LOCAL 表示本地视频地å€ã€‚ */ - resourceType: VideoPlayer.ResourceType; - /** !#en The remote URL of video. - !#zh 远程视频的 URL */ - remoteURL: string; - /** !#en The local video full path. - !#zh 本地视频的 URL */ - clip: string; - /** !#en The current playback time of the now playing item in seconds, you could also change the start playback time. - !#zh æŒ‡å®šè§†é¢‘ä»Žä»€ä¹ˆæ—¶é—´ç‚¹å¼€å§‹æ’æ”¾ï¼Œå•使˜¯ç§’,也å¯ä»¥ç”¨æ¥èŽ·å–当å‰è§†é¢‘æ’æ”¾çš„æ—¶é—´è¿›åº¦ã€‚ */ - currentTime: number; - /** !#en The volume of the video. - !#zh 视频的音é‡ï¼ˆ0.0 ~ 1.0) */ - volume: number; - /** !#en Mutes the VideoPlayer. Mute sets the volume=0, Un-Mute restore the original volume. - !#zh 是å¦é™éŸ³è§†é¢‘。é™éŸ³æ—¶è®¾ç½®éŸ³é‡ä¸º 0ï¼Œå–æ¶ˆé™éŸ³æ˜¯æ¢å¤åŽŸæ¥çš„音é‡ã€‚ */ - mute: boolean; - /** !#en Whether keep the aspect ration of the original video. - !#zh 是å¦ä¿æŒè§†é¢‘原æ¥çš„宽高比 */ - keepAspectRatio: boolean; - /** !#en Whether play video in fullscreen mode. - !#zh 是å¦å…¨å±æ’放视频 */ - isFullscreen: boolean; - /** !#en Always below the game view (only useful on Web. Note: The specific effects are not guaranteed to be consistent, depending on whether each browser supports or restricts). - !#zh 永远在游æˆè§†å›¾æœ€åº•å±‚ï¼ˆè¿™ä¸ªå±žæ€§åªæœ‰åœ¨ Web å¹³å°ä¸Šæœ‰æ•ˆæžœã€‚注æ„ï¼šå…·ä½“æ•ˆæžœæ— æ³•ä¿è¯ä¸€è‡´ï¼Œè·Ÿå„个æµè§ˆå™¨æ˜¯å¦æ”¯æŒä¸Žé™åˆ¶æœ‰å…³ï¼‰ */ - stayOnBottom: boolean; - /** !#en the video player's callback, it will be triggered when certain event occurs, like: playing, paused, stopped and completed. - !#zh è§†é¢‘æ’æ”¾å›žè°ƒå‡½æ•°ï¼Œè¯¥å›žè°ƒå‡½æ•°ä¼šåœ¨ç‰¹å®šæƒ…况被触å‘ï¼Œæ¯”å¦‚æ’æ”¾ä¸ï¼Œæš‚æ—¶ï¼Œåœæ¢å’Œå®Œæˆæ’放。 */ - videoPlayerEvent: Component.EventHandler[]; - /** - !#en If a video is paused, call this method could resume playing. If a video is stopped, call this method to play from scratch. - !#zh å¦‚æžœè§†é¢‘è¢«æš‚åœæ’放了,调用这个接å£å¯ä»¥ç»§ç»æ’æ”¾ã€‚å¦‚æžœè§†é¢‘è¢«åœæ¢æ’放了,调用这个接å£å¯ä»¥ä»Žå¤´å¼€å§‹æ’放。 - */ - play(): void; - /** - !#en If a video is paused, call this method to resume playing. - !#zh å¦‚æžœä¸€ä¸ªè§†é¢‘æ’æ”¾è¢«æš‚åœæ’放了,调用这个接å£å¯ä»¥ç»§ç»æ’放。 - */ - resume(): void; - /** - !#en If a video is playing, call this method to pause playing. - !#zh 如果一个视频æ£åœ¨æ’放,调用这个接å£å¯ä»¥æš‚åœæ’放。 - */ - pause(): void; - /** - !#en If a video is playing, call this method to stop playing immediately. - !#zh 如果一个视频æ£åœ¨æ’放,调用这个接å£å¯ä»¥ç«‹é©¬åœæ¢æ’放。 - */ - stop(): void; - /** - !#en Gets the duration of the video - !#zh 获å–è§†é¢‘æ–‡ä»¶çš„æ’æ”¾æ€»æ—¶é•¿ - */ - getDuration(): number; + pauseSystemEvents(recursive: boolean): void; /** - !#en Determine whether video is playing or not. - !#zh 判æ–当å‰è§†é¢‘是å¦å¤„äºŽæ’æ”¾çŠ¶æ€ + !#en Resume node related system events registered with the current Node. Node system events includes touch and mouse events. + If recursive is set to true, then this API will resume the node system events for the node and all nodes in its sub node tree. + Reference: http://docs.cocos2d-x.org/editors_and_tools/creator-chapters/scripting/internal-events/ + !#zh æ¢å¤å½“å‰èŠ‚ç‚¹ä¸Šæ³¨å†Œçš„æ‰€æœ‰èŠ‚ç‚¹ç³»ç»Ÿäº‹ä»¶ï¼ŒèŠ‚ç‚¹ç³»ç»Ÿäº‹ä»¶åŒ…å«è§¦æ‘¸å’Œé¼ æ ‡äº‹ä»¶ã€‚ + å¦‚æžœä¼ é€’ recursive 为 true,那么这个 API å°†æ¢å¤æœ¬èŠ‚ç‚¹å’Œå®ƒçš„åæ ‘上所有节点的节点系统事件。 + å‚考:https://www.cocos.com/docs/creator/scripting/internal-events.html + @param recursive Whether to resume node system events on the sub node tree. + + @example + ```js + node.resumeSystemEvents(true); + ``` */ - isPlaying(): boolean; + resumeSystemEvents(recursive: boolean): void; /** - !#en if you don't need the VideoPlayer and it isn't in any running Scene, you should - call the destroy method on this component or the associated node explicitly. - Otherwise, the created DOM element won't be removed from web page. + !#en + Executes an action, and returns the action that is executed.<br/> + The node becomes the action's target. Refer to cc.Action's getTarget() <br/> + Calling runAction while the node is not active won't have any effect. <br/> + Note:You shouldn't modify the action after runAction, that won't take any effect.<br/> + if you want to modify, when you define action plus. !#zh - å¦‚æžœä½ ä¸å†ä½¿ç”¨ VideoPlayerï¼Œå¹¶ä¸”ç»„ä»¶æœªæ·»åŠ åˆ°åœºæ™¯ä¸ï¼Œé‚£ä¹ˆä½ 必须手动对组件或所在节点调用 destroy。 - è¿™æ ·æ‰èƒ½ç§»é™¤ç½‘页上的 DOM 节点,é¿å… Web å¹³å°å†…å˜æ³„露。 + æ‰§è¡Œå¹¶è¿”å›žè¯¥æ‰§è¡Œçš„åŠ¨ä½œã€‚è¯¥èŠ‚ç‚¹å°†ä¼šå˜æˆåŠ¨ä½œçš„ç›®æ ‡ã€‚<br/> + 调用 runAction æ—¶ï¼ŒèŠ‚ç‚¹è‡ªèº«å¤„äºŽä¸æ¿€æ´»çжæ€å°†ä¸ä¼šæœ‰ä»»ä½•效果。<br/> + 注æ„ï¼šä½ ä¸åº”该修改 runAction åŽçš„åŠ¨ä½œï¼Œå°†æ— æ³•å‘æŒ¥ä½œç”¨ï¼Œå¦‚果想进行修改,请在定义 action æ—¶åŠ å…¥ã€‚ + @param action action @example ```js - videoplayer.node.parent = null; // or videoplayer.node.removeFromParent(false); - // when you don't need videoplayer anymore - videoplayer.node.destroy(); + var action = cc.scaleTo(0.2, 1, 0.6); + node.runAction(action); + node.runAction(action).repeatForever(); // fail + node.runAction(action.repeatForever()); // right ``` */ - destroy(): boolean; - } - /** !#en - cc.NodePool is the cache pool designed for node type.<br/> - It can helps you to improve your game performance for objects which need frequent release and recreate operations<br/> - - It's recommended to create cc.NodePool instances by node type, the type corresponds to node type in game design, not the class, - for example, a prefab is a specific node type. <br/> - When you create a node pool, you can pass a Component which contains `unuse`, `reuse` functions to control the content of node.<br/> - - Some common use case is :<br/> - 1. Bullets in game (die very soon, massive creation and recreation, no side effect on other objects)<br/> - 2. Blocks in candy crash (massive creation and recreation)<br/> - etc... - !#zh - cc.NodePool 是用于管ç†èŠ‚ç‚¹å¯¹è±¡çš„å¯¹è±¡ç¼“å˜æ± 。<br/> - 它å¯ä»¥å¸®åŠ©æ‚¨æé«˜æ¸¸æˆæ€§èƒ½ï¼Œé€‚用于优化对象的åå¤åˆ›å»ºå’Œé”€æ¯<br/> - ä»¥å‰ cocos2d-x ä¸çš„ cc.pool 和新的节点事件注册系统ä¸å…¼å®¹ï¼Œå› æ¤è¯·ä½¿ç”¨ cc.NodePool æ¥ä»£æ›¿ã€‚ - - æ–°çš„ NodePool 需è¦å®žä¾‹åŒ–ä¹‹åŽæ‰èƒ½ä½¿ç”¨ï¼Œæ¯ç§ä¸åŒçš„èŠ‚ç‚¹å¯¹è±¡æ± éœ€è¦ä¸€ä¸ªä¸åŒçš„å¯¹è±¡æ± å®žä¾‹ï¼Œè¿™é‡Œçš„ç§ç±»å¯¹åº”于游æˆä¸çš„节点设计,一个 prefab 相当于一个ç§ç±»çš„节点。<br/> - åœ¨åˆ›å»ºç¼“å†²æ± æ—¶ï¼Œå¯ä»¥ä¼ å…¥ä¸€ä¸ªåŒ…å« unuse, reuse 函数的组件类型用于节点的回收和å¤ç”¨é€»è¾‘。<br/> - - 一些常è§çš„用例是:<br/> - 1.在游æˆä¸çš„å弹(æ»äº¡å¾ˆå¿«ï¼Œé¢‘ç¹åˆ›å»ºï¼Œå¯¹å…¶ä»–å¯¹è±¡æ— å‰¯ä½œç”¨ï¼‰<br/> - 2.ç³–æžœç²‰ç¢Žä¼ å¥‡ä¸çš„æœ¨å—(频ç¹åˆ›å»ºï¼‰ã€‚ - ç‰ç‰.... */ - export class NodePool { + runAction(action: Action): Action; /** - !#en - Constructor for creating a pool for a specific node template (usually a prefab). You can pass a component (type or name) argument for handling event for reusing and recycling node. - !#zh - ä½¿ç”¨æž„é€ å‡½æ•°æ¥åˆ›å»ºä¸€ä¸ªèŠ‚ç‚¹ä¸“ç”¨çš„å¯¹è±¡æ± ï¼Œæ‚¨å¯ä»¥ä¼ 递一个组件类型或å称,用于处ç†èŠ‚ç‚¹å›žæ”¶å’Œå¤ç”¨æ—¶çš„事件逻辑。 - @param poolHandlerComp !#en The constructor or the class name of the component to control the unuse/reuse logic. !#zh 处ç†èŠ‚ç‚¹å›žæ”¶å’Œå¤ç”¨äº‹ä»¶é€»è¾‘的组件类型或å称。 + !#en Pause all actions running on the current node. Equals to `cc.director.getActionManager().pauseTarget(node)`. + !#zh æš‚åœæœ¬èŠ‚ç‚¹ä¸Šæ‰€æœ‰æ£åœ¨è¿è¡Œçš„动作。和 `cc.director.getActionManager().pauseTarget(node);` ç‰ä»·ã€‚ @example ```js - properties: { - template: cc.Prefab - }, - onLoad () { - // MyTemplateHandler is a component with 'unuse' and 'reuse' to handle events when node is reused or recycled. - this.myPool = new cc.NodePool('MyTemplateHandler'); - } + node.pauseAllActions(); ``` */ - constructor(poolHandlerComp?: {prototype: Component}|string); - /** !#en The pool handler component, it could be the class name or the constructor. - !#zh ç¼“å†²æ± å¤„ç†ç»„件,用于节点的回收和å¤ç”¨é€»è¾‘,这个属性å¯ä»¥æ˜¯ç»„ä»¶ç±»åæˆ–ç»„ä»¶çš„æž„é€ å‡½æ•°ã€‚ */ - poolHandlerComp: Function|string; + pauseAllActions(): void; /** - !#en The current available size in the pool - !#zh 获å–当å‰ç¼“å†²æ± çš„å¯ç”¨å¯¹è±¡æ•°é‡ + !#en Resume all paused actions on the current node. Equals to `cc.director.getActionManager().resumeTarget(node)`. + !#zh æ¢å¤è¿è¡Œæœ¬èŠ‚ç‚¹ä¸Šæ‰€æœ‰æš‚åœçš„动作。和 `cc.director.getActionManager().resumeTarget(node);` ç‰ä»·ã€‚ + + @example + ```js + node.resumeAllActions(); + ``` */ - size(): number; + resumeAllActions(): void; /** - !#en Destroy all cached nodes in the pool - !#zh 销æ¯å¯¹è±¡æ± ä¸ç¼“å˜çš„æ‰€æœ‰èŠ‚ç‚¹ + !#en Stops and removes all actions from the running action list . + !#zh åœæ¢å¹¶ä¸”移除所有æ£åœ¨è¿è¡Œçš„动作列表。 + + @example + ```js + node.stopAllActions(); + ``` */ - clear(): void; + stopAllActions(): void; /** - !#en Put a new Node into the pool. - It will automatically remove the node from its parent without cleanup. - It will also invoke unuse method of the poolHandlerComp if exist. - !#zh å‘ç¼“å†²æ± ä¸å˜å…¥ä¸€ä¸ªä¸å†éœ€è¦çš„节点对象。 - è¿™ä¸ªå‡½æ•°ä¼šè‡ªåŠ¨å°†ç›®æ ‡èŠ‚ç‚¹ä»Žçˆ¶èŠ‚ç‚¹ä¸Šç§»é™¤ï¼Œä½†æ˜¯ä¸ä¼šè¿›è¡Œ cleanup æ“作。 - 这个函数会调用 poolHandlerComp çš„ unuse 函数,如果组件和函数都å˜åœ¨çš„è¯ã€‚ - @param obj obj + !#en Stops and removes an action from the running action list. + !#zh åœæ¢å¹¶ç§»é™¤æŒ‡å®šçš„动作。 + @param action An action object to be removed. @example ```js - let myNode = cc.instantiate(this.template); - this.myPool.put(myNode); + var action = cc.scaleTo(0.2, 1, 0.6); + node.stopAction(action); ``` */ - put(obj: Node): void; + stopAction(action: Action): void; /** - !#en Get a obj from pool, if no available object in pool, null will be returned. - This function will invoke the reuse function of poolHandlerComp if exist. - !#zh 获å–å¯¹è±¡æ± ä¸çš„å¯¹è±¡ï¼Œå¦‚æžœå¯¹è±¡æ± æ²¡æœ‰å¯ç”¨å¯¹è±¡ï¼Œåˆ™è¿”回空。 - 这个函数会调用 poolHandlerComp çš„ reuse 函数,如果组件和函数都å˜åœ¨çš„è¯ã€‚ - @param params !#en Params to pass to 'reuse' method in poolHandlerComp !#zh å‘ poolHandlerComp ä¸çš„ 'reuse' å‡½æ•°ä¼ é€’çš„å‚æ•° + !#en Removes an action from the running action list by its tag. + !#zh åœæ¢å¹¶ä¸”ç§»é™¤æŒ‡å®šæ ‡ç¾çš„动作。 + @param tag A tag that indicates the action to be removed. @example ```js - let newNode = this.myPool.get(); + node.stopActionByTag(1); ``` */ - get(...params: any[]): Node; - } - /** !#en An object to boot the game. - !#zh åŒ…å«æ¸¸æˆä¸»ä½“ä¿¡æ¯å¹¶è´Ÿè´£é©±åŠ¨æ¸¸æˆçš„æ¸¸æˆå¯¹è±¡ã€‚ */ - export class debug { + stopActionByTag(tag: number): void; /** - !#en Gets error message with the error id and possible parameters. - !#zh 通过 error id 和必è¦çš„傿•°æ¥èŽ·å–错误信æ¯ã€‚ - @param errorId errorId - @param param param + !#en Returns an action from the running action list by its tag. + !#zh é€šè¿‡æ ‡ç¾èŽ·å–æŒ‡å®šåŠ¨ä½œã€‚ + @param tag tag + + @example + ```js + var action = node.getActionByTag(1); + ``` */ - static getError(errorId: string, param?: any): string; + getActionByTag(tag: number): Action; /** - !#en Returns whether or not to display the FPS informations. - !#zh æ˜¯å¦æ˜¾ç¤º FPS ä¿¡æ¯ã€‚ + !#en + Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).<br/> + Composable actions are counted as 1 action. Example:<br/> + If you are running 1 Sequence of 7 actions, it will return 1. <br/> + If you are running 7 Sequences of 2 actions, it will return 7.</p> + !#zh + 获å–è¿è¡Œç€çš„åŠ¨ä½œåŠ ä¸Šæ£åœ¨è°ƒåº¦è¿è¡Œçš„动作的总数。<br/> + 例如:<br/> + - å¦‚æžœä½ æ£åœ¨è¿è¡Œ 7 个动作ä¸çš„ 1 个 Sequence,它将返回 1。<br/> + - å¦‚æžœä½ æ£åœ¨è¿è¡Œ 2 个动作ä¸çš„ 7 个 Sequence,它将返回 7。<br/> + + @example + ```js + var count = node.getNumberOfRunningActions(); + cc.log("Running Action Count: " + count); + ``` */ - static isDisplayStats(): boolean; + getNumberOfRunningActions(): number; /** - !#en Sets whether display the FPS on the bottom-left corner. - !#zh 设置是å¦åœ¨å·¦ä¸‹è§’显示 FPS。 - @param displayStats displayStats + !#en + Returns a copy of the position (x, y, z) of the node in its parent's coordinates. + You can pass a cc.Vec2 or cc.Vec3 as the argument to receive the return values. + !#zh + 获å–èŠ‚ç‚¹åœ¨çˆ¶èŠ‚ç‚¹åæ ‡ç³»ä¸çš„ä½ç½®ï¼ˆx, y, z)。 + ä½ å¯ä»¥ä¼ 一个 cc.Vec2 或者 cc.Vec3 ä½œä¸ºå‚æ•°æ¥æŽ¥æ”¶è¿”回值。 + @param out The return value to receive position + + @example + ```js + cc.log("Node Position: " + node.getPosition()); + ``` */ - static setDisplayStats(displayStats: boolean): void; - } - /** !#en - <p> - ATTENTION: USE cc.director INSTEAD OF cc.Director.<br/> - cc.director is a singleton object which manage your game's logic flow.<br/> - Since the cc.director is a singleton, you don't need to call any constructor or create functions,<br/> - the standard way to use it is by calling:<br/> - - cc.director.methodName(); <br/> - - It creates and handle the main Window and manages how and when to execute the Scenes.<br/> - <br/> - The cc.director is also responsible for:<br/> - - initializing the OpenGL context<br/> - - setting the OpenGL pixel format (default on is RGB565)<br/> - - setting the OpenGL buffer depth (default on is 0-bit)<br/> - - setting the color for clear screen (default one is BLACK)<br/> - - setting the projection (default one is 3D)<br/> - - setting the orientation (default one is Portrait)<br/> - <br/> - <br/> - The cc.director also sets the default OpenGL context:<br/> - - GL_TEXTURE_2D is enabled<br/> - - GL_VERTEX_ARRAY is enabled<br/> - - GL_COLOR_ARRAY is enabled<br/> - - GL_TEXTURE_COORD_ARRAY is enabled<br/> - </p> - <p> - cc.director also synchronizes timers with the refresh rate of the display.<br/> - Features and Limitations:<br/> - - Scheduled timers & drawing are synchronizes with the refresh rate of the display<br/> - - Only supports animation intervals of 1/60 1/30 & 1/15<br/> - </p> - - !#zh - <p> - 注æ„:用 cc.director 代替 cc.Director。<br/> - cc.director 一个管ç†ä½ 的游æˆçš„逻辑æµç¨‹çš„å•例对象。<br/> - 由于 cc.director 是一个å•ä¾‹ï¼Œä½ ä¸éœ€è¦è°ƒç”¨ä»»ä½•æž„é€ å‡½æ•°æˆ–åˆ›å»ºå‡½æ•°ï¼Œ<br/> - ä½¿ç”¨å®ƒçš„æ ‡å‡†æ–¹æ³•æ˜¯é€šè¿‡è°ƒç”¨ï¼š<br/> - - cc.director.methodName(); - <br/> - 它创建和处ç†ä¸»çª—å£å¹¶ä¸”管ç†ä»€ä¹ˆæ—¶å€™æ‰§è¡Œåœºæ™¯ã€‚<br/> - <br/> - cc.director 还负责:<br/> - - åˆå§‹åŒ– OpenGL 环境。<br/> - - 设置OpenGLåƒç´ æ ¼å¼ã€‚(默认是 RGB565)<br/> - - 设置OpenGL缓冲区深度 (默认是 0-bit)<br/> - - 设置空白场景的颜色 (默认是 黑色)<br/> - - 设置投影 (默认是 3D)<br/> - - è®¾ç½®æ–¹å‘ (默认是 Portrait)<br/> - <br/> - cc.director 设置了 OpenGL 默认环境 <br/> - - GL_TEXTURE_2D å¯ç”¨ã€‚<br/> - - GL_VERTEX_ARRAY å¯ç”¨ã€‚<br/> - - GL_COLOR_ARRAY å¯ç”¨ã€‚<br/> - - GL_TEXTURE_COORD_ARRAY å¯ç”¨ã€‚<br/> - </p> - <p> - cc.director ä¹ŸåŒæ¥å®šæ—¶å™¨ä¸Žæ˜¾ç¤ºå™¨çš„刷新速率。 - <br/> - ç‰¹ç‚¹å’Œå±€é™æ€§: <br/> - - 将计时器 & æ¸²æŸ“ä¸Žæ˜¾ç¤ºå™¨çš„åˆ·æ–°é¢‘çŽ‡åŒæ¥ã€‚<br/> - - åªæ”¯æŒåŠ¨ç”»çš„é—´éš” 1/60 1/30 & 1/15。<br/> - </p> */ - export class Director extends EventTarget { + getPosition(out?: Vec2|Vec3): Vec2; /** !#en - Converts a view coordinate to an WebGL coordinate<br/> - Useful to convert (multi) touches coordinates to the current layout (portrait or landscape)<br/> - Implementation can be found in CCDirectorWebGL. - !#zh 将触摸点的å±å¹•åæ ‡è½¬æ¢ä¸º WebGL View ä¸‹çš„åæ ‡ã€‚ - @param uiPoint uiPoint + Sets the position (x, y, z) of the node in its parent's coordinates.<br/> + Usually we use cc.v2(x, y) to compose cc.Vec2 object, in this case, position.z will become 0.<br/> + and passing two numbers (x, y) is more efficient than passing cc.Vec2 object, in this case, position.z will remain unchanged. + For 3D node we can use cc.v3(x, y, z) to compose cc.Vec3 object,<br/> + and passing three numbers (x, y, z) is more efficient than passing cc.Vec3 object. + !#zh + è®¾ç½®èŠ‚ç‚¹åœ¨çˆ¶èŠ‚ç‚¹åæ ‡ç³»ä¸çš„ä½ç½®ã€‚<br/> + å¯ä»¥é€šè¿‡ä¸‹é¢çš„æ–¹å¼è®¾ç½®åæ ‡ç‚¹ï¼š<br/> + 1. ä¼ å…¥ 2 个数值 x, y (æ¤æ—¶ä¸ä¼šæ”¹å˜ position.z 的值)。<br/> + 2. ä¼ å…¥ cc.v2(x, y) 类型为 cc.Vec2 的对象 (æ¤æ—¶ position.z 的值将被设置为0)。 + 3. 对于 3D 节点å¯ä»¥ä¼ å…¥ 3 个数值 x, y, z。<br/> + 4. 对于 3D 节点å¯ä»¥ä¼ å…¥ cc.v3(x, y, z) 类型为 cc.Vec3 的对象。 + @param x X coordinate for position or the position object + @param y Y coordinate for position + @param z Z coordinate for position */ - convertToGL(uiPoint: Vec2): Vec2; + setPosition(x: Vec2|Vec3|number, y?: number, z?: number): void; /** !#en - Converts an OpenGL coordinate to a view coordinate<br/> - Useful to convert node points to window points for calls such as glScissor<br/> - Implementation can be found in CCDirectorWebGL. - !#zh 将触摸点的 WebGL View åæ ‡è½¬æ¢ä¸ºå±å¹•åæ ‡ã€‚ - @param glPoint glPoint - */ - convertToUI(glPoint: Vec2): Vec2; - /** - End the life of director in the next frame + Returns the scale factor of the node. + Need pass a cc.Vec2 or cc.Vec3 as the argument to receive the return values. + !#zh 获å–节点的缩放,需è¦ä¼ 一个 cc.Vec2 或者 cc.Vec3 ä½œä¸ºå‚æ•°æ¥æŽ¥æ”¶è¿”回值。 + @param out out + + @example + ```js + cc.log("Node Scale: " + node.getScale(cc.v3())); + ``` */ - end(): void; + getScale(out: Vec2|Vec3): Vec2; /** !#en - Returns the size of the WebGL view in points.<br/> - It takes into account any possible rotation (device orientation) of the window. - !#zh 获å–视图的大å°ï¼Œä»¥ç‚¹ä¸ºå•ä½ã€‚ + Sets the scale of axis in local coordinates of the node. + You can operate 2 axis in 2D node, and 3 axis in 3D node. + When only (x, y) is passed, the value of scale.z will not be changed. + When a Vec2 is passed in, the value of scale.z will be set to 0. + !#zh + è®¾ç½®èŠ‚ç‚¹åœ¨æœ¬åœ°åæ ‡ç³»ä¸åæ ‡è½´ä¸Šçš„ç¼©æ”¾æ¯”ä¾‹ã€‚ + 2D 节点å¯ä»¥æ“ä½œä¸¤ä¸ªåæ ‡è½´ï¼Œè€Œ 3D 节点å¯ä»¥æ“ä½œä¸‰ä¸ªåæ ‡è½´ã€‚ + 当åªä¼ å…¥ (x, y) 时,scale.z 的值ä¸ä¼šè¢«æ”¹å˜ã€‚ + 当åªä¼ å…¥ Vec2 对象时,scale.z 的值将被设置为0。 + @param x scaleX or scale object + @param y y + @param z z + + @example + ```js + node.setScale(cc.v2(2, 2)); // Notice: scaleZ will be 0 + node.setScale(cc.v3(2, 2, 2)); // for 3D node + node.setScale(2); + ``` */ - getWinSize(): Size; + setScale(x: number|Vec2|Vec3, y?: number, z?: number): void; /** !#en - Returns the size of the OpenGL view in pixels.<br/> - It takes into account any possible rotation (device orientation) of the window.<br/> - On Mac winSize and winSizeInPixels return the same value. - (The pixel here refers to the resource resolution. If you want to get the physics resolution of device, you need to use cc.view.getFrameSize()) + Get rotation of node (in quaternion). + Need pass a cc.Quat as the argument to receive the return values. !#zh - 获å–视图大å°ï¼Œä»¥åƒç´ 为å•ä½ï¼ˆè¿™é‡Œçš„åƒç´ 指的是资æºåˆ†è¾¨çŽ‡ã€‚ - 如果è¦èŽ·å–å±å¹•物ç†åˆ†è¾¨çŽ‡ï¼Œéœ€è¦ç”¨ cc.view.getFrameSize()) + 获å–该节点的 quaternion 旋转角度,需è¦ä¼ 一个 cc.Quat ä½œä¸ºå‚æ•°æ¥æŽ¥æ”¶è¿”回值。 + @param out out */ - getWinSizeInPixels(): Size; + getRotation(out: Quat): Quat; /** - !#en Pause the director's ticker, only involve the game logic execution. - It won't pause the rendering process nor the event manager. - If you want to pause the entier game including rendering, audio and event, - please use {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}} - !#zh æš‚åœæ£åœ¨è¿è¡Œçš„场景,该暂åœåªä¼šåœæ¢æ¸¸æˆé€»è¾‘执行,但是ä¸ä¼šåœæ¢æ¸²æŸ“å’Œ UI å“应。 - å¦‚æžœæƒ³è¦æ›´å½»åº•å¾—æš‚åœæ¸¸æˆï¼ŒåŒ…嫿¸²æŸ“,音频和事件,请使用 {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}。 + !#en Set rotation of node (in quaternion). + !#zh 设置该节点的 quaternion 旋转角度。 + @param quat Quaternion object represents the rotation or the x value of quaternion + @param y y value of quternion + @param z z value of quternion + @param w w value of quternion */ - pause(): void; + setRotation(quat: Quat|number, y?: number, z?: number, w?: number): void; /** !#en - Run a scene. Replaces the running scene with a new one or enter the first scene.<br/> - The new scene will be launched immediately. - !#zh ç«‹åˆ»åˆ‡æ¢æŒ‡å®šåœºæ™¯ã€‚ - @param scene The need run scene. - @param onBeforeLoadScene The function invoked at the scene before loading. - @param onLaunched The function invoked at the scene after launch. + Returns a copy the untransformed size of the node. <br/> + The contentSize remains the same no matter the node is scaled or rotated.<br/> + All nodes has a size. Layer and Scene has the same size of the screen by default. <br/> + !#zh 获å–节点自身大å°ï¼Œä¸å—该节点是å¦è¢«ç¼©æ”¾æˆ–者旋转的影å“。 + + @example + ```js + cc.log("Content Size: " + node.getContentSize()); + ``` */ - runSceneImmediate(scene: Scene|SceneAsset, onBeforeLoadScene?: Function, onLaunched?: Function): void; + getContentSize(): Size; /** !#en - Run a scene. Replaces the running scene with a new one or enter the first scene. - The new scene will be launched at the end of the current frame. - !#zh è¿è¡ŒæŒ‡å®šåœºæ™¯ã€‚ - @param scene The need run scene. - @param onBeforeLoadScene The function invoked at the scene before loading. - @param onLaunched The function invoked at the scene after launch. + Sets the untransformed size of the node.<br/> + The contentSize remains the same no matter the node is scaled or rotated.<br/> + All nodes has a size. Layer and Scene has the same size of the screen. + !#zh 设置节点原始大å°ï¼Œä¸å—该节点是å¦è¢«ç¼©æ”¾æˆ–者旋转的影å“。 + @param size The untransformed size of the node or The untransformed size's width of the node. + @param height The untransformed size's height of the node. + + @example + ```js + node.setContentSize(cc.size(100, 100)); + node.setContentSize(100, 100); + ``` */ - runScene(scene: Scene|SceneAsset, onBeforeLoadScene?: Function, onLaunched?: Function): void; + setContentSize(size: Size|number, height?: number): void; /** - !#en Loads the scene by its name. - !#zh 通过场景åç§°è¿›è¡ŒåŠ è½½åœºæ™¯ã€‚ - @param sceneName The name of the scene to load. - @param onLaunched callback, will be called after scene launched. + !#en + Returns a copy of the anchor point.<br/> + Anchor point is the point around which all transformations and positioning manipulations take place.<br/> + It's like a pin in the node where it is "attached" to its parent. <br/> + The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner. <br/> + But you can use values higher than (1,1) and lower than (0,0) too. <br/> + The default anchor point is (0.5,0.5), so it starts at the center of the node. + !#zh + 获å–节点锚点,用百分比表示。<br/> + é”šç‚¹åº”ç”¨äºŽæ‰€æœ‰å˜æ¢å’Œåæ ‡ç‚¹çš„æ“作,它就åƒåœ¨èŠ‚ç‚¹ä¸Šè¿žæŽ¥å…¶çˆ¶èŠ‚ç‚¹çš„å¤§å¤´é’ˆã€‚<br/> + é”šç‚¹æ˜¯æ ‡å‡†åŒ–çš„ï¼Œå°±åƒç™¾åˆ†æ¯”ä¸€æ ·ã€‚(0,0) 表示左下角,(1,1) 表示å³ä¸Šè§’。<br/> + ä½†æ˜¯ä½ å¯ä»¥ä½¿ç”¨æ¯”(1,1)更高的值或者比(0,0)更低的值。<br/> + 默认的锚点是(0.5,0.5ï¼‰ï¼Œå› æ¤å®ƒå¼€å§‹äºŽèŠ‚ç‚¹çš„ä¸å¿ƒä½ç½®ã€‚<br/> + 注æ„:Creator ä¸çš„é”šç‚¹ä»…ç”¨äºŽå®šä½æ‰€åœ¨çš„节点,å节点的定ä½ä¸å—å½±å“。 + + @example + ```js + cc.log("Node AnchorPoint: " + node.getAnchorPoint()); + ``` */ - loadScene(sceneName: string, onLaunched?: Function): boolean; + getAnchorPoint(): Vec2; /** !#en - Preloads the scene to reduces loading time. You can call this method at any time you want. - After calling this method, you still need to launch the scene by `cc.director.loadScene`. - It will be totally fine to call `cc.director.loadScene` at any time even if the preloading is not - yet finished, the scene will be launched after loaded automatically. - !#zh é¢„åŠ è½½åœºæ™¯ï¼Œä½ å¯ä»¥åœ¨ä»»ä½•时候调用这个方法。 - 调用完åŽï¼Œä½ ä»ç„¶éœ€è¦é€šè¿‡ `cc.director.loadScene` æ¥å¯åŠ¨åœºæ™¯ï¼Œå› ä¸ºè¿™ä¸ªæ–¹æ³•ä¸ä¼šæ‰§è¡Œåœºæ™¯åŠ è½½æ“作。 - å°±ç®—é¢„åŠ è½½è¿˜æ²¡å®Œæˆï¼Œä½ 也å¯ä»¥ç›´æŽ¥è°ƒç”¨ `cc.director.loadScene`ï¼ŒåŠ è½½å®ŒæˆåŽåœºæ™¯å°±ä¼šå¯åŠ¨ã€‚ - @param sceneName The name of the scene to preload. - @param onProgress callback, will be called when the load progression change. - @param onLoaded callback, will be called after scene loaded. + Sets the anchor point in percent. <br/> + anchor point is the point around which all transformations and positioning manipulations take place. <br/> + It's like a pin in the node where it is "attached" to its parent. <br/> + The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.<br/> + But you can use values higher than (1,1) and lower than (0,0) too.<br/> + The default anchor point is (0.5,0.5), so it starts at the center of the node. + !#zh + 设置锚点的百分比。<br/> + é”šç‚¹åº”ç”¨äºŽæ‰€æœ‰å˜æ¢å’Œåæ ‡ç‚¹çš„æ“作,它就åƒåœ¨èŠ‚ç‚¹ä¸Šè¿žæŽ¥å…¶çˆ¶èŠ‚ç‚¹çš„å¤§å¤´é’ˆã€‚<br/> + é”šç‚¹æ˜¯æ ‡å‡†åŒ–çš„ï¼Œå°±åƒç™¾åˆ†æ¯”ä¸€æ ·ã€‚(0,0) 表示左下角,(1,1) 表示å³ä¸Šè§’。<br/> + ä½†æ˜¯ä½ å¯ä»¥ä½¿ç”¨æ¯”(1,1)更高的值或者比(0,0)更低的值。<br/> + 默认的锚点是(0.5,0.5ï¼‰ï¼Œå› æ¤å®ƒå¼€å§‹äºŽèŠ‚ç‚¹çš„ä¸å¿ƒä½ç½®ã€‚<br/> + 注æ„:Creator ä¸çš„é”šç‚¹ä»…ç”¨äºŽå®šä½æ‰€åœ¨çš„节点,å节点的定ä½ä¸å—å½±å“。 + @param point The anchor point of node or The x axis anchor of node. + @param y The y axis anchor of node. + + @example + ```js + node.setAnchorPoint(cc.v2(1, 1)); + node.setAnchorPoint(1, 1); + ``` */ - preloadScene(sceneName: string, onProgress?: (completedCount: number, totalCount: number, item: any) => void, onLoaded?: (error: Error) => void): void; + setAnchorPoint(point: Vec2|number, y?: number): void; /** - !#en Resume game logic execution after pause, if the current scene is not paused, nothing will happen. - !#zh æ¢å¤æš‚åœåœºæ™¯çš„æ¸¸æˆé€»è¾‘,如果当å‰åœºæ™¯æ²¡æœ‰æš‚åœå°†æ²¡ä»»ä½•事情å‘生。 + !#en Set rotation by lookAt target point, normally used by Camera Node + !#zh é€šè¿‡è§‚å¯Ÿç›®æ ‡æ¥è®¾ç½® rotation,一般用于 Camera Node 上 + @param pos pos + @param up default is (0,1,0) */ - resume(): void; + lookAt(pos: Vec3, up?: Vec3): void; /** !#en - Enables or disables WebGL depth test.<br/> - Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js - !#zh å¯ç”¨/ç¦ç”¨æ·±åº¦æµ‹è¯•(在 Canvas 渲染模å¼ä¸‹ä¸ä¼šç”Ÿæ•ˆï¼‰ã€‚ - @param on on + Get the local transform matrix (4x4), based on parent node coordinates + !#zh è¿”å›žå±€éƒ¨ç©ºé—´åæ ‡ç³»çš„çŸ©é˜µï¼ŒåŸºäºŽçˆ¶èŠ‚ç‚¹åæ ‡ç³»ã€‚ + @param out The matrix object to be filled with data + + @example + ```js + let mat4 = cc.mat4(); + node.getLocalMatrix(mat4); + ``` */ - setDepthTest(on: boolean): void; + getLocalMatrix(out: Mat4): Mat4; /** !#en - Set color for clear screen.<br/> - (Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js) - !#zh - 设置场景的默认擦除颜色。<br/> - 支æŒå…¨é€æ˜Žï¼Œä½†ä¸æ”¯æŒé€æ˜Žåº¦ä¸ºä¸é—´å€¼ã€‚è¦æ”¯æŒå…¨é€æ˜Žéœ€æ‰‹å·¥å¼€å¯ cc.macro.ENABLE_TRANSPARENT_CANVAS。 - @param clearColor clearColor - */ - setClearColor(clearColor: Color): void; - /** - !#en Returns current logic Scene. - !#zh 获å–当å‰é€»è¾‘场景。 + Get the world transform matrix (4x4) + !#zh è¿”å›žä¸–ç•Œç©ºé—´åæ ‡ç³»çš„矩阵。 + @param out The matrix object to be filled with data @example ```js - // This will help you to get the Canvas node in scene - cc.director.getScene().getChildByName('Canvas'); + let mat4 = cc.mat4(); + node.getWorldMatrix(mat4); ``` */ - getScene(): Scene; + getWorldMatrix(out: Mat4): Mat4; /** - !#en Returns the FPS value. Please use {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} to control animation interval. - !#zh 获å–å•ä½å¸§æ‰§è¡Œæ—¶é—´ã€‚请使用 {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} æ¥æŽ§åˆ¶æ¸¸æˆå¸§çŽ‡ã€‚ + !#en + Converts a Point to node (local) space coordinates. + !#zh + 将一个点转æ¢åˆ°èŠ‚ç‚¹ (局部) ç©ºé—´åæ ‡ç³»ã€‚ + @param worldPoint worldPoint + @param out out + + @example + ```js + var newVec2 = node.convertToNodeSpaceAR(cc.v2(100, 100)); + var newVec3 = node.convertToNodeSpaceAR(cc.v3(100, 100, 100)); + ``` */ - getAnimationInterval(): number; + convertToNodeSpaceAR<T extends cc.Vec2 | cc.Vec3>(worldPoint: T, out?: T): T; /** - Sets animation interval, this doesn't control the main loop. - To control the game's frame rate overall, please use {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} - @param value The animation interval desired. + !#en + Converts a Point in node coordinates to world space coordinates. + !#zh + å°†èŠ‚ç‚¹åæ ‡ç³»ä¸‹çš„一个点转æ¢åˆ°ä¸–ç•Œç©ºé—´åæ ‡ç³»ã€‚ + @param nodePoint nodePoint + @param out out + + @example + ```js + var newVec2 = node.convertToWorldSpaceAR(cc.v2(100, 100)); + var newVec3 = node.convertToWorldSpaceAR(cc.v3(100, 100, 100)); + ``` */ - setAnimationInterval(value: number): void; + convertToWorldSpaceAR<T extends cc.Vec2 | cc.Vec3>(nodePoint: T, out?: T): T; /** - !#en Returns the delta time since last frame. - !#zh 获å–ä¸Šä¸€å¸§çš„å¢žé‡æ—¶é—´ã€‚ + !#en Converts a Point to node (local) space coordinates then add the anchor point position. + So the return position will be related to the left bottom corner of the node's bounding box. + This equals to the API behavior of cocos2d-x, you probably want to use convertToNodeSpaceAR instead + !#zh 将一个点转æ¢åˆ°èŠ‚ç‚¹ (局部) åæ ‡ç³»ï¼Œå¹¶åŠ ä¸Šé”šç‚¹çš„åæ ‡ã€‚<br/> + ä¹Ÿå°±æ˜¯è¯´è¿”å›žçš„åæ ‡æ˜¯ç›¸å¯¹äºŽèŠ‚ç‚¹åŒ…å›´ç›’å·¦ä¸‹è§’çš„åæ ‡ã€‚<br/> + 这个 API 的设计是为了和 cocos2d-x ä¸è¡Œä¸ºä¸€è‡´ï¼Œæ›´å¤šæƒ…å†µä¸‹ä½ å¯èƒ½éœ€è¦ä½¿ç”¨ convertToNodeSpaceAR。 + @param worldPoint worldPoint + + @example + ```js + var newVec2 = node.convertToNodeSpace(cc.v2(100, 100)); + ``` */ - getDeltaTime(): number; + convertToNodeSpace(worldPoint: Vec2): Vec2; /** - !#en Returns the total passed time since game start, unit: ms - !#zh 获å–从游æˆå¼€å§‹åˆ°çŽ°åœ¨æ€»å…±ç»è¿‡çš„æ—¶é—´ï¼Œå•ä½ä¸º ms + !#en Converts a Point related to the left bottom corner of the node's bounding box to world space coordinates. + This equals to the API behavior of cocos2d-x, you probably want to use convertToWorldSpaceAR instead + !#zh å°†ä¸€ä¸ªç›¸å¯¹äºŽèŠ‚ç‚¹å·¦ä¸‹è§’çš„åæ ‡ä½ç½®è½¬æ¢åˆ°ä¸–ç•Œç©ºé—´åæ ‡ç³»ã€‚ + 这个 API 的设计是为了和 cocos2d-x ä¸è¡Œä¸ºä¸€è‡´ï¼Œæ›´å¤šæƒ…å†µä¸‹ä½ å¯èƒ½éœ€è¦ä½¿ç”¨ convertToWorldSpaceAR + @param nodePoint nodePoint + + @example + ```js + var newVec2 = node.convertToWorldSpace(cc.v2(100, 100)); + ``` */ - getTotalTime(): number; + convertToWorldSpace(nodePoint: Vec2): Vec2; /** - !#en Returns how many frames were called since the director started. - !#zh èŽ·å– director å¯åŠ¨ä»¥æ¥æ¸¸æˆè¿è¡Œçš„æ€»å¸§æ•°ã€‚ + !#en + Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.<br/> + The matrix is in Pixels. + !#zh è¿”å›žè¿™ä¸ªå°†èŠ‚ç‚¹ï¼ˆå±€éƒ¨ï¼‰çš„ç©ºé—´åæ ‡ç³»è½¬æ¢æˆçˆ¶èŠ‚ç‚¹çš„ç©ºé—´åæ ‡ç³»çš„矩阵。这个矩阵以åƒç´ 为å•ä½ã€‚ + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToParentTransform(affineTransform); + ``` */ - getTotalFrames(): number; + getNodeToParentTransform(out?: AffineTransform): AffineTransform; /** - !#en Returns whether or not the Director is paused. - !#zh 是å¦å¤„于暂åœçжæ€ã€‚ + !#en + Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.<br/> + The matrix is in Pixels.<br/> + This method is AR (Anchor Relative). + !#zh + è¿”å›žè¿™ä¸ªå°†èŠ‚ç‚¹ï¼ˆå±€éƒ¨ï¼‰çš„ç©ºé—´åæ ‡ç³»è½¬æ¢æˆçˆ¶èŠ‚ç‚¹çš„ç©ºé—´åæ ‡ç³»çš„矩阵。<br/> + 这个矩阵以åƒç´ 为å•ä½ã€‚<br/> + è¯¥æ–¹æ³•åŸºäºŽèŠ‚ç‚¹åæ ‡ã€‚ + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToParentTransformAR(affineTransform); + ``` */ - isPaused(): boolean; + getNodeToParentTransformAR(out?: AffineTransform): AffineTransform; /** - !#en Returns the cc.Scheduler associated with this director. - !#zh 获å–å’Œ director 相关è”çš„ cc.Scheduler。 + !#en Returns the world affine transform matrix. The matrix is in Pixels. + !#zh è¿”å›žèŠ‚ç‚¹åˆ°ä¸–ç•Œåæ ‡ç³»çš„ä»¿å°„å˜æ¢çŸ©é˜µã€‚矩阵å•使˜¯åƒç´ 。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToWorldTransform(affineTransform); + ``` */ - getScheduler(): Scheduler; + getNodeToWorldTransform(out?: AffineTransform): AffineTransform; /** - !#en Sets the cc.Scheduler associated with this director. - !#zh 设置和 director 相关è”çš„ cc.Scheduler。 - @param scheduler scheduler + !#en + Returns the world affine transform matrix. The matrix is in Pixels.<br/> + This method is AR (Anchor Relative). + !#zh + è¿”å›žèŠ‚ç‚¹åˆ°ä¸–ç•Œåæ ‡ä»¿å°„å˜æ¢çŸ©é˜µã€‚矩阵å•使˜¯åƒç´ 。<br/> + è¯¥æ–¹æ³•åŸºäºŽèŠ‚ç‚¹åæ ‡ã€‚ + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getNodeToWorldTransformAR(affineTransform); + ``` */ - setScheduler(scheduler: Scheduler): void; + getNodeToWorldTransformAR(out?: AffineTransform): AffineTransform; /** - !#en Returns the cc.ActionManager associated with this director. - !#zh 获å–å’Œ director 相关è”çš„ cc.ActionManager(动作管ç†å™¨ï¼‰ã€‚ + !#en + Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.<br/> + The matrix is in Pixels. The returned transform is readonly and cannot be changed. + !#zh + è¿”å›žå°†çˆ¶èŠ‚ç‚¹çš„åæ ‡ç³»è½¬æ¢æˆèŠ‚ç‚¹ï¼ˆå±€éƒ¨ï¼‰çš„ç©ºé—´åæ ‡ç³»çš„矩阵。<br/> + 该矩阵以åƒç´ 为å•ä½ã€‚返回的矩阵是åªè¯»çš„,ä¸èƒ½æ›´æ”¹ã€‚ + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getParentToNodeTransform(affineTransform); + ``` */ - getActionManager(): ActionManager; + getParentToNodeTransform(out?: AffineTransform): AffineTransform; /** - !#en Sets the cc.ActionManager associated with this director. - !#zh 设置和 director 相关è”çš„ cc.ActionManager(动作管ç†å™¨ï¼‰ã€‚ - @param actionManager actionManager + !#en Returns the inverse world affine transform matrix. The matrix is in Pixels. + !#en è¿”å›žä¸–ç•Œåæ ‡ç³»åˆ°èŠ‚ç‚¹åæ ‡ç³»çš„逆矩阵。 + @param out The affine transform object to be filled with data + + @example + ```js + let affineTransform = cc.AffineTransform.create(); + node.getWorldToNodeTransform(affineTransform); + ``` */ - setActionManager(actionManager: ActionManager): void; + getWorldToNodeTransform(out?: AffineTransform): AffineTransform; /** - !#en Returns the cc.CollisionManager associated with this director. - !#zh 获å–å’Œ director 相关è”çš„ cc.CollisionManager (碰撞管ç†å™¨ï¼‰ã€‚ + !#en convenience methods which take a cc.Touch instead of cc.Vec2. + !#zh å°†è§¦æ‘¸ç‚¹è½¬æ¢æˆæœ¬åœ°åæ ‡ç³»ä¸ä½ç½®ã€‚ + @param touch The touch object + + @example + ```js + var newVec2 = node.convertTouchToNodeSpace(touch); + ``` */ - getCollisionManager(): CollisionManager; + convertTouchToNodeSpace(touch: Touch): Vec2; /** - !#en Returns the cc.PhysicsManager associated with this director. - !#zh 返回与 director 相关è”çš„ cc.PhysicsManager (物ç†ç®¡ç†å™¨ï¼‰ã€‚ + !#en converts a cc.Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative). + !#zh 转æ¢ä¸€ä¸ª cc.Touchï¼ˆä¸–ç•Œåæ ‡ï¼‰åˆ°ä¸€ä¸ªå±€éƒ¨åæ ‡ï¼Œè¯¥æ–¹æ³•åŸºäºŽèŠ‚ç‚¹åæ ‡ã€‚ + @param touch The touch object + + @example + ```js + var newVec2 = node.convertTouchToNodeSpaceAR(touch); + ``` */ - getPhysicsManager(): PhysicsManager; + convertTouchToNodeSpaceAR(touch: Touch): Vec2; /** - !#en Returns the cc.Physics3DManager associated with this director. - !#zh 返回与 director 相关è”çš„ cc.Physics3DManager (物ç†ç®¡ç†å™¨ï¼‰ã€‚ - */ - getPhysics3DManager(): Physics3DManager; - /** !#en The event projection changed of cc.Director. This event will not get triggered since v2.0 - !#zh cc.Director 投影å˜åŒ–的事件。从 v2.0 开始这个事件ä¸ä¼šå†è¢«è§¦å‘ */ - static EVENT_PROJECTION_CHANGED: string; - /** !#en The event which will be triggered before loading a new scene. - !#zh åŠ è½½æ–°åœºæ™¯ä¹‹å‰æ‰€è§¦å‘的事件。 */ - static EVENT_BEFORE_SCENE_LOADING: string; - /** !#en The event which will be triggered before launching a new scene. - !#zh è¿è¡Œæ–°åœºæ™¯ä¹‹å‰æ‰€è§¦å‘的事件。 */ - static EVENT_BEFORE_SCENE_LAUNCH: string; - /** !#en The event which will be triggered after launching a new scene. - !#zh è¿è¡Œæ–°åœºæ™¯ä¹‹åŽæ‰€è§¦å‘的事件。 */ - static EVENT_AFTER_SCENE_LAUNCH: string; - /** !#en The event which will be triggered at the beginning of every frame. - !#zh æ¯ä¸ªå¸§çš„开始时所触å‘的事件。 */ - static EVENT_BEFORE_UPDATE: string; - /** !#en The event which will be triggered after engine and components update logic. - !#zh 将在引擎和组件 “updateâ€ é€»è¾‘ä¹‹åŽæ‰€è§¦å‘的事件。 */ - static EVENT_AFTER_UPDATE: string; - /** !#en The event is deprecated since v2.0, please use cc.Director.EVENT_BEFORE_DRAW instead - !#zh 这个事件从 v2.0 开始被废弃,请直接使用 cc.Director.EVENT_BEFORE_DRAW */ - static EVENT_BEFORE_VISIT: string; - /** !#en The event is deprecated since v2.0, please use cc.Director.EVENT_BEFORE_DRAW instead - !#zh 这个事件从 v2.0 开始被废弃,请直接使用 cc.Director.EVENT_BEFORE_DRAW */ - static EVENT_AFTER_VISIT: string; - /** !#en The event which will be triggered before the rendering process. - !#zh æ¸²æŸ“è¿‡ç¨‹ä¹‹å‰æ‰€è§¦å‘的事件。 */ - static EVENT_BEFORE_DRAW: string; - /** !#en The event which will be triggered after the rendering process. - !#zh æ¸²æŸ“è¿‡ç¨‹ä¹‹åŽæ‰€è§¦å‘的事件。 */ - static EVENT_AFTER_DRAW: string; - /** Constant for 2D projection (orthogonal projection) */ - static PROJECTION_2D: number; - /** Constant for 3D projection with a fovy=60, znear=0.5f and zfar=1500. */ - static PROJECTION_3D: number; - /** Constant for custom projection, if cc.Director's projection set to it, it calls "updateProjection" on the projection delegate. */ - static PROJECTION_CUSTOM: number; - /** Constant for default projection of cc.Director, default projection is 2D projection */ - static PROJECTION_DEFAULT: number; - } - /** !#en An object to boot the game. - !#zh åŒ…å«æ¸¸æˆä¸»ä½“ä¿¡æ¯å¹¶è´Ÿè´£é©±åŠ¨æ¸¸æˆçš„æ¸¸æˆå¯¹è±¡ã€‚ */ - export class Game extends EventTarget { - /** !#en Event triggered when game hide to background. - Please note that this event is not 100% guaranteed to be fired on Web platform, - on native platforms, it corresponds to enter background event, os status bar or notification center may not trigger this event. - !#zh 游æˆè¿›å…¥åŽå°æ—¶è§¦å‘的事件。 - 请注æ„,在 WEB å¹³å°ï¼Œè¿™ä¸ªäº‹ä»¶ä¸ä¸€å®šä¼š 100% 触å‘,这完全å–决于æµè§ˆå™¨çš„回调行为。 - 在原生平å°ï¼Œå®ƒå¯¹åº”的是应用被切æ¢åˆ°åŽå°äº‹ä»¶ï¼Œä¸‹æ‹‰èœå•å’Œä¸Šæ‹‰çŠ¶æ€æ ç‰ä¸ä¸€å®šä¼šè§¦å‘这个事件,这å–决于系统行为。 */ - EVENT_HIDE: string; - /** !#en Event triggered when game back to foreground - Please note that this event is not 100% guaranteed to be fired on Web platform, - on native platforms, it corresponds to enter foreground event. - !#zh 游æˆè¿›å…¥å‰å°è¿è¡Œæ—¶è§¦å‘的事件。 - 请注æ„,在 WEB å¹³å°ï¼Œè¿™ä¸ªäº‹ä»¶ä¸ä¸€å®šä¼š 100% 触å‘,这完全å–决于æµè§ˆå™¨çš„回调行为。 - 在原生平å°ï¼Œå®ƒå¯¹åº”的是应用被切æ¢åˆ°å‰å°äº‹ä»¶ã€‚ */ - EVENT_SHOW: string; - /** !#en Event triggered when game restart - !#zh 调用restartåŽï¼Œè§¦å‘事件。 */ - EVENT_RESTART: string; - /** Event triggered after game inited, at this point all engine objects and game scripts are loaded */ - EVENT_GAME_INITED: string; - /** Event triggered after engine inited, at this point you will be able to use all engine classes. - It was defined as EVENT_RENDERER_INITED in cocos creator v1.x and renamed in v2.0 */ - EVENT_ENGINE_INITED: string; - /** Web Canvas 2d API as renderer backend */ - RENDER_TYPE_CANVAS: number; - /** WebGL API as renderer backend */ - RENDER_TYPE_WEBGL: number; - /** OpenGL API as renderer backend */ - RENDER_TYPE_OPENGL: number; - /** !#en The outer frame of the game canvas, parent of game container. - !#zh 游æˆç”»å¸ƒçš„外框,container 的父容器。 */ - frame: any; - /** !#en The container of game canvas. - !#zh 游æˆç”»å¸ƒçš„容器。 */ - container: HTMLDivElement; - /** !#en The canvas of the game. - !#zh 游æˆçš„画布。 */ - canvas: HTMLCanvasElement; - /** !#en The renderer backend of the game. - !#zh 游æˆçš„æ¸²æŸ“器类型。 */ - renderType: number; - /** !#en - The current game configuration, including:<br/> - 1. debugMode<br/> - "debugMode" possible values :<br/> - 0 - No message will be printed. <br/> - 1 - cc.error, cc.assert, cc.warn, cc.log will print in console. <br/> - 2 - cc.error, cc.assert, cc.warn will print in console. <br/> - 3 - cc.error, cc.assert will print in console. <br/> - 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web.<br/> - 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web. <br/> - 6 - cc.error, cc.assert will print on canvas, available only on web. <br/> - 2. showFPS<br/> - Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide.<br/> - 3. exposeClassName<br/> - Expose class name to chrome debug tools, the class intantiate performance is a little bit slower when exposed.<br/> - 4. frameRate<br/> - "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment.<br/> - 5. id<br/> - "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web.<br/> - 6. renderMode<br/> - "renderMode" sets the renderer type, only useful on web :<br/> - 0 - Automatically chosen by engine<br/> - 1 - Forced to use canvas renderer<br/> - 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers<br/> - <br/> - Please DO NOT modify this object directly, it won't have any effect.<br/> + !#en + Returns a "local" axis aligned bounding box of the node. <br/> + The returned box is relative only to its parent. + !#zh è¿”å›žçˆ¶èŠ‚åæ ‡ç³»ä¸‹çš„è½´å‘对é½çš„包围盒。 + + @example + ```js + var boundingBox = node.getBoundingBox(); + ``` + */ + getBoundingBox(): Rect; + /** + !#en + Returns a "world" axis aligned bounding box of the node.<br/> + The bounding box contains self and active children's world bounding box. !#zh - 当å‰çš„æ¸¸æˆé…置,包括: <br/> - 1. debugMode(debug 模å¼ï¼Œä½†æ˜¯åœ¨æµè§ˆå™¨ä¸è¿™ä¸ªé€‰é¡¹ä¼šè¢«å¿½ç•¥ï¼‰ <br/> - "debugMode" å„ç§è®¾ç½®é€‰é¡¹çš„æ„ä¹‰ã€‚ <br/> - 0 - 没有消æ¯è¢«æ‰“å°å‡ºæ¥ã€‚ <br/> - 1 - cc.error,cc.assert,cc.warn,cc.log 将打å°åœ¨ console ä¸ã€‚ <br/> - 2 - cc.error,cc.assert,cc.warn 将打å°åœ¨ console ä¸ã€‚ <br/> - 3 - cc.error,cc.assert 将打å°åœ¨ console ä¸ã€‚ <br/> - 4 - cc.error,cc.assert,cc.warn,cc.log 将打å°åœ¨ canvas ä¸ï¼ˆä»…适用于 web 端)。 <br/> - 5 - cc.error,cc.assert,cc.warn 将打å°åœ¨ canvas ä¸ï¼ˆä»…适用于 web 端)。 <br/> - 6 - cc.error,cc.assert 将打å°åœ¨ canvas ä¸ï¼ˆä»…适用于 web 端)。 <br/> - 2. showFPS(显示 FPS) <br/> - 当 showFPS 为 true 的时候界é¢çš„左下角将显示 fps 的信æ¯ï¼Œå¦åˆ™è¢«éšè—。 <br/> - 3. exposeClassName <br/> - 暴露类å让 Chrome DevTools å¯ä»¥è¯†åˆ«ï¼Œå¦‚果开å¯ä¼šç¨ç¨é™ä½Žç±»çš„åˆ›å»ºè¿‡ç¨‹çš„æ€§èƒ½ï¼Œä½†å¯¹å¯¹è±¡æž„é€ æ²¡æœ‰å½±å“。 <br/> - 4. frameRate (帧率) <br/> - “frameRate†设置想è¦çš„å¸§çŽ‡ä½ çš„æ¸¸æˆï¼Œä½†çœŸæ£çš„FPSå–å†³äºŽä½ çš„æ¸¸æˆå®žçŽ°å’Œè¿è¡ŒçŽ¯å¢ƒã€‚ <br/> - 5. id <br/> - "gameCanvas" Web 页é¢ä¸Šçš„ Canvas Element ID,仅适用于 web 端。 <br/> - 6. renderMode(渲染模å¼ï¼‰ <br/> - “renderMode†设置渲染器类型,仅适用于 web 端: <br/> - 0 - 通过引擎自动选择。 <br/> - 1 - 强制使用 canvas 渲染。 - 2 - 强制使用 WebGL 渲染,但是在部分 Android æµè§ˆå™¨ä¸è¿™ä¸ªé€‰é¡¹ä¼šè¢«å¿½ç•¥ã€‚ <br/> - <br/> - 注æ„:请ä¸è¦ç›´æŽ¥ä¿®æ”¹è¿™ä¸ªå¯¹è±¡ï¼Œå®ƒä¸ä¼šæœ‰ä»»ä½•效果。 */ - config: any; + è¿”å›žèŠ‚ç‚¹åœ¨ä¸–ç•Œåæ ‡ç³»ä¸‹çš„对é½è½´å‘的包围盒(AABB)。<br/> + 该边框包å«è‡ªèº«å’Œå·²æ¿€æ´»çš„å节点的世界边框。 + + @example + ```js + var newRect = node.getBoundingBoxToWorld(); + ``` + */ + getBoundingBoxToWorld(): Rect; /** - !#en Callback when the scripts of engine have been load. - !#zh 当引擎完æˆå¯åЍåŽçš„回调函数。 + !#en + Adds a child to the node with z order and name. + !#zh + æ·»åŠ å节点,并且å¯ä»¥ä¿®æ”¹è¯¥èŠ‚ç‚¹çš„ 局部 Z 顺åºå’Œåå—。 + @param child A child node + @param zIndex Z order for drawing priority. Please refer to zIndex property + @param name A name to identify the node easily. Please refer to name property + + @example + ```js + node.addChild(newNode, 1, "node"); + ``` */ - onStart(): void; + addChild(child: Node, zIndex?: number, name?: string): void; /** - !#en Set frame rate of game. - !#zh 设置游æˆå¸§çŽ‡ã€‚ - @param frameRate frameRate + !#en Stops all running actions and schedulers. + !#zh åœæ¢æ‰€æœ‰æ£åœ¨æ’放的动作和计时器。 + + @example + ```js + node.cleanup(); + ``` */ - setFrameRate(frameRate: number): void; + cleanup(): void; /** - !#en Get frame rate set for the game, it doesn't represent the real frame rate. - !#zh 获å–设置的游æˆå¸§çŽ‡ï¼ˆä¸ç‰åŒäºŽå®žé™…帧率)。 + !#en Sorts the children array depends on children's zIndex and arrivalOrder, + normally you won't need to invoke this function. + !#zh æ ¹æ®å节点的 zIndex å’Œ arrivalOrder 进行排åºï¼Œæ£å¸¸æƒ…况下开å‘者ä¸éœ€è¦æ‰‹åŠ¨è°ƒç”¨è¿™ä¸ªå‡½æ•°ã€‚ */ - getFrameRate(): number; + sortAllChildren(): void; /** - !#en Run the game frame by frame. - !#zh 执行一帧游æˆå¾ªçŽ¯ã€‚ + !#en + Returns the displayed opacity of Node, + the difference between displayed opacity and opacity is that displayed opacity is calculated based on opacity and parent node's opacity when cascade opacity enabled. + !#zh + 获å–èŠ‚ç‚¹æ˜¾ç¤ºé€æ˜Žåº¦ï¼Œ + æ˜¾ç¤ºé€æ˜Žåº¦å’Œé€æ˜Žåº¦ä¹‹é—´çš„ä¸åŒä¹‹å¤„在于当å¯ç”¨çº§è¿žé€æ˜Žåº¦æ—¶ï¼Œ + æ˜¾ç¤ºé€æ˜Žåº¦æ˜¯åŸºäºŽè‡ªèº«é€æ˜Žåº¦å’Œçˆ¶èŠ‚ç‚¹é€æ˜Žåº¦è®¡ç®—的。 */ - step(): void; + getDisplayedOpacity(): number; /** - !#en Pause the game main loop. This will pause: - game logic execution, rendering process, event manager, background music and all audio effects. - This is different with cc.director.pause which only pause the game logic execution. - !#zh æš‚åœæ¸¸æˆä¸»å¾ªçŽ¯ã€‚åŒ…å«ï¼šæ¸¸æˆé€»è¾‘,渲染,事件处ç†ï¼ŒèƒŒæ™¯éŸ³ä¹å’Œæ‰€æœ‰éŸ³æ•ˆã€‚è¿™ç‚¹å’Œåªæš‚åœæ¸¸æˆé€»è¾‘çš„ cc.director.pause ä¸åŒã€‚ + !#en + Returns the displayed color of Node, + the difference between displayed color and color is that displayed color is calculated based on color and parent node's color when cascade color enabled. + !#zh + 获å–节点的显示颜色, + 显示颜色和颜色之间的ä¸åŒä¹‹å¤„在于当å¯ç”¨çº§è¿žé¢œè‰²æ—¶ï¼Œ + 显示颜色是基于自身颜色和父节点颜色计算的。 */ - pause(): void; + getDisplayedColor(): Color; + /** !#en Cascade opacity is removed from v2.0 + Indicate whether node's opacity value affect its child nodes, default value is true. + !#zh 逿˜Žåº¦çº§è”功能从 v2.0 开始已移除 + 节点的ä¸é€æ˜Žåº¦å€¼æ˜¯å¦å½±å“å…¶å节点,默认值为 true。 */ + cascadeOpacity: boolean; /** - !#en Resume the game from pause. This will resume: - game logic execution, rendering process, event manager, background music and all audio effects. - !#zh æ¢å¤æ¸¸æˆä¸»å¾ªçŽ¯ã€‚åŒ…å«ï¼šæ¸¸æˆé€»è¾‘,渲染,事件处ç†ï¼ŒèƒŒæ™¯éŸ³ä¹å’Œæ‰€æœ‰éŸ³æ•ˆã€‚ + !#en Cascade opacity is removed from v2.0 + Returns whether node's opacity value affect its child nodes. + !#zh 逿˜Žåº¦çº§è”功能从 v2.0 开始已移除 + 返回节点的ä¸é€æ˜Žåº¦å€¼æ˜¯å¦å½±å“å…¶å节点。 */ - resume(): void; + isCascadeOpacityEnabled(): boolean; /** - !#en Check whether the game is paused. - !#zh åˆ¤æ–æ¸¸æˆæ˜¯å¦æš‚åœã€‚ + !#en Cascade opacity is removed from v2.0 + Enable or disable cascade opacity, if cascade enabled, child nodes' opacity will be the multiplication of parent opacity and its own opacity. + !#zh 逿˜Žåº¦çº§è”功能从 v2.0 开始已移除 + å¯ç”¨æˆ–ç¦ç”¨çº§è¿žä¸é€æ˜Žåº¦ï¼Œå¦‚果级连å¯ç”¨ï¼Œå节点的ä¸é€æ˜Žåº¦å°†æ˜¯çˆ¶ä¸é€æ˜Žåº¦ä¹˜ä¸Šå®ƒè‡ªå·±çš„ä¸é€æ˜Žåº¦ã€‚ + @param cascadeOpacityEnabled cascadeOpacityEnabled */ - isPaused(): boolean; + setCascadeOpacityEnabled(cascadeOpacityEnabled: boolean): void; /** - !#en Restart game. - !#zh 釿–°å¼€å§‹æ¸¸æˆ + !#en Opacity modify RGB have been removed since v2.0 + Set whether color should be changed with the opacity value, + useless in ccsg.Node, but this function is override in some class to have such behavior. + !#zh 逿˜Žåº¦å½±å“颜色é…置已ç»è¢«åºŸå¼ƒ + è®¾ç½®æ›´æ”¹é€æ˜Žåº¦æ—¶æ˜¯å¦ä¿®æ”¹RGB值, + @param opacityValue opacityValue */ - restart(): void; + setOpacityModifyRGB(opacityValue: boolean): void; /** - !#en End game, it will close the game window - !#zh é€€å‡ºæ¸¸æˆ + !#en Opacity modify RGB have been removed since v2.0 + Get whether color should be changed with the opacity value. + !#zh 逿˜Žåº¦å½±å“颜色é…置已ç»è¢«åºŸå¼ƒ + èŽ·å–æ›´æ”¹é€æ˜Žåº¦æ—¶æ˜¯å¦ä¿®æ”¹RGB值。 + */ + isOpacityModifyRGB(): boolean; + } + /** !#en + Class of private entities in Cocos Creator scenes.<br/> + The PrivateNode is hidden in editor, and completely transparent to users.<br/> + It's normally used as Node's private content created by components in parent node.<br/> + So in theory private nodes are not children, they are part of the parent node.<br/> + Private node have two important characteristics:<br/> + 1. It has the minimum z index and cannot be modified, because they can't be displayed over real children.<br/> + 2. The positioning of private nodes is also special, they will consider the left bottom corner of the parent node's bounding box as the origin of local coordinates.<br/> + In this way, they can be easily kept inside the bounding box.<br/> + Currently, it's used by RichText component and TileMap component. + !#zh + Cocos Creator 场景ä¸çš„ç§æœ‰èŠ‚ç‚¹ç±»ã€‚<br/> + ç§æœ‰èŠ‚ç‚¹åœ¨ç¼–è¾‘å™¨ä¸ä¸å¯è§ï¼Œå¯¹ç”¨æˆ·é€æ˜Žã€‚<br/> + é€šå¸¸ç§æœ‰èŠ‚ç‚¹æ˜¯è¢«ä¸€äº›ç‰¹æ®Šçš„ç»„ä»¶åˆ›å»ºå‡ºæ¥ä½œä¸ºçˆ¶èŠ‚ç‚¹çš„ä¸€éƒ¨åˆ†è€Œå˜åœ¨çš„,ç†è®ºä¸Šæ¥è¯´ï¼Œå®ƒä»¬ä¸æ˜¯å节点,而是父节点的组æˆéƒ¨åˆ†ã€‚<br/> + ç§æœ‰èŠ‚ç‚¹æœ‰ä¸¤ä¸ªéžå¸¸é‡è¦çš„特性:<br/> + 1. å®ƒæœ‰ç€æœ€å°çš„æ¸²æŸ“排åºçš„ Z è½´æ·±åº¦ï¼Œå¹¶ä¸”æ— æ³•è¢«æ›´æ”¹ï¼Œå› ä¸ºå®ƒä»¬ä¸èƒ½è¢«æ˜¾ç¤ºåœ¨å…¶ä»–æ£å¸¸å节点之上。<br/> + 2. 它的定ä½ä¹Ÿæ˜¯ç‰¹æ®Šçš„ï¼Œå¯¹äºŽç§æœ‰èŠ‚ç‚¹æ¥è¯´ï¼Œçˆ¶èŠ‚ç‚¹åŒ…å›´ç›’çš„å·¦ä¸‹è§’æ˜¯å®ƒçš„å±€éƒ¨åæ ‡ç³»åŽŸç‚¹ï¼Œè¿™ä¸ªåŽŸç‚¹ç›¸å½“äºŽçˆ¶èŠ‚ç‚¹çš„ä½ç½®å‡åŽ»å®ƒé”šç‚¹çš„åç§»ã€‚è¿™æ ·ç§æœ‰èŠ‚ç‚¹å¯ä»¥æ¯”较容易被控制在包围盒之ä¸ã€‚<br/> + ç›®å‰åœ¨å¼•擎ä¸ï¼ŒRichText å’Œ TileMap 都有å¯èƒ½ç”Ÿæˆç§æœ‰èŠ‚ç‚¹ã€‚ */ + export class PrivateNode extends Node { + /** + + @param name name + */ + constructor(name?: string); + } + /** !#en + cc.Scene is a subclass of cc.Node that is used only as an abstract concept.<br/> + cc.Scene and cc.Node are almost identical with the difference that users can not modify cc.Scene manually. + !#zh + cc.Scene 是 cc.Node çš„å类,仅作为一个抽象的概念。<br/> + cc.Scene å’Œ cc.Node 有点ä¸åŒï¼Œç”¨æˆ·ä¸åº”直接修改 cc.Scene。 */ + export class Scene extends Node { + /** !#en Indicates whether all (directly or indirectly) static referenced assets of this scene are releasable by default after scene unloading. + !#zh 指示该场景ä¸ç›´æŽ¥æˆ–é—´æŽ¥é™æ€å¼•ç”¨åˆ°çš„æ‰€æœ‰èµ„æºæ˜¯å¦é»˜è®¤åœ¨åœºæ™¯åˆ‡æ¢åŽè‡ªåŠ¨é‡Šæ”¾ã€‚ */ + autoReleaseAssets: boolean; + } + /** !#en + Scheduler is responsible of triggering the scheduled callbacks.<br/> + You should not use NSTimer. Instead use this class.<br/> + <br/> + There are 2 different types of callbacks (selectors):<br/> + - update callback: the 'update' callback will be called every frame. You can customize the priority.<br/> + - custom callback: A custom callback will be called every frame, or with a custom interval of time<br/> + <br/> + The 'custom selectors' should be avoided when possible. It is faster, + and consumes less memory to use the 'update callback'. * + !#zh + Scheduler 是负责触å‘回调函数的类。<br/> + 通常情况下,建议使用 cc.director.getScheduler() æ¥èŽ·å–系统定时器。<br/> + 有两ç§ä¸åŒç±»åž‹çš„定时器:<br/> + - update 定时器:æ¯ä¸€å¸§éƒ½ä¼šè§¦å‘。您å¯ä»¥è‡ªå®šä¹‰ä¼˜å…ˆçº§ã€‚<br/> + - 自定义定时器:自定义定时器å¯ä»¥æ¯ä¸€å¸§æˆ–者自定义的时间间隔触å‘。<br/> + 如果希望æ¯å¸§éƒ½è§¦å‘,应该使用 update 定时器,使用 update 定时器更快,而且消耗更少的内å˜ã€‚ */ + export class Scheduler { + /** + !#en This method should be called for any target which needs to schedule tasks, and this method should be called before any scheduler API usage. + This method will add a `_id` property if it doesn't exist. + !#zh 任何需è¦ç”¨ Scheduler 管ç†ä»»åŠ¡çš„å¯¹è±¡ä¸»ä½“éƒ½åº”è¯¥è°ƒç”¨è¿™ä¸ªæ–¹æ³•ï¼Œå¹¶ä¸”åº”è¯¥åœ¨è°ƒç”¨ä»»ä½• Scheduler API 之å‰è°ƒç”¨è¿™ä¸ªæ–¹æ³•。 + è¿™ä¸ªæ–¹æ³•ä¼šç»™å¯¹è±¡æ·»åŠ ä¸€ä¸ª `_id` 属性,如果这个属性ä¸å˜åœ¨çš„è¯ã€‚ + @param target target + */ + enableForTarget(target: any): void; + /** + !#en + Modifies the time of all scheduled callbacks.<br/> + You can use this property to create a 'slow motion' or 'fast forward' effect.<br/> + Default is 1.0. To create a 'slow motion' effect, use values below 1.0.<br/> + To create a 'fast forward' effect, use values higher than 1.0.<br/> + Note:It will affect EVERY scheduled selector / action. + !#zh + 设置时间间隔的缩放比例。<br/> + 您å¯ä»¥ä½¿ç”¨è¿™ä¸ªæ–¹æ³•æ¥åˆ›å»ºä¸€ä¸ª “slow motion(慢动作)†或 “fast forward(快进)†的效果。<br/> + 默认是 1.0。è¦åˆ›å»ºä¸€ä¸ª “slow motion(慢动作)†效果,使用值低于 1.0。<br/> + è¦ä½¿ç”¨ “fast forward(快进)†效果,使用值大于 1.0。<br/> + 注æ„:它影å“该 Scheduler 下管ç†çš„æ‰€æœ‰å®šæ—¶å™¨ã€‚ + @param timeScale timeScale + */ + setTimeScale(timeScale: number): void; + /** + !#en Returns time scale of scheduler. + !#zh èŽ·å–æ—¶é—´é—´éš”的缩放比例。 + */ + getTimeScale(): number; + /** + !#en 'update' the scheduler. (You should NEVER call this method, unless you know what you are doing.) + !#zh update 调度函数。(ä¸åº”该直接调用这个方法,除éžå®Œå…¨äº†è§£è¿™ä¹ˆåšçš„结果) + @param dt delta time + */ + update(dt: number): void; + /** + !#en + <p> + The scheduled method will be called every 'interval' seconds.<br/> + If paused is YES, then it won't be called until it is resumed.<br/> + If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.<br/> + If the callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.<br/> + repeat let the action be repeated repeat + 1 times, use cc.macro.REPEAT_FOREVER to let the action run continuously<br/> + delay is the amount of time the action will wait before it'll start<br/> + </p> + !#zh + 指定回调函数,调用对象ç‰ä¿¡æ¯æ¥æ·»åŠ ä¸€ä¸ªæ–°çš„å®šæ—¶å™¨ã€‚<br/> + 如果 paused 值为 true,那么直到 resume 被调用æ‰å¼€å§‹è®¡æ—¶ã€‚<br/> + 当时间间隔达到指定值时,设置的回调函数将会被调用。<br/> + 如果 interval 值为 0,那么回调函数æ¯ä¸€å¸§éƒ½ä¼šè¢«è°ƒç”¨ï¼Œä½†å¦‚æžœæ˜¯è¿™æ ·ï¼Œ + 建议使用 scheduleUpdateForTarget 代替。<br/> + 如果回调函数已ç»è¢«å®šæ—¶å™¨ä½¿ç”¨ï¼Œé‚£ä¹ˆåªä¼šæ›´æ–°ä¹‹å‰å®šæ—¶å™¨çš„æ—¶é—´é—´éš”傿•°ï¼Œä¸ä¼šè®¾ç½®æ–°çš„定时器。<br/> + repeat 值å¯ä»¥è®©å®šæ—¶å™¨è§¦å‘ repeat + 1 次,使用 cc.macro.REPEAT_FOREVER + å¯ä»¥è®©å®šæ—¶å™¨ä¸€ç›´å¾ªçŽ¯è§¦å‘。<br/> + delay 值指定延迟时间,定时器会在延迟指定的时间之åŽå¼€å§‹è®¡æ—¶ã€‚ + @param callback callback + @param target target + @param interval interval + @param repeat repeat + @param delay delay + @param paused paused + + @example + ```js + //register a schedule to scheduler + cc.director.getScheduler().schedule(callback, this, interval, !this._isRunning); + + ``` */ - end(): void; + schedule(callback: Function, target: any, interval: number, repeat: number, delay: number, paused?: boolean): void; + schedule(callback: Function, target: any, interval: number, paused?: boolean): void; /** !#en - Register an callback of a specific event type on the game object. - This type of event should be triggered via `emit`. + Schedules the update callback for a given target, + During every frame after schedule started, the "update" function of target will be invoked. !#zh - 注册 game 的特定事件类型回调。这ç§ç±»åž‹çš„事件应该被 `emit` 触å‘。 - @param type A string representing the event type to listen for. - @param callback The callback that will be invoked when the event is dispatched. - The callback is ignored if it is a duplicate (the callbacks are unique). - @param target The target (this object) to invoke the callback, can be null + 使用指定的优先级为指定的对象设置 update 定时器。 + update 定时器æ¯ä¸€å¸§éƒ½ä¼šè¢«è§¦å‘ï¼Œè§¦å‘æ—¶è‡ªåŠ¨è°ƒç”¨æŒ‡å®šå¯¹è±¡çš„ "update" 函数。 + 优先级的值越低,定时器被触å‘的越早。 + @param target target + @param priority priority + @param paused paused */ - on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T; + scheduleUpdate(target: any, priority: number, paused: boolean): void; /** !#en - Register an callback of a specific event type on the game object, - the callback will remove itself after the first time it is triggered. + Unschedules a callback for a callback and a given target. + If you want to unschedule the "update", use `unscheduleUpdate()` !#zh - 注册 game 的特定事件类型回调,回调会在第一时间被触å‘åŽåˆ 除自身。 - @param type A string representing the event type to listen for. - @param callback The callback that will be invoked when the event is dispatched. - The callback is ignored if it is a duplicate (the callbacks are unique). - @param target The target (this object) to invoke the callback, can be null + å–æ¶ˆæŒ‡å®šå¯¹è±¡å®šæ—¶å™¨ã€‚ + 如果需è¦å–消 update 定时器,请使用 unscheduleUpdate()。 + @param callback The callback to be unscheduled + @param target The target bound to the callback. */ - once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + unschedule(callback: Function, target: any): void; /** - !#en Prepare game. - !#zh 准备引擎,请ä¸è¦ç›´æŽ¥è°ƒç”¨è¿™ä¸ªå‡½æ•°ã€‚ - @param cb cb + !#en Unschedules the update callback for a given target. + !#zh å–æ¶ˆæŒ‡å®šå¯¹è±¡çš„ update 定时器。 + @param target The target to be unscheduled. */ - prepare(cb: Function): void; + unscheduleUpdate(target: any): void; /** - !#en Run game with configuration object and onStart function. - !#zh è¿è¡Œæ¸¸æˆï¼Œå¹¶ä¸”指定引擎é…置和 onStart 的回调。 - @param config Pass configuration object or onStart function - @param onStart function to be executed after game initialized + !#en + Unschedules all scheduled callbacks for a given target. + This also includes the "update" callback. + !#zh å–æ¶ˆæŒ‡å®šå¯¹è±¡çš„æ‰€æœ‰å®šæ—¶å™¨ï¼ŒåŒ…括 update 定时器。 + @param target The target to be unscheduled. */ - run(config: any, onStart: Function): void; + unscheduleAllForTarget(target: any): void; /** !#en - Add a persistent root node to the game, the persistent node won't be destroyed during scene transition.<br/> - The target node must be placed in the root level of hierarchy, otherwise this API won't have any effect. + Unschedules all scheduled callbacks from all targets including the system callbacks.<br/> + You should NEVER call this method, unless you know what you are doing. !#zh - å£°æ˜Žå¸¸é©»æ ¹èŠ‚ç‚¹ï¼Œè¯¥èŠ‚ç‚¹ä¸ä¼šè¢«åœ¨åœºæ™¯åˆ‡æ¢ä¸è¢«é”€æ¯ã€‚<br/> - ç›®æ ‡èŠ‚ç‚¹å¿…é¡»ä½äºŽä¸ºå±‚çº§çš„æ ¹èŠ‚ç‚¹ï¼Œå¦åˆ™æ— 效。 - @param node The node to be made persistent + å–æ¶ˆæ‰€æœ‰å¯¹è±¡çš„æ‰€æœ‰å®šæ—¶å™¨ï¼ŒåŒ…括系统定时器。<br/> + ä¸è¦è°ƒç”¨æ¤å‡½æ•°ï¼Œé™¤éžä½ ç¡®å®šä½ åœ¨åšä»€ä¹ˆã€‚ */ - addPersistRootNode(node: Node): void; + unscheduleAll(): void; /** - !#en Remove a persistent root node. - !#zh å–æ¶ˆå¸¸é©»æ ¹èŠ‚ç‚¹ã€‚ - @param node The node to be removed from persistent node list + !#en + Unschedules all callbacks from all targets with a minimum priority.<br/> + You should only call this with `PRIORITY_NON_SYSTEM_MIN` or higher. + !#zh + å–æ¶ˆæ‰€æœ‰ä¼˜å…ˆçº§çš„值大于指定优先级的定时器。<br/> + ä½ åº”è¯¥åªå–消优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。 + @param minPriority The minimum priority of selector to be unscheduled. Which means, all selectors which + priority is higher than minPriority will be unscheduled. */ - removePersistRootNode(node: Node): void; + unscheduleAllWithMinPriority(minPriority: number): void; /** - !#en Check whether the node is a persistent root node. - !#zh æ£€æŸ¥èŠ‚ç‚¹æ˜¯å¦æ˜¯å¸¸é©»æ ¹èŠ‚ç‚¹ã€‚ - @param node The node to be checked + !#en Checks whether a callback for a given target is scheduled. + !#zh æ£€æŸ¥æŒ‡å®šçš„å›žè°ƒå‡½æ•°å’Œå›žè°ƒå¯¹è±¡ç»„åˆæ˜¯å¦å˜åœ¨å®šæ—¶å™¨ã€‚ + @param callback The callback to check. + @param target The target of the callback. */ - isPersistRootNode(node: Node): boolean; - } - /** !#en - Class of all entities in Cocos Creator scenes.<br/> - For events supported by Node, please refer to {{#crossLink "Node.EventType"}}{{/crossLink}} - !#zh - Cocos Creator 场景ä¸çš„æ‰€æœ‰èŠ‚ç‚¹ç±»ã€‚<br/> - 支æŒçš„节点事件,请å‚阅 {{#crossLink "Node.EventType"}}{{/crossLink}}。 */ - export class Node extends _BaseNode { - /** !#en - Group index of node.<br/> - Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.<br/> - !#zh - 节点的分组索引。<br/> - 节点的分组将关系到节点的碰撞组件å¯ä»¥ä¸Žå“ªäº›ç¢°æ’žç»„件相碰撞。<br/> */ - groupIndex: number; - /** !#en - Group of node.<br/> - Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.<br/> - !#zh - 节点的分组。<br/> - 节点的分组将关系到节点的碰撞组件å¯ä»¥ä¸Žå“ªäº›ç¢°æ’žç»„件相碰撞。<br/> */ - group: string; - /** !#en The position (x, y) of the node in its parent's coordinates. - !#zh èŠ‚ç‚¹åœ¨çˆ¶èŠ‚ç‚¹åæ ‡ç³»ä¸çš„ä½ç½®ï¼ˆx, y)。 */ - position: Vec3; - /** !#en x axis position of node. - !#zh 节点 X è½´åæ ‡ã€‚ */ - x: number; - /** !#en y axis position of node. - !#zh 节点 Y è½´åæ ‡ã€‚ */ - y: number; - /** !#en z axis position of node. - !#zh 节点 Z è½´åæ ‡ã€‚ */ - z: number; - /** !#en Rotation of node. - !#zh 该节点旋转角度。 */ - rotation: number; - /** !#en - Angle of node, the positive value is anti-clockwise direction. - !#zh - 该节点的旋转角度,æ£å€¼ä¸ºé€†æ—¶é’ˆæ–¹å‘。 */ - angle: number; - /** !#en The rotation as Euler angles in degrees, used in 3D node. - !#zh 该节点的欧拉角度,用于 3D 节点。 */ - eulerAngles: Vec3; - /** !#en Rotation on x axis. - !#zh 该节点 X 轴旋转角度。 */ - rotationX: number; - /** !#en Rotation on y axis. - !#zh 该节点 Y 轴旋转角度。 */ - rotationY: number; - /** !#en The local scale relative to the parent. - !#zh 节点相对父节点的缩放。 */ - scale: number; - /** !#en Scale on x axis. - !#zh 节点 X 轴缩放。 */ - scaleX: number; - /** !#en Scale on y axis. - !#zh 节点 Y 轴缩放。 */ - scaleY: number; - /** !#en Scale on z axis. - !#zh 节点 Z 轴缩放。 */ - scaleZ: number; - /** !#en Skew x - !#zh 该节点 X 轴倾斜角度。 */ - skewX: number; - /** !#en Skew y - !#zh 该节点 Y 轴倾斜角度。 */ - skewY: number; - /** !#en Opacity of node, default value is 255. - !#zh èŠ‚ç‚¹é€æ˜Žåº¦ï¼Œé»˜è®¤å€¼ä¸º 255。 */ - opacity: number; - /** !#en Color of node, default value is white: (255, 255, 255). - !#zh 节点颜色。默认为白色,数值为:(255,255,255)。 */ - color: Color; - /** !#en Anchor point's position on x axis. - !#zh 节点 X 轴锚点ä½ç½®ã€‚ */ - anchorX: number; - /** !#en Anchor point's position on y axis. - !#zh 节点 Y 轴锚点ä½ç½®ã€‚ */ - anchorY: number; - /** !#en Width of node. - !#zh 节点宽度。 */ - width: number; - /** !#en Height of node. - !#zh 节点高度。 */ - height: number; - /** !#en zIndex is the 'key' used to sort the node relative to its siblings.<br/> - The value of zIndex should be in the range between cc.macro.MIN_ZINDEX and cc.macro.MAX_ZINDEX.<br/> - The Node's parent will sort all its children based on the zIndex value and the arrival order.<br/> - Nodes with greater zIndex will be sorted after nodes with smaller zIndex.<br/> - If two nodes have the same zIndex, then the node that was added first to the children's array will be in front of the other node in the array.<br/> - Node's order in children list will affect its rendering order. Parent is always rendering before all children. - !#zh zIndex 是用æ¥å¯¹èŠ‚ç‚¹è¿›è¡ŒæŽ’åºçš„关键属性,它决定一个节点在兄弟节点之间的ä½ç½®ã€‚<br/> - zIndex çš„å–值应该介于 cc.macro.MIN_ZINDEX å’Œ cc.macro.MAX_ZINDEX 之间 - çˆ¶èŠ‚ç‚¹ä¸»è¦æ ¹æ®èŠ‚ç‚¹çš„ zIndex å’Œæ·»åŠ æ¬¡åºæ¥æŽ’åºï¼Œæ‹¥æœ‰æ›´é«˜ zIndex 的节点将被排在åŽé¢ï¼Œå¦‚果两个节点的 zIndex ä¸€è‡´ï¼Œå…ˆæ·»åŠ çš„èŠ‚ç‚¹ä¼šç¨³å®šæŽ’åœ¨å¦ä¸€ä¸ªèŠ‚ç‚¹ä¹‹å‰ã€‚<br/> - 节点在 children ä¸çš„顺åºå†³å®šäº†å…¶æ¸²æŸ“顺åºã€‚父节点永远在所有å节点之å‰è¢«æ¸²æŸ“ */ - zIndex: number; - /** !#en - Switch 2D/3D node. The 2D nodes will run faster. - !#zh - åˆ‡æ¢ 2D/3D 节点,2D 节点会有更高的è¿è¡Œæ•ˆçއ */ - is3DNode: boolean; - /** !#en Returns a normalized vector representing the up direction (Y axis) of the node in world space. - !#zh 获å–节点æ£ä¸Šæ–¹ï¼ˆy 轴)é¢å¯¹çš„æ–¹å‘ï¼Œè¿”å›žå€¼ä¸ºä¸–ç•Œåæ ‡ç³»ä¸‹çš„归一化å‘é‡ */ - up: Vec3; - /** !#en Returns a normalized vector representing the right direction (X axis) of the node in world space. - !#zh 获å–节点æ£å³æ–¹ï¼ˆx 轴)é¢å¯¹çš„æ–¹å‘ï¼Œè¿”å›žå€¼ä¸ºä¸–ç•Œåæ ‡ç³»ä¸‹çš„归一化å‘é‡ */ - right: Vec3; - /** !#en Returns a normalized vector representing the forward direction (Z axis) of the node in world space. - !#zh 获å–节点æ£å‰æ–¹ï¼ˆz 轴)é¢å¯¹çš„æ–¹å‘ï¼Œè¿”å›žå€¼ä¸ºä¸–ç•Œåæ ‡ç³»ä¸‹çš„归一化å‘é‡ */ - forward: Vec3; + isScheduled(callback: Function, target: any): boolean; /** - - @param name name + !#en + Pause all selectors from all targets.<br/> + You should NEVER call this method, unless you know what you are doing. + !#zh + æš‚åœæ‰€æœ‰å¯¹è±¡çš„æ‰€æœ‰å®šæ—¶å™¨ã€‚<br/> + ä¸è¦è°ƒç”¨è¿™ä¸ªæ–¹æ³•,除éžä½ 知é“ä½ æ£åœ¨åšä»€ä¹ˆã€‚ */ - constructor(name?: string); + pauseAllTargets(): void; /** !#en - Register a callback of a specific event type on Node.<br/> - Use this method to register touch or mouse event permit propagation based on scene graph,<br/> - These kinds of event are triggered with dispatchEvent, the dispatch process has three steps:<br/> - 1. Capturing phase: dispatch in capture targets (`_getCapturingTargets`), e.g. parents in node tree, from root to the real target<br/> - 2. At target phase: dispatch to the listeners of the real target<br/> - 3. Bubbling phase: dispatch in bubble targets (`_getBubblingTargets`), e.g. parents in node tree, from the real target to root<br/> - In any moment of the dispatching process, it can be stopped via `event.stopPropagation()` or `event.stopPropagationImmidiate()`.<br/> - It's the recommended way to register touch/mouse event for Node,<br/> - please do not use cc.eventManager directly for Node.<br/> - You can also register custom event and use `emit` to trigger custom event on Node.<br/> - For such events, there won't be capturing and bubbling phase, your event will be dispatched directly to its listeners registered on the same node.<br/> - You can also pass event callback parameters with `emit` by passing parameters after `type`. - !#zh - 在节点上注册指定类型的回调函数,也å¯ä»¥è®¾ç½® target 用于绑定å“应函数的 this 对象。<br/> - é¼ æ ‡æˆ–è§¦æ‘¸äº‹ä»¶ä¼šè¢«ç³»ç»Ÿè°ƒç”¨ dispatchEvent 方法触å‘,触å‘的过程包å«ä¸‰ä¸ªé˜¶æ®µï¼š<br/> - 1. æ•获阶段:派å‘事件给æ•èŽ·ç›®æ ‡ï¼ˆé€šè¿‡ `_getCapturingTargets` 获å–ï¼‰ï¼Œæ¯”å¦‚ï¼ŒèŠ‚ç‚¹æ ‘ä¸æ³¨å†Œäº†æ•èŽ·é˜¶æ®µçš„çˆ¶èŠ‚ç‚¹ï¼Œä»Žæ ¹èŠ‚ç‚¹å¼€å§‹æ´¾å‘ç›´åˆ°ç›®æ ‡èŠ‚ç‚¹ã€‚<br/> - 2. ç›®æ ‡é˜¶æ®µï¼šæ´¾å‘ç»™ç›®æ ‡èŠ‚ç‚¹çš„ç›‘å¬å™¨ã€‚<br/> - 3. 冒泡阶段:派å‘äº‹ä»¶ç»™å†’æ³¡ç›®æ ‡ï¼ˆé€šè¿‡ `_getBubblingTargets` 获å–ï¼‰ï¼Œæ¯”å¦‚ï¼ŒèŠ‚ç‚¹æ ‘ä¸æ³¨å†Œäº†å†’æ³¡é˜¶æ®µçš„çˆ¶èŠ‚ç‚¹ï¼Œä»Žç›®æ ‡èŠ‚ç‚¹å¼€å§‹æ´¾å‘ç›´åˆ°æ ¹èŠ‚ç‚¹ã€‚<br/> - åŒæ—¶æ‚¨å¯ä»¥å°†äº‹ä»¶æ´¾å‘到父节点或者通过调用 stopPropagation 拦截它。<br/> - 推èä½¿ç”¨è¿™ç§æ–¹å¼æ¥ç›‘å¬èŠ‚ç‚¹ä¸Šçš„è§¦æ‘¸æˆ–é¼ æ ‡äº‹ä»¶ï¼Œè¯·ä¸è¦åœ¨èŠ‚ç‚¹ä¸Šç›´æŽ¥ä½¿ç”¨ cc.eventManager。<br/> - ä½ ä¹Ÿå¯ä»¥æ³¨å†Œè‡ªå®šä¹‰äº‹ä»¶åˆ°èŠ‚ç‚¹ä¸Šï¼Œå¹¶é€šè¿‡ emit æ–¹æ³•è§¦å‘æ¤ç±»äº‹ä»¶ï¼Œå¯¹äºŽè¿™ç±»äº‹ä»¶ï¼Œä¸ä¼šå‘生æ•获冒泡阶段,åªä¼šç›´æŽ¥æ´¾å‘给注册在该节点上的监å¬å™¨<br/> - ä½ å¯ä»¥é€šè¿‡åœ¨ emit 方法调用时在 type 之åŽä¼ 递é¢å¤–çš„å‚æ•°ä½œä¸ºäº‹ä»¶å›žè°ƒçš„傿•°åˆ—表 - @param type A string representing the event type to listen for.<br>See {{#crossLink "Node/EventTyupe/POSITION_CHANGED"}}Node Events{{/crossLink}} for all builtin events. - @param callback The callback that will be invoked when the event is dispatched. The callback is ignored if it is a duplicate (the callbacks are unique). - @param target The target (this object) to invoke the callback, can be null - @param useCapture When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase. - - @example - ```js - this.node.on(cc.Node.EventType.TOUCH_START, this.memberFunction, this); // if "this" is component and the "memberFunction" declared in CCClass. - node.on(cc.Node.EventType.TOUCH_START, callback, this); - node.on(cc.Node.EventType.TOUCH_MOVE, callback, this); - node.on(cc.Node.EventType.TOUCH_END, callback, this); - node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this); - node.on(cc.Node.EventType.ANCHOR_CHANGED, callback); - node.on(cc.Node.EventType.COLOR_CHANGED, callback); - ``` + Pause all selectors from all targets with a minimum priority. <br/> + You should only call this with kCCPriorityNonSystemMin or higher. + !#zh + æš‚åœæ‰€æœ‰ä¼˜å…ˆçº§çš„值大于指定优先级的定时器。<br/> + ä½ åº”è¯¥åªæš‚åœä¼˜å…ˆçº§çš„值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。 + @param minPriority minPriority */ - on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T; + pauseAllTargetsWithMinPriority(minPriority: number): void; /** !#en - Register an callback of a specific event type on the Node, - the callback will remove itself after the first time it is triggered. + Resume selectors on a set of targets.<br/> + This can be useful for undoing a call to pauseAllCallbacks. !#zh - 注册节点的特定事件类型回调,回调会在第一时间被触å‘åŽåˆ 除自身。 - @param type A string representing the event type to listen for. - @param callback The callback that will be invoked when the event is dispatched. - The callback is ignored if it is a duplicate (the callbacks are unique). - @param target The target (this object) to invoke the callback, can be null - - @example - ```js - node.once(cc.Node.EventType.ANCHOR_CHANGED, callback); - ``` + æ¢å¤æŒ‡å®šæ•°ç»„䏿‰€æœ‰å¯¹è±¡çš„定时器。<br/> + 这个函数是 pauseAllCallbacks 的逆æ“作。 + @param targetsToResume targetsToResume */ - once<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T; + resumeTargets(targetsToResume: any[]): void; /** !#en - Removes the callback previously registered with the same type, callback, target and or useCapture. - This method is merely an alias to removeEventListener. - !#zh åˆ é™¤ä¹‹å‰ä¸ŽåŒç±»åž‹ï¼Œå›žè°ƒï¼Œç›®æ ‡æˆ– useCapture 注册的回调。 - @param type A string representing the event type being removed. - @param callback The callback to remove. - @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed - @param useCapture When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase. + Pauses the target.<br/> + All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.<br/> + If the target is not present, nothing happens. + !#zh + æš‚åœæŒ‡å®šå¯¹è±¡çš„定时器。<br/> + 指定对象的所有定时器都会被暂åœã€‚<br/> + 如果指定的对象没有定时器,什么也ä¸ä¼šå‘生。 + @param target target + */ + pauseTarget(target: any): void; + /** + !#en + Resumes the target.<br/> + The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.<br/> + If the target is not present, nothing happens. + !#zh + æ¢å¤æŒ‡å®šå¯¹è±¡çš„æ‰€æœ‰å®šæ—¶å™¨ã€‚<br/> + 指定对象的所有定时器将继ç»å·¥ä½œã€‚<br/> + 如果指定的对象没有定时器,什么也ä¸ä¼šå‘生。 + @param target target + */ + resumeTarget(target: any): void; + /** + !#en Returns whether or not the target is paused. + !#zh è¿”å›žæŒ‡å®šå¯¹è±¡çš„å®šæ—¶å™¨æ˜¯å¦æš‚åœäº†ã€‚ + @param target target + */ + isTargetPaused(target: any): boolean; + /** !#en Priority level reserved for system services. + !#zh 系统æœåŠ¡çš„ä¼˜å…ˆçº§ã€‚ */ + static PRIORITY_SYSTEM: number; + /** !#en Minimum priority level for user scheduling. + !#zh 用户调度最低优先级。 */ + static PRIORITY_NON_SYSTEM: number; + } + /** !#en cc.VideoPlayer is a component for playing videos, you can use it for showing videos in your game. Because different platforms have different authorization, API and control methods for VideoPlayer component. And have not yet formed a unified standard, only Web, iOS, and Android platforms are currently supported. + !#zh Video 组件,用于在游æˆä¸æ’放视频。由于ä¸åŒå¹³å°å¯¹äºŽ VideoPlayer 组件的授æƒã€APIã€æŽ§åˆ¶æ–¹å¼éƒ½ä¸åŒï¼Œè¿˜æ²¡æœ‰å½¢æˆç»Ÿä¸€çš„æ ‡å‡†ï¼Œæ‰€ä»¥ç›®å‰åªæ”¯æŒ Webã€iOS å’Œ Android å¹³å°ã€‚ */ + export class VideoPlayer extends Component { + /** !#en The resource type of videoplayer, REMOTE for remote url and LOCAL for local file path. + !#zh è§†é¢‘æ¥æºï¼šREMOTE 表示远程视频 URL,LOCAL 表示本地视频地å€ã€‚ */ + resourceType: VideoPlayer.ResourceType; + /** !#en The remote URL of video. + !#zh 远程视频的 URL */ + remoteURL: string; + /** !#en The local video full path. + !#zh 本地视频的 URL */ + clip: string; + /** !#en The current playback time of the now playing item in seconds, you could also change the start playback time. + !#zh æŒ‡å®šè§†é¢‘ä»Žä»€ä¹ˆæ—¶é—´ç‚¹å¼€å§‹æ’æ”¾ï¼Œå•使˜¯ç§’,也å¯ä»¥ç”¨æ¥èŽ·å–当å‰è§†é¢‘æ’æ”¾çš„æ—¶é—´è¿›åº¦ã€‚ */ + currentTime: number; + /** !#en The volume of the video. + !#zh 视频的音é‡ï¼ˆ0.0 ~ 1.0) */ + volume: number; + /** !#en Mutes the VideoPlayer. Mute sets the volume=0, Un-Mute restore the original volume. + !#zh 是å¦é™éŸ³è§†é¢‘。é™éŸ³æ—¶è®¾ç½®éŸ³é‡ä¸º 0ï¼Œå–æ¶ˆé™éŸ³æ˜¯æ¢å¤åŽŸæ¥çš„音é‡ã€‚ */ + mute: boolean; + /** !#en Whether keep the aspect ration of the original video. + !#zh 是å¦ä¿æŒè§†é¢‘原æ¥çš„宽高比 */ + keepAspectRatio: boolean; + /** !#en Whether play video in fullscreen mode. + !#zh 是å¦å…¨å±æ’放视频 */ + isFullscreen: boolean; + /** !#en Always below the game view (only useful on Web. Note: The specific effects are not guaranteed to be consistent, depending on whether each browser supports or restricts). + !#zh 永远在游æˆè§†å›¾æœ€åº•å±‚ï¼ˆè¿™ä¸ªå±žæ€§åªæœ‰åœ¨ Web å¹³å°ä¸Šæœ‰æ•ˆæžœã€‚注æ„ï¼šå…·ä½“æ•ˆæžœæ— æ³•ä¿è¯ä¸€è‡´ï¼Œè·Ÿå„个æµè§ˆå™¨æ˜¯å¦æ”¯æŒä¸Žé™åˆ¶æœ‰å…³ï¼‰ */ + stayOnBottom: boolean; + /** !#en the video player's callback, it will be triggered when certain event occurs, like: playing, paused, stopped and completed. + !#zh è§†é¢‘æ’æ”¾å›žè°ƒå‡½æ•°ï¼Œè¯¥å›žè°ƒå‡½æ•°ä¼šåœ¨ç‰¹å®šæƒ…况被触å‘ï¼Œæ¯”å¦‚æ’æ”¾ä¸ï¼Œæš‚æ—¶ï¼Œåœæ¢å’Œå®Œæˆæ’放。 */ + videoPlayerEvent: Component.EventHandler[]; + /** + !#en If a video is paused, call this method could resume playing. If a video is stopped, call this method to play from scratch. + !#zh å¦‚æžœè§†é¢‘è¢«æš‚åœæ’放了,调用这个接å£å¯ä»¥ç»§ç»æ’æ”¾ã€‚å¦‚æžœè§†é¢‘è¢«åœæ¢æ’放了,调用这个接å£å¯ä»¥ä»Žå¤´å¼€å§‹æ’放。 + */ + play(): void; + /** + !#en If a video is paused, call this method to resume playing. + !#zh å¦‚æžœä¸€ä¸ªè§†é¢‘æ’æ”¾è¢«æš‚åœæ’放了,调用这个接å£å¯ä»¥ç»§ç»æ’放。 + */ + resume(): void; + /** + !#en If a video is playing, call this method to pause playing. + !#zh 如果一个视频æ£åœ¨æ’放,调用这个接å£å¯ä»¥æš‚åœæ’放。 + */ + pause(): void; + /** + !#en If a video is playing, call this method to stop playing immediately. + !#zh 如果一个视频æ£åœ¨æ’放,调用这个接å£å¯ä»¥ç«‹é©¬åœæ¢æ’放。 + */ + stop(): void; + /** + !#en Gets the duration of the video + !#zh 获å–è§†é¢‘æ–‡ä»¶çš„æ’æ”¾æ€»æ—¶é•¿ + */ + getDuration(): number; + /** + !#en Determine whether video is playing or not. + !#zh 判æ–当å‰è§†é¢‘是å¦å¤„äºŽæ’æ”¾çŠ¶æ€ + */ + isPlaying(): boolean; + /** + !#en if you don't need the VideoPlayer and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + å¦‚æžœä½ ä¸å†ä½¿ç”¨ VideoPlayerï¼Œå¹¶ä¸”ç»„ä»¶æœªæ·»åŠ åˆ°åœºæ™¯ä¸ï¼Œé‚£ä¹ˆä½ 必须手动对组件或所在节点调用 destroy。 + è¿™æ ·æ‰èƒ½ç§»é™¤ç½‘页上的 DOM 节点,é¿å… Web å¹³å°å†…å˜æ³„露。 @example ```js - this.node.off(cc.Node.EventType.TOUCH_START, this.memberFunction, this); - node.off(cc.Node.EventType.TOUCH_START, callback, this.node); - node.off(cc.Node.EventType.ANCHOR_CHANGED, callback, this); + videoplayer.node.parent = null; // or videoplayer.node.removeFromParent(false); + // when you don't need videoplayer anymore + videoplayer.node.destroy(); ``` */ - off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; + destroy(): boolean; + } + /** Class for particle asset handling. */ + export class ParticleAsset extends Asset { + } + /** Particle System base class. <br/> + Attributes of a Particle System:<br/> + - emmision rate of the particles<br/> + - Gravity Mode (Mode A): <br/> + - gravity <br/> + - direction <br/> + - speed +- variance <br/> + - tangential acceleration +- variance<br/> + - radial acceleration +- variance<br/> + - Radius Mode (Mode B): <br/> + - startRadius +- variance <br/> + - endRadius +- variance <br/> + - rotate +- variance <br/> + - Properties common to all modes: <br/> + - life +- life variance <br/> + - start spin +- variance <br/> + - end spin +- variance <br/> + - start size +- variance <br/> + - end size +- variance <br/> + - start color +- variance <br/> + - end color +- variance <br/> + - life +- variance <br/> + - blending function <br/> + - texture <br/> + <br/> + cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).<br/> + 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d, <br/> + cocos2d uses a another approach, but the results are almost identical.<br/> + cocos2d supports all the variables used by Particle Designer plus a bit more: <br/> + - spinning particles (supported when using ParticleSystem) <br/> + - tangential acceleration (Gravity mode) <br/> + - radial acceleration (Gravity mode) <br/> + - radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only) <br/> + It is possible to customize any of the above mentioned properties in runtime. Example: <br/> */ + export class ParticleSystem extends RenderComponent implements BlendFunc { + /** !#en Play particle in edit mode. + !#zh 在编辑器模å¼ä¸‹é¢„览粒å,å¯ç”¨åŽé€‰ä¸ç²’åæ—¶ï¼Œç²’åå°†è‡ªåŠ¨æ’æ”¾ã€‚ */ + preview: boolean; + /** !#en + If set custom to true, then use custom properties insteadof read particle file. + !#zh 是å¦è‡ªå®šä¹‰ç²’å属性。 */ + custom: boolean; + /** !#en The plist file. + !#zh plist æ ¼å¼çš„ç²’åé…置文件。 */ + file: ParticleAsset; + /** !#en SpriteFrame used for particles display + !#zh 用于粒å呈现的 SpriteFrame */ + spriteFrame: SpriteFrame; + /** !#en Texture of Particle System, readonly, please use spriteFrame to setup new texture。 + !#zh ç²’å贴图,åªè¯»å±žæ€§ï¼Œè¯·ä½¿ç”¨ spriteFrame å±žæ€§æ¥æ›¿æ¢è´´å›¾ã€‚ */ + texture: string; + /** !#en Current quantity of particles that are being simulated. + !#zh 当剿’æ”¾çš„ç²’åæ•°é‡ã€‚ */ + particleCount: number; + /** !#en Indicate whether the system simulation have stopped. + !#zh æŒ‡ç¤ºç²’åæ’æ”¾æ˜¯å¦å®Œæ¯•。 */ + stopped: boolean; + /** !#en If set to true, the particle system will automatically start playing on onLoad. + !#zh 如果设置为 true è¿è¡Œæ—¶ä¼šè‡ªåЍå‘å°„ç²’å。 */ + playOnLoad: boolean; + /** !#en Indicate whether the owner node will be auto-removed when it has no particles left. + !#zh ç²’åæ’æ”¾å®Œæ¯•åŽè‡ªåŠ¨é”€æ¯æ‰€åœ¨çš„节点。 */ + autoRemoveOnFinish: boolean; + /** !#en Indicate whether the particle system is activated. + !#zh æ˜¯å¦æ¿€æ´»ç²’å。 */ + active: boolean; + /** !#en Maximum particles of the system. + !#zh ç²’åæœ€å¤§æ•°é‡ã€‚ */ + totalParticles: number; + /** !#en How many seconds the emitter wil run. -1 means 'forever'. + !#zh å‘å°„å™¨ç”Ÿå˜æ—¶é—´ï¼Œå•ä½ç§’,-1表示æŒç»å‘射。 */ + duration: number; + /** !#en Emission rate of the particles. + !#zh æ¯ç§’å‘å°„çš„ç²’åæ•°ç›®ã€‚ */ + emissionRate: number; + /** !#en Life of each particle setter. + !#zh ç²’åçš„è¿è¡Œæ—¶é—´ã€‚ */ + life: number; + /** !#en Variation of life. + !#zh ç²’åçš„è¿è¡Œæ—¶é—´å˜åŒ–范围。 */ + lifeVar: number; + /** !#en Start color of each particle. + !#zh ç²’ååˆå§‹é¢œè‰²ã€‚ */ + startColor: Color; + /** !#en Variation of the start color. + !#zh ç²’ååˆå§‹é¢œè‰²å˜åŒ–范围。 */ + startColorVar: Color; + /** !#en Ending color of each particle. + !#zh ç²’å结æŸé¢œè‰²ã€‚ */ + endColor: Color; + /** !#en Variation of the end color. + !#zh ç²’å结æŸé¢œè‰²å˜åŒ–范围。 */ + endColorVar: Color; + /** !#en Angle of each particle setter. + !#zh ç²’å角度。 */ + angle: number; + /** !#en Variation of angle of each particle setter. + !#zh ç²’å角度å˜åŒ–范围。 */ + angleVar: number; + /** !#en Start size in pixels of each particle. + !#zh ç²’åçš„åˆå§‹å¤§å°ã€‚ */ + startSize: number; + /** !#en Variation of start size in pixels. + !#zh ç²’ååˆå§‹å¤§å°çš„å˜åŒ–范围。 */ + startSizeVar: number; + /** !#en End size in pixels of each particle. + !#zh ç²’åç»“æŸæ—¶çš„大å°ã€‚ */ + endSize: number; + /** !#en Variation of end size in pixels. + !#zh ç²’å结æŸå¤§å°çš„å˜åŒ–范围。 */ + endSizeVar: number; + /** !#en Start angle of each particle. + !#zh ç²’å开始自旋角度。 */ + startSpin: number; + /** !#en Variation of start angle. + !#zh ç²’å开始自旋角度å˜åŒ–范围。 */ + startSpinVar: number; + /** !#en End angle of each particle. + !#zh ç²’å结æŸè‡ªæ—‹è§’度。 */ + endSpin: number; + /** !#en Variation of end angle. + !#zh ç²’å结æŸè‡ªæ—‹è§’度å˜åŒ–范围。 */ + endSpinVar: number; + /** !#en Source position of the emitter. + !#zh å‘射器ä½ç½®ã€‚ */ + sourcePos: Vec2; + /** !#en Variation of source position. + !#zh å‘射器ä½ç½®çš„å˜åŒ–范围。(横å‘和纵å‘) */ + posVar: Vec2; + /** !#en Particles movement type. + !#zh ç²’åä½ç½®ç±»åž‹ã€‚ */ + positionType: ParticleSystem.PositionType; + /** !#en Particles emitter modes. + !#zh å‘射器类型。 */ + emitterMode: ParticleSystem.EmitterMode; + /** !#en Gravity of the emitter. + !#zh é‡åŠ›ã€‚ */ + gravity: Vec2; + /** !#en Speed of the emitter. + !#zh 速度。 */ + speed: number; + /** !#en Variation of the speed. + !#zh 速度å˜åŒ–范围。 */ + speedVar: number; + /** !#en Tangential acceleration of each particle. Only available in 'Gravity' mode. + !#zh æ¯ä¸ªç²’å的切å‘åŠ é€Ÿåº¦ï¼Œå³åž‚直于é‡åŠ›æ–¹å‘çš„åŠ é€Ÿåº¦ï¼Œåªæœ‰åœ¨é‡åŠ›æ¨¡å¼ä¸‹å¯ç”¨ã€‚ */ + tangentialAccel: number; + /** !#en Variation of the tangential acceleration. + !#zh æ¯ä¸ªç²’å的切å‘åŠ é€Ÿåº¦å˜åŒ–范围。 */ + tangentialAccelVar: number; + /** !#en Acceleration of each particle. Only available in 'Gravity' mode. + !#zh ç²’å径å‘åŠ é€Ÿåº¦ï¼Œå³å¹³è¡ŒäºŽé‡åŠ›æ–¹å‘çš„åŠ é€Ÿåº¦ï¼Œåªæœ‰åœ¨é‡åŠ›æ¨¡å¼ä¸‹å¯ç”¨ã€‚ */ + radialAccel: number; + /** !#en Variation of the radial acceleration. + !#zh ç²’å径å‘åŠ é€Ÿåº¦å˜åŒ–范围。 */ + radialAccelVar: number; + /** !#en Indicate whether the rotation of each particle equals to its direction. Only available in 'Gravity' mode. + !#zh æ¯ä¸ªç²’å的旋转是å¦ç‰äºŽå…¶æ–¹å‘ï¼Œåªæœ‰åœ¨é‡åŠ›æ¨¡å¼ä¸‹å¯ç”¨ã€‚ */ + rotationIsDir: boolean; + /** !#en Starting radius of the particles. Only available in 'Radius' mode. + !#zh åˆå§‹åŠå¾„,表示粒å出生时相对å‘射器的è·ç¦»ï¼Œåªæœ‰åœ¨åŠå¾„模å¼ä¸‹å¯ç”¨ã€‚ */ + startRadius: number; + /** !#en Variation of the starting radius. + !#zh åˆå§‹åŠå¾„å˜åŒ–范围。 */ + startRadiusVar: number; + /** !#en Ending radius of the particles. Only available in 'Radius' mode. + !#zh 结æŸåŠå¾„ï¼Œåªæœ‰åœ¨åŠå¾„模å¼ä¸‹å¯ç”¨ã€‚ */ + endRadius: number; + /** !#en Variation of the ending radius. + !#zh 结æŸåŠå¾„å˜åŒ–范围。 */ + endRadiusVar: number; + /** !#en Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode. + !#zh ç²’åæ¯ç§’å›´ç»•èµ·å§‹ç‚¹çš„æ—‹è½¬è§’åº¦ï¼Œåªæœ‰åœ¨åŠå¾„模å¼ä¸‹å¯ç”¨ã€‚ */ + rotatePerS: number; + /** !#en Variation of the degress to rotate a particle around the source pos per second. + !#zh ç²’åæ¯ç§’å›´ç»•èµ·å§‹ç‚¹çš„æ—‹è½¬è§’åº¦å˜åŒ–范围。 */ + rotatePerSVar: number; + /** !#en The Particle emitter lives forever. + !#zh 表示å‘射器永久å˜åœ¨ */ + static DURATION_INFINITY: number; + /** !#en The starting size of the particle is equal to the ending size. + !#zh 表示粒å的起始大å°ç‰äºŽç»“æŸå¤§å°ã€‚ */ + static START_SIZE_EQUAL_TO_END_SIZE: number; + /** !#en The starting radius of the particle is equal to the ending radius. + !#zh 表示粒å的起始åŠå¾„ç‰äºŽç»“æŸåŠå¾„。 */ + static START_RADIUS_EQUAL_TO_END_RADIUS: number; /** - !#en Removes all callbacks previously registered with the same target. - !#zh ç§»é™¤ç›®æ ‡ä¸Šçš„æ‰€æœ‰æ³¨å†Œäº‹ä»¶ã€‚ - @param target The target to be searched for all related callbacks + !#en Stop emitting particles. Running particles will continue to run until they die. + !#zh åœæ¢å‘射器å‘å°„ç²’å,å‘射出去的粒å将继ç»è¿è¡Œï¼Œç›´è‡³ç²’å生命结æŸã€‚ @example ```js - node.targetOff(target); + // stop particle system. + myParticleSystem.stopSystem(); ``` */ - targetOff(target: any): void; - /** - !#en Checks whether the EventTarget object has any callback registered for a specific type of event. - !#zh æ£€æŸ¥äº‹ä»¶ç›®æ ‡å¯¹è±¡æ˜¯å¦æœ‰ä¸ºç‰¹å®šç±»åž‹çš„事件注册的回调。 - @param type The type of event. - */ - hasEventListener(type: string): boolean; + stopSystem(): void; /** - !#en - Trigger an event directly with the event name and necessary arguments. - !#zh - 通过事件åå‘é€è‡ªå®šä¹‰äº‹ä»¶ - @param type event type - @param arg1 First argument in callback - @param arg2 Second argument in callback - @param arg3 Third argument in callback - @param arg4 Fourth argument in callback - @param arg5 Fifth argument in callback + !#en Kill all living particles. + !#zh æ€æ»æ‰€æœ‰å˜åœ¨çš„ç²’å,然åŽé‡æ–°å¯åŠ¨ç²’åå‘射器。 @example ```js - eventTarget.emit('fire', event); - eventTarget.emit('fire', message, emitter); + // play particle system. + myParticleSystem.resetSystem(); ``` */ - emit(type: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any): void; + resetSystem(): void; /** - !#en - Dispatches an event into the event flow. - The event target is the EventTarget object upon which the dispatchEvent() method is called. - !#zh 分å‘事件到事件æµä¸ã€‚ - @param event The Event object that is dispatched into the event flow + !#en Whether or not the system is full. + !#zh å‘射器ä¸ç²’åæ˜¯å¦å¤§äºŽç‰äºŽè®¾ç½®çš„æ€»ç²’åæ•°é‡ã€‚ */ - dispatchEvent(event: Event): void; + isFull(): boolean; /** - !#en Pause node related system events registered with the current Node. Node system events includes touch and mouse events. - If recursive is set to true, then this API will pause the node system events for the node and all nodes in its sub node tree. - Reference: http://docs.cocos2d-x.org/editors_and_tools/creator-chapters/scripting/internal-events/ - !#zh æš‚åœå½“å‰èŠ‚ç‚¹ä¸Šæ³¨å†Œçš„æ‰€æœ‰èŠ‚ç‚¹ç³»ç»Ÿäº‹ä»¶ï¼ŒèŠ‚ç‚¹ç³»ç»Ÿäº‹ä»¶åŒ…å«è§¦æ‘¸å’Œé¼ æ ‡äº‹ä»¶ã€‚ - å¦‚æžœä¼ é€’ recursive 为 true,那么这个 API å°†æš‚åœæœ¬èŠ‚ç‚¹å’Œå®ƒçš„åæ ‘上所有节点的节点系统事件。 - å‚考:https://www.cocos.com/docs/creator/scripting/internal-events.html - @param recursive Whether to pause node system events on the sub node tree. - - @example - ```js - node.pauseSystemEvents(true); - ``` + !#en Sets a new texture with a rect. The rect is in texture position and size. + Please use spriteFrame property instead, this function is deprecated since v1.9 + !#zh è®¾ç½®ä¸€å¼ æ–°è´´å›¾å’Œå…³è”的矩形。 + 请直接设置 spriteFrame 属性,这个函数从 v1.9 版本开始已ç»è¢«åºŸå¼ƒ + @param texture texture + @param rect rect */ - pauseSystemEvents(recursive: boolean): void; + setTextureWithRect(texture: Texture2D, rect: Rect): void; + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh æŒ‡å®šåŽŸå›¾çš„æ··åˆæ¨¡å¼ï¼Œè¿™ä¼šå…‹éš†ä¸€ä¸ªæ–°çš„æè´¨å¯¹è±¡ï¼Œæ³¨æ„这带æ¥çš„开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh æŒ‡å®šç›®æ ‡çš„æ··åˆæ¨¡å¼ */ + dstBlendFactor: macro.BlendFactor; + } + /** cc.TMXLayerInfo contains the information about the layers like: + - Layer name + - Layer size + - Layer opacity at creation time (it can be modified at runtime) + - Whether the layer is visible (if it's not visible, then the CocosNode won't be created) + This information is obtained from the TMX file. */ + export class TMXLayerInfo { + /** Properties of the layer info. */ + properties: any; + } + /** cc.TMXImageLayerInfo contains the information about the image layers. + This information is obtained from the TMX file. */ + export class TMXImageLayerInfo { + } + /** <p>cc.TMXObjectGroupInfo contains the information about the object group like: + - group name + - group size + - group opacity at creation time (it can be modified at runtime) + - Whether the group is visible + + This information is obtained from the TMX file.</p> */ + export class TMXObjectGroupInfo { + /** Properties of the ObjectGroup info. */ + properties: any[]; + } + /** <p>cc.TMXTilesetInfo contains the information about the tilesets like: <br /> + - Tileset name<br /> + - Tileset spacing<br /> + - Tileset margin<br /> + - size of the tiles<br /> + - Image used for the tiles<br /> + - Image size<br /> + + This information is obtained from the TMX file. </p> */ + export class TMXTilesetInfo { + /** Tileset name */ + name: string; + /** First grid */ + firstGid: number; + /** Spacing */ + spacing: number; + /** Margin */ + margin: number; + /** Texture containing the tiles (should be sprite sheet / texture atlas) */ + sourceImage: any; + /** Size in pixels of the image */ + imageSize: Size; + } + /** <p>cc.TMXMapInfo contains the information about the map like: <br/> + - Map orientation (hexagonal, isometric or orthogonal)<br/> + - Tile size<br/> + - Map size</p> + + <p>And it also contains: <br/> + - Layers (an array of TMXLayerInfo objects)<br/> + - Tilesets (an array of TMXTilesetInfo objects) <br/> + - ObjectGroups (an array of TMXObjectGroupInfo objects) </p> + + <p>This information is obtained from the TMX file. </p> */ + export class TMXMapInfo { + /** Properties of the map info. */ + properties: any[]; + /** Map orientation. */ + orientation: number; + /** Parent element. */ + parentElement: any; + /** Parent GID. */ + parentGID: number; + /** Layer attributes. */ + layerAttrs: any; + /** Is reading storing characters stream. */ + storingCharacters: boolean; + /** Current string stored from characters stream. */ + currentString: string; + /** Width of the map */ + mapWidth: number; + /** Height of the map */ + mapHeight: number; + /** Width of a tile */ + tileWidth: number; + /** Height of a tile */ + tileHeight: number; + static ATTRIB_NONE: number; + static ATTRIB_BASE64: number; + static ATTRIB_GZIP: number; + static ATTRIB_ZLIB: number; + } + /** !#en Render the TMX layer. + !#zh 渲染 TMX layer。 */ + export class TiledLayer extends Component { /** - !#en Resume node related system events registered with the current Node. Node system events includes touch and mouse events. - If recursive is set to true, then this API will resume the node system events for the node and all nodes in its sub node tree. - Reference: http://docs.cocos2d-x.org/editors_and_tools/creator-chapters/scripting/internal-events/ - !#zh æ¢å¤å½“å‰èŠ‚ç‚¹ä¸Šæ³¨å†Œçš„æ‰€æœ‰èŠ‚ç‚¹ç³»ç»Ÿäº‹ä»¶ï¼ŒèŠ‚ç‚¹ç³»ç»Ÿäº‹ä»¶åŒ…å«è§¦æ‘¸å’Œé¼ æ ‡äº‹ä»¶ã€‚ - å¦‚æžœä¼ é€’ recursive 为 true,那么这个 API å°†æ¢å¤æœ¬èŠ‚ç‚¹å’Œå®ƒçš„åæ ‘上所有节点的节点系统事件。 - å‚考:https://www.cocos.com/docs/creator/scripting/internal-events.html - @param recursive Whether to resume node system events on the sub node tree. - - @example - ```js - node.resumeSystemEvents(true); - ``` + !#en enable or disable culling + !#zh 开坿ˆ–å…³é—è£å‰ªã€‚ + @param value value */ - resumeSystemEvents(recursive: boolean): void; + enableCulling(value: any): void; /** - !#en - Executes an action, and returns the action that is executed.<br/> - The node becomes the action's target. Refer to cc.Action's getTarget() <br/> - Calling runAction while the node is not active won't have any effect. <br/> - Note:You shouldn't modify the action after runAction, that won't take any effect.<br/> - if you want to modify, when you define action plus. - !#zh - æ‰§è¡Œå¹¶è¿”å›žè¯¥æ‰§è¡Œçš„åŠ¨ä½œã€‚è¯¥èŠ‚ç‚¹å°†ä¼šå˜æˆåŠ¨ä½œçš„ç›®æ ‡ã€‚<br/> - 调用 runAction æ—¶ï¼ŒèŠ‚ç‚¹è‡ªèº«å¤„äºŽä¸æ¿€æ´»çжæ€å°†ä¸ä¼šæœ‰ä»»ä½•效果。<br/> - 注æ„ï¼šä½ ä¸åº”该修改 runAction åŽçš„åŠ¨ä½œï¼Œå°†æ— æ³•å‘æŒ¥ä½œç”¨ï¼Œå¦‚果想进行修改,请在定义 action æ—¶åŠ å…¥ã€‚ - @param action action - - @example - ```js - var action = cc.scaleTo(0.2, 1, 0.6); - node.runAction(action); - node.runAction(action).repeatForever(); // fail - node.runAction(action.repeatForever()); // right - ``` + !#en Adds user's node into layer. + !#zh æ·»åŠ ç”¨æˆ·èŠ‚ç‚¹ã€‚ + @param node node */ - runAction(action: Action): Action; + addUserNode(node: Node): boolean; /** - !#en Pause all actions running on the current node. Equals to `cc.director.getActionManager().pauseTarget(node)`. - !#zh æš‚åœæœ¬èŠ‚ç‚¹ä¸Šæ‰€æœ‰æ£åœ¨è¿è¡Œçš„动作。和 `cc.director.getActionManager().pauseTarget(node);` ç‰ä»·ã€‚ - - @example - ```js - node.pauseAllActions(); - ``` + !#en Removes user's node. + !#zh 移除用户节点。 + @param node node */ - pauseAllActions(): void; + removeUserNode(node: Node): boolean; /** - !#en Resume all paused actions on the current node. Equals to `cc.director.getActionManager().resumeTarget(node)`. - !#zh æ¢å¤è¿è¡Œæœ¬èŠ‚ç‚¹ä¸Šæ‰€æœ‰æš‚åœçš„动作。和 `cc.director.getActionManager().resumeTarget(node);` ç‰ä»·ã€‚ - - @example - ```js - node.resumeAllActions(); - ``` + !#en Destroy user's node. + !#zh 销æ¯ç”¨æˆ·èŠ‚ç‚¹ã€‚ + @param node node */ - resumeAllActions(): void; + destroyUserNode(node: Node): void; /** - !#en Stops and removes all actions from the running action list . - !#zh åœæ¢å¹¶ä¸”移除所有æ£åœ¨è¿è¡Œçš„动作列表。 + !#en Gets the layer name. + !#zh 获å–层的å称。 @example ```js - node.stopAllActions(); + let layerName = tiledLayer.getLayerName(); + cc.log(layerName); ``` */ - stopAllActions(): void; + getLayerName(): string; /** - !#en Stops and removes an action from the running action list. - !#zh åœæ¢å¹¶ç§»é™¤æŒ‡å®šçš„动作。 - @param action An action object to be removed. + !#en Set the layer name. + !#zh 设置层的åç§° + @param layerName layerName @example ```js - var action = cc.scaleTo(0.2, 1, 0.6); - node.stopAction(action); + tiledLayer.setLayerName("New Layer"); ``` */ - stopAction(action: Action): void; + SetLayerName(layerName: string): void; /** - !#en Removes an action from the running action list by its tag. - !#zh åœæ¢å¹¶ä¸”ç§»é™¤æŒ‡å®šæ ‡ç¾çš„动作。 - @param tag A tag that indicates the action to be removed. + !#en Return the value for the specific property name. + !#zh èŽ·å–æŒ‡å®šå±žæ€§å的值。 + @param propertyName propertyName @example ```js - node.stopActionByTag(1); + let property = tiledLayer.getProperty("info"); + cc.log(property); ``` */ - stopActionByTag(tag: number): void; + getProperty(propertyName: string): any; /** - !#en Returns an action from the running action list by its tag. - !#zh é€šè¿‡æ ‡ç¾èŽ·å–æŒ‡å®šåŠ¨ä½œã€‚ - @param tag tag + !#en Returns the position in pixels of a given tile coordinate. + !#zh èŽ·å–æŒ‡å®š tile çš„åƒç´ åæ ‡ã€‚ + @param pos position or x + @param y y @example ```js - var action = node.getActionByTag(1); + let pos = tiledLayer.getPositionAt(cc.v2(0, 0)); + cc.log("Pos: " + pos); + let pos = tiledLayer.getPositionAt(0, 0); + cc.log("Pos: " + pos); ``` */ - getActionByTag(tag: number): Action; + getPositionAt(pos: Vec2|number, y?: number): Vec2; /** !#en - Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).<br/> - Composable actions are counted as 1 action. Example:<br/> - If you are running 1 Sequence of 7 actions, it will return 1. <br/> - If you are running 7 Sequences of 2 actions, it will return 7.</p> + Sets the tiles gid (gid = tile global id) at a given tiles rect. !#zh - 获å–è¿è¡Œç€çš„åŠ¨ä½œåŠ ä¸Šæ£åœ¨è°ƒåº¦è¿è¡Œçš„动作的总数。<br/> - 例如:<br/> - - å¦‚æžœä½ æ£åœ¨è¿è¡Œ 7 个动作ä¸çš„ 1 个 Sequence,它将返回 1。<br/> - - å¦‚æžœä½ æ£åœ¨è¿è¡Œ 2 个动作ä¸çš„ 7 个 Sequence,它将返回 7。<br/> + 设置给定区域的 tile çš„ gid (gid = tile 全局 id), + @param gids an array contains gid + @param beginCol begin col number + @param beginRow begin row number + @param totalCols count of column @example ```js - var count = node.getNumberOfRunningActions(); - cc.log("Running Action Count: " + count); + tiledLayer.setTilesGIDAt([1, 1, 1, 1], 10, 10, 2) ``` */ - getNumberOfRunningActions(): number; + setTilesGIDAt(gids: any[], beginCol: number, beginRow: number, totalCols: number): void; /** !#en - Returns a copy of the position (x, y, z) of the node in its parent's coordinates. - You can pass a cc.Vec2 or cc.Vec3 as the argument to receive the return values. + Sets the tile gid (gid = tile global id) at a given tile coordinate.<br /> + The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor . Tileset Mgr +1.<br /> + If a tile is already placed at that position, then it will be removed. !#zh - 获å–èŠ‚ç‚¹åœ¨çˆ¶èŠ‚ç‚¹åæ ‡ç³»ä¸çš„ä½ç½®ï¼ˆx, y, z)。 - ä½ å¯ä»¥ä¼ 一个 cc.Vec2 或者 cc.Vec3 ä½œä¸ºå‚æ•°æ¥æŽ¥æ”¶è¿”回值。 - @param out The return value to receive position + è®¾ç½®ç»™å®šåæ ‡çš„ tile çš„ gid (gid = tile 全局 id), + tile çš„ GID å¯ä»¥ä½¿ç”¨æ–¹æ³• “tileGIDAt†æ¥èŽ·å¾—ã€‚<br /> + 如果一个 tile å·²ç»æ”¾åœ¨é‚£ä¸ªä½ç½®ï¼Œé‚£ä¹ˆå®ƒå°†è¢«åˆ 除。 + @param gid gid + @param posOrX position or x + @param flagsOrY flags or y + @param flags flags @example ```js - cc.log("Node Position: " + node.getPosition()); + tiledLayer.setTileGIDAt(1001, 10, 10, 1) ``` */ - getPosition(out?: Vec2|Vec3): Vec2; + setTileGIDAt(gid: number, posOrX: Vec2|number, flagsOrY: number, flags?: number): void; /** !#en - Sets the position (x, y, z) of the node in its parent's coordinates.<br/> - Usually we use cc.v2(x, y) to compose cc.Vec2 object,<br/> - and passing two numbers (x, y) is more efficient than passing cc.Vec2 object. - For 3D node we can use cc.v3(x, y, z) to compose cc.Vec3 object,<br/> - and passing three numbers (x, y, z) is more efficient than passing cc.Vec3 object. + Returns the tiles data.An array fill with GIDs. <br /> !#zh - è®¾ç½®èŠ‚ç‚¹åœ¨çˆ¶èŠ‚ç‚¹åæ ‡ç³»ä¸çš„ä½ç½®ã€‚<br/> - å¯ä»¥é€šè¿‡ä¸‹é¢çš„æ–¹å¼è®¾ç½®åæ ‡ç‚¹ï¼š<br/> - 1. ä¼ å…¥ 2 个数值 x, y。<br/> - 2. ä¼ å…¥ cc.v2(x, y) 类型为 cc.Vec2 的对象。 - 3. 对于 3D 节点å¯ä»¥ä¼ å…¥ 3 个数值 x, y, z。<br/> - 4. 对于 3D 节点å¯ä»¥ä¼ å…¥ cc.v3(x, y, z) 类型为 cc.Vec3 的对象。 - @param newPosOrX X coordinate for position or the position (x, y, z) of the node in coordinates - @param y Y coordinate for position - @param z Z coordinate for position - */ - setPosition(newPosOrX: Vec2|Vec3|number, y?: number, z?: number): void; - /** - !#en - Returns the scale factor of the node. - Need pass a cc.Vec2 or cc.Vec3 as the argument to receive the return values. - !#zh 获å–节点的缩放,需è¦ä¼ 一个 cc.Vec2 或者 cc.Vec3 ä½œä¸ºå‚æ•°æ¥æŽ¥æ”¶è¿”回值。 - @param out out - - @example - ```js - cc.log("Node Scale: " + node.getScale(cc.v3())); - ``` + 返回 tiles æ•°æ®. ç”±GIDæž„æˆçš„一个数组. <br /> */ - getScale(out: Vec2|Vec3): Vec2; + getTiles(): number[]; /** !#en - Sets the scale of axis in local coordinates of the node. - You can operate 2 axis in 2D node, and 3 axis in 3D node. + Returns the tile gid at a given tile coordinate. <br /> + if it returns 0, it means that the tile is empty. <br /> !#zh - è®¾ç½®èŠ‚ç‚¹åœ¨æœ¬åœ°åæ ‡ç³»ä¸åæ ‡è½´ä¸Šçš„ç¼©æ”¾æ¯”ä¾‹ã€‚ - 2D 节点å¯ä»¥æ“ä½œä¸¤ä¸ªåæ ‡è½´ï¼Œè€Œ 3D 节点å¯ä»¥æ“ä½œä¸‰ä¸ªåæ ‡è½´ã€‚ - @param x scaleX or scale object + 通过给定的 tile åæ ‡ã€flags(å¯é€‰ï¼‰è¿”回 tile çš„ GID. <br /> + 如果它返回 0,则表示该 tile 为空。<br /> + @param pos or x @param y y - @param z z - - @example - ```js - node.setScale(cc.v2(2, 2)); - node.setScale(cc.v3(2, 2, 2)); // for 3D node - node.setScale(2); - ``` - */ - setScale(x: number|Vec2|Vec3, y?: number, z?: number): void; - /** - !#en - Get rotation of node (in quaternion). - Need pass a cc.Quat as the argument to receive the return values. - !#zh - 获å–该节点的 quaternion 旋转角度,需è¦ä¼ 一个 cc.Quat ä½œä¸ºå‚æ•°æ¥æŽ¥æ”¶è¿”回值。 - @param out out - */ - getRotation(out: Quat): Quat; - /** - !#en Set rotation of node (in quaternion). - !#zh 设置该节点的 quaternion 旋转角度。 - @param quat Quaternion object represents the rotation or the x value of quaternion - @param y y value of quternion - @param z z value of quternion - @param w w value of quternion - */ - setRotation(quat: Quat|number, y?: number, z?: number, w?: number): void; - /** - !#en - Returns a copy the untransformed size of the node. <br/> - The contentSize remains the same no matter the node is scaled or rotated.<br/> - All nodes has a size. Layer and Scene has the same size of the screen by default. <br/> - !#zh 获å–节点自身大å°ï¼Œä¸å—该节点是å¦è¢«ç¼©æ”¾æˆ–者旋转的影å“。 - - @example - ```js - cc.log("Content Size: " + node.getContentSize()); - ``` - */ - getContentSize(): Size; - /** - !#en - Sets the untransformed size of the node.<br/> - The contentSize remains the same no matter the node is scaled or rotated.<br/> - All nodes has a size. Layer and Scene has the same size of the screen. - !#zh 设置节点原始大å°ï¼Œä¸å—该节点是å¦è¢«ç¼©æ”¾æˆ–者旋转的影å“。 - @param size The untransformed size of the node or The untransformed size's width of the node. - @param height The untransformed size's height of the node. @example ```js - node.setContentSize(cc.size(100, 100)); - node.setContentSize(100, 100); + let tileGid = tiledLayer.getTileGIDAt(0, 0); ``` */ - setContentSize(size: Size|number, height?: number): void; + getTileGIDAt(pos: Vec2|number, y?: number): number; /** - !#en - Returns a copy of the anchor point.<br/> - Anchor point is the point around which all transformations and positioning manipulations take place.<br/> - It's like a pin in the node where it is "attached" to its parent. <br/> - The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner. <br/> - But you can use values higher than (1,1) and lower than (0,0) too. <br/> - The default anchor point is (0.5,0.5), so it starts at the center of the node. - !#zh - 获å–节点锚点,用百分比表示。<br/> - é”šç‚¹åº”ç”¨äºŽæ‰€æœ‰å˜æ¢å’Œåæ ‡ç‚¹çš„æ“作,它就åƒåœ¨èŠ‚ç‚¹ä¸Šè¿žæŽ¥å…¶çˆ¶èŠ‚ç‚¹çš„å¤§å¤´é’ˆã€‚<br/> - é”šç‚¹æ˜¯æ ‡å‡†åŒ–çš„ï¼Œå°±åƒç™¾åˆ†æ¯”ä¸€æ ·ã€‚(0,0) 表示左下角,(1,1) 表示å³ä¸Šè§’。<br/> - ä½†æ˜¯ä½ å¯ä»¥ä½¿ç”¨æ¯”(1,1)更高的值或者比(0,0)更低的值。<br/> - 默认的锚点是(0.5,0.5ï¼‰ï¼Œå› æ¤å®ƒå¼€å§‹äºŽèŠ‚ç‚¹çš„ä¸å¿ƒä½ç½®ã€‚<br/> - 注æ„:Creator ä¸çš„é”šç‚¹ä»…ç”¨äºŽå®šä½æ‰€åœ¨çš„节点,å节点的定ä½ä¸å—å½±å“。 + !#en Layer orientation, which is the same as the map orientation. + !#zh èŽ·å– Layer æ–¹å‘(åŒåœ°å›¾æ–¹å‘)。 @example ```js - cc.log("Node AnchorPoint: " + node.getAnchorPoint()); + let orientation = tiledLayer.getLayerOrientation(); + cc.log("Layer Orientation: " + orientation); ``` */ - getAnchorPoint(): Vec2; - /** - !#en - Sets the anchor point in percent. <br/> - anchor point is the point around which all transformations and positioning manipulations take place. <br/> - It's like a pin in the node where it is "attached" to its parent. <br/> - The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.<br/> - But you can use values higher than (1,1) and lower than (0,0) too.<br/> - The default anchor point is (0.5,0.5), so it starts at the center of the node. - !#zh - 设置锚点的百分比。<br/> - é”šç‚¹åº”ç”¨äºŽæ‰€æœ‰å˜æ¢å’Œåæ ‡ç‚¹çš„æ“作,它就åƒåœ¨èŠ‚ç‚¹ä¸Šè¿žæŽ¥å…¶çˆ¶èŠ‚ç‚¹çš„å¤§å¤´é’ˆã€‚<br/> - é”šç‚¹æ˜¯æ ‡å‡†åŒ–çš„ï¼Œå°±åƒç™¾åˆ†æ¯”ä¸€æ ·ã€‚(0,0) 表示左下角,(1,1) 表示å³ä¸Šè§’。<br/> - ä½†æ˜¯ä½ å¯ä»¥ä½¿ç”¨æ¯”(1,1)更高的值或者比(0,0)更低的值。<br/> - 默认的锚点是(0.5,0.5ï¼‰ï¼Œå› æ¤å®ƒå¼€å§‹äºŽèŠ‚ç‚¹çš„ä¸å¿ƒä½ç½®ã€‚<br/> - 注æ„:Creator ä¸çš„é”šç‚¹ä»…ç”¨äºŽå®šä½æ‰€åœ¨çš„节点,å节点的定ä½ä¸å—å½±å“。 - @param point The anchor point of node or The x axis anchor of node. - @param y The y axis anchor of node. + getLayerOrientation(): number; + /** + !#en properties from the layer. They can be added using Tiled. + !#zh èŽ·å– layer 的属性,å¯ä»¥ä½¿ç”¨ Tiled ç¼–è¾‘å™¨æ·»åŠ å±žæ€§ã€‚ @example ```js - node.setAnchorPoint(cc.v2(1, 1)); - node.setAnchorPoint(1, 1); + let properties = tiledLayer.getProperties(); + cc.log("Properties: " + properties); ``` */ - setAnchorPoint(point: Vec2|number, y?: number): void; - /** - !#en Set rotation by lookAt target point, normally used by Camera Node - !#zh é€šè¿‡è§‚å¯Ÿç›®æ ‡æ¥è®¾ç½® rotation,一般用于 Camera Node 上 - @param pos pos - @param up default is (0,1,0) - */ - lookAt(pos: Vec3, up?: Vec3): void; + getProperties(): any; /** !#en - Get the local transform matrix (4x4), based on parent node coordinates - !#zh è¿”å›žå±€éƒ¨ç©ºé—´åæ ‡ç³»çš„çŸ©é˜µï¼ŒåŸºäºŽçˆ¶èŠ‚ç‚¹åæ ‡ç³»ã€‚ - @param out The matrix object to be filled with data + Get the TiledTile with the tile coordinate.<br/> + If there is no tile in the specified coordinate and forceCreate parameter is true, <br/> + then will create a new TiledTile at the coordinate. + The renderer will render the tile with the rotation, scale, position and color property of the TiledTile. + !#zh + 通过指定的 tile åæ ‡èŽ·å–对应的 TiledTile。 <br/> + å¦‚æžœæŒ‡å®šçš„åæ ‡æ²¡æœ‰ tile,并且设置了 forceCreate é‚£ä¹ˆå°†ä¼šåœ¨æŒ‡å®šçš„åæ ‡åˆ›å»ºä¸€ä¸ªæ–°çš„ TiledTile 。<br/> + 在渲染这个 tile 的时候,将会使用 TiledTile 的节点的旋转ã€ç¼©æ”¾ã€ä½ç§»ã€é¢œè‰²å±žæ€§ã€‚<br/> + @param x x + @param y y + @param forceCreate forceCreate @example ```js - let mat4 = cc.mat4(); - node.getLocalMatrix(mat4); + let tile = tiledLayer.getTiledTileAt(100, 100, true); + cc.log(tile); ``` */ - getLocalMatrix(out: Mat4): Mat4; + getTiledTileAt(x: number, y: number, forceCreate: boolean): TiledTile; /** !#en - Get the world transform matrix (4x4) - !#zh è¿”å›žä¸–ç•Œç©ºé—´åæ ‡ç³»çš„矩阵。 - @param out The matrix object to be filled with data + Change tile to TiledTile at the specified coordinate. + !#zh + 将指定的 tile åæ ‡æ›¿æ¢ä¸ºæŒ‡å®šçš„ TiledTile。 + @param x x + @param y y + @param tiledTile tiledTile + */ + setTiledTileAt(x: number, y: number, tiledTile: TiledTile): TiledTile; + /** + !#en Return texture. + !#zh 获å–纹ç†ã€‚ + @param index The index of textures + */ + getTexture(index: any): Texture2D; + /** + !#en Return texture. + !#zh 获å–纹ç†ã€‚ + */ + getTextures(): Texture2D; + /** + !#en Set the texture. + !#zh 设置纹ç†ã€‚ + @param texture texture + */ + setTexture(texture: Texture2D): void; + /** + !#en Set the texture. + !#zh 设置纹ç†ã€‚ + @param textures textures + */ + setTexture(textures: Texture2D): void; + /** + !#en Gets layer size. + !#zh 获得层大å°ã€‚ @example ```js - let mat4 = cc.mat4(); - node.getWorldMatrix(mat4); + let size = tiledLayer.getLayerSize(); + cc.log("layer size: " + size); ``` */ - getWorldMatrix(out: Mat4): Mat4; + getLayerSize(): Size; /** - !#en - Converts a Point to node (local) space coordinates. - !#zh - 将一个点转æ¢åˆ°èŠ‚ç‚¹ (局部) ç©ºé—´åæ ‡ç³»ã€‚ - @param worldPoint worldPoint - @param out out + !#en Size of the map's tile (could be different from the tile's size). + !#zh èŽ·å– tile 的大å°( tile 的大å°å¯èƒ½ä¼šæœ‰æ‰€ä¸åŒ)。 @example ```js - var newVec2 = node.convertToNodeSpaceAR(cc.v2(100, 100)); - var newVec3 = node.convertToNodeSpaceAR(cc.v3(100, 100, 100)); + let mapTileSize = tiledLayer.getMapTileSize(); + cc.log("MapTile size: " + mapTileSize); ``` */ - convertToNodeSpaceAR<T extends cc.Vec2 | cc.Vec3>(worldPoint: T, out?: T): T; + getMapTileSize(): Size; /** - !#en - Converts a Point in node coordinates to world space coordinates. - !#zh - å°†èŠ‚ç‚¹åæ ‡ç³»ä¸‹çš„一个点转æ¢åˆ°ä¸–ç•Œç©ºé—´åæ ‡ç³»ã€‚ - @param nodePoint nodePoint - @param out out + !#en Gets Tile set first information for the layer. + !#zh èŽ·å– layer 索引ä½ç½®ä¸º0çš„ Tileset ä¿¡æ¯ã€‚ + @param index The index of tilesets + */ + getTileSet(index: any): TMXTilesetInfo; + /** + !#en Gets tile set all information for the layer. + !#zh èŽ·å– layer 所有的 Tileset ä¿¡æ¯ã€‚ + */ + getTileSet(): TMXTilesetInfo; + /** + !#en Sets tile set information for the layer. + !#zh 设置 layer çš„ tileset ä¿¡æ¯ã€‚ + @param tileset tileset + */ + setTileSet(tileset: TMXTilesetInfo): void; + /** + !#en Sets Tile set information for the layer. + !#zh 设置 layer çš„ Tileset ä¿¡æ¯ã€‚ + @param tilesets tilesets + */ + setTileSets(tilesets: TMXTilesetInfo): void; + } + /** !#en Renders a TMX Tile Map in the scene. + !#zh åœ¨åœºæ™¯ä¸æ¸²æŸ“一个 tmx æ ¼å¼çš„ Tile Map。 */ + export class TiledMap extends Component { + /** !#en The TiledMap Asset. + !#zh TiledMap 资æºã€‚ */ + tmxAsset: TiledMapAsset; + /** + !#en Gets the map size. + !#zh 获å–地图大å°ã€‚ @example ```js - var newVec2 = node.convertToWorldSpaceAR(cc.v2(100, 100)); - var newVec3 = node.convertToWorldSpaceAR(cc.v3(100, 100, 100)); + let mapSize = tiledMap.getMapSize(); + cc.log("Map Size: " + mapSize); ``` */ - convertToWorldSpaceAR<T extends cc.Vec2 | cc.Vec3>(nodePoint: T, out?: T): T; + getMapSize(): Size; /** - !#en Converts a Point to node (local) space coordinates then add the anchor point position. - So the return position will be related to the left bottom corner of the node's bounding box. - This equals to the API behavior of cocos2d-x, you probably want to use convertToNodeSpaceAR instead - !#zh 将一个点转æ¢åˆ°èŠ‚ç‚¹ (局部) åæ ‡ç³»ï¼Œå¹¶åŠ ä¸Šé”šç‚¹çš„åæ ‡ã€‚<br/> - ä¹Ÿå°±æ˜¯è¯´è¿”å›žçš„åæ ‡æ˜¯ç›¸å¯¹äºŽèŠ‚ç‚¹åŒ…å›´ç›’å·¦ä¸‹è§’çš„åæ ‡ã€‚<br/> - 这个 API 的设计是为了和 cocos2d-x ä¸è¡Œä¸ºä¸€è‡´ï¼Œæ›´å¤šæƒ…å†µä¸‹ä½ å¯èƒ½éœ€è¦ä½¿ç”¨ convertToNodeSpaceAR。 - @param worldPoint worldPoint + !#en Gets the tile size. + !#zh 获å–åœ°å›¾èƒŒæ™¯ä¸ tile å…ƒç´ çš„å¤§å°ã€‚ @example ```js - var newVec2 = node.convertToNodeSpace(cc.v2(100, 100)); + let tileSize = tiledMap.getTileSize(); + cc.log("Tile Size: " + tileSize); ``` */ - convertToNodeSpace(worldPoint: Vec2): Vec2; + getTileSize(): Size; /** - !#en Converts a Point related to the left bottom corner of the node's bounding box to world space coordinates. - This equals to the API behavior of cocos2d-x, you probably want to use convertToWorldSpaceAR instead - !#zh å°†ä¸€ä¸ªç›¸å¯¹äºŽèŠ‚ç‚¹å·¦ä¸‹è§’çš„åæ ‡ä½ç½®è½¬æ¢åˆ°ä¸–ç•Œç©ºé—´åæ ‡ç³»ã€‚ - 这个 API 的设计是为了和 cocos2d-x ä¸è¡Œä¸ºä¸€è‡´ï¼Œæ›´å¤šæƒ…å†µä¸‹ä½ å¯èƒ½éœ€è¦ä½¿ç”¨ convertToWorldSpaceAR - @param nodePoint nodePoint + !#en map orientation. + !#zh 获å–地图方å‘。 @example ```js - var newVec2 = node.convertToWorldSpace(cc.v2(100, 100)); + let mapOrientation = tiledMap.getMapOrientation(); + cc.log("Map Orientation: " + mapOrientation); ``` */ - convertToWorldSpace(nodePoint: Vec2): Vec2; + getMapOrientation(): number; /** - !#en - Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.<br/> - The matrix is in Pixels. - !#zh è¿”å›žè¿™ä¸ªå°†èŠ‚ç‚¹ï¼ˆå±€éƒ¨ï¼‰çš„ç©ºé—´åæ ‡ç³»è½¬æ¢æˆçˆ¶èŠ‚ç‚¹çš„ç©ºé—´åæ ‡ç³»çš„矩阵。这个矩阵以åƒç´ 为å•ä½ã€‚ - @param out The affine transform object to be filled with data + !#en object groups. + !#zh èŽ·å–æ‰€æœ‰çš„对象层。 @example ```js - let affineTransform = cc.AffineTransform.create(); - node.getNodeToParentTransform(affineTransform); + let objGroups = titledMap.getObjectGroups(); + for (let i = 0; i < objGroups.length; ++i) { + cc.log("obj: " + objGroups[i]); + } ``` */ - getNodeToParentTransform(out?: AffineTransform): AffineTransform; + getObjectGroups(): TiledObjectGroup[]; /** - !#en - Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.<br/> - The matrix is in Pixels.<br/> - This method is AR (Anchor Relative). - !#zh - è¿”å›žè¿™ä¸ªå°†èŠ‚ç‚¹ï¼ˆå±€éƒ¨ï¼‰çš„ç©ºé—´åæ ‡ç³»è½¬æ¢æˆçˆ¶èŠ‚ç‚¹çš„ç©ºé—´åæ ‡ç³»çš„矩阵。<br/> - 这个矩阵以åƒç´ 为å•ä½ã€‚<br/> - è¯¥æ–¹æ³•åŸºäºŽèŠ‚ç‚¹åæ ‡ã€‚ - @param out The affine transform object to be filled with data + !#en Return the TMXObjectGroup for the specific group. + !#zh èŽ·å–æŒ‡å®šçš„ TMXObjectGroup。 + @param groupName groupName @example ```js - let affineTransform = cc.AffineTransform.create(); - node.getNodeToParentTransformAR(affineTransform); + let group = titledMap.getObjectGroup("Players"); + cc.log("ObjectGroup: " + group); ``` */ - getNodeToParentTransformAR(out?: AffineTransform): AffineTransform; + getObjectGroup(groupName: string): TiledObjectGroup; /** - !#en Returns the world affine transform matrix. The matrix is in Pixels. - !#zh è¿”å›žèŠ‚ç‚¹åˆ°ä¸–ç•Œåæ ‡ç³»çš„ä»¿å°„å˜æ¢çŸ©é˜µã€‚矩阵å•使˜¯åƒç´ 。 - @param out The affine transform object to be filled with data + !#en enable or disable culling + !#zh 开坿ˆ–å…³é—è£å‰ªã€‚ + @param value value + */ + enableCulling(value: any): void; + /** + !#en Gets the map properties. + !#zh 获å–地图的属性。 @example ```js - let affineTransform = cc.AffineTransform.create(); - node.getNodeToWorldTransform(affineTransform); + let properties = titledMap.getProperties(); + for (let i = 0; i < properties.length; ++i) { + cc.log("Properties: " + properties[i]); + } ``` */ - getNodeToWorldTransform(out?: AffineTransform): AffineTransform; + getProperties(): any[]; /** - !#en - Returns the world affine transform matrix. The matrix is in Pixels.<br/> - This method is AR (Anchor Relative). - !#zh - è¿”å›žèŠ‚ç‚¹åˆ°ä¸–ç•Œåæ ‡ä»¿å°„å˜æ¢çŸ©é˜µã€‚矩阵å•使˜¯åƒç´ 。<br/> - è¯¥æ–¹æ³•åŸºäºŽèŠ‚ç‚¹åæ ‡ã€‚ - @param out The affine transform object to be filled with data + !#en Return All layers array. + !#zh è¿”å›žåŒ…å«æ‰€æœ‰ layer 的数组。 @example ```js - let affineTransform = cc.AffineTransform.create(); - node.getNodeToWorldTransformAR(affineTransform); + let layers = titledMap.getLayers(); + for (let i = 0; i < layers.length; ++i) { + cc.log("Layers: " + layers[i]); + } ``` */ - getNodeToWorldTransformAR(out?: AffineTransform): AffineTransform; + getLayers(): TiledLayer[]; /** - !#en - Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.<br/> - The matrix is in Pixels. The returned transform is readonly and cannot be changed. - !#zh - è¿”å›žå°†çˆ¶èŠ‚ç‚¹çš„åæ ‡ç³»è½¬æ¢æˆèŠ‚ç‚¹ï¼ˆå±€éƒ¨ï¼‰çš„ç©ºé—´åæ ‡ç³»çš„矩阵。<br/> - 该矩阵以åƒç´ 为å•ä½ã€‚返回的矩阵是åªè¯»çš„,ä¸èƒ½æ›´æ”¹ã€‚ - @param out The affine transform object to be filled with data + !#en return the cc.TiledLayer for the specific layer. + !#zh èŽ·å–æŒ‡å®šåç§°çš„ layer。 + @param layerName layerName @example ```js - let affineTransform = cc.AffineTransform.create(); - node.getParentToNodeTransform(affineTransform); + let layer = titledMap.getLayer("Player"); + cc.log(layer); ``` */ - getParentToNodeTransform(out?: AffineTransform): AffineTransform; + getLayer(layerName: string): TiledLayer; /** - !#en Returns the inverse world affine transform matrix. The matrix is in Pixels. - !#en è¿”å›žä¸–ç•Œåæ ‡ç³»åˆ°èŠ‚ç‚¹åæ ‡ç³»çš„逆矩阵。 - @param out The affine transform object to be filled with data + !#en Return the value for the specific property name. + !#zh 通过属性åç§°ï¼ŒèŽ·å–æŒ‡å®šçš„属性。 + @param propertyName propertyName @example ```js - let affineTransform = cc.AffineTransform.create(); - node.getWorldToNodeTransform(affineTransform); + let property = titledMap.getProperty("info"); + cc.log("Property: " + property); ``` */ - getWorldToNodeTransform(out?: AffineTransform): AffineTransform; + getProperty(propertyName: string): string; /** - !#en convenience methods which take a cc.Touch instead of cc.Vec2. - !#zh å°†è§¦æ‘¸ç‚¹è½¬æ¢æˆæœ¬åœ°åæ ‡ç³»ä¸ä½ç½®ã€‚ - @param touch The touch object + !#en Return properties dictionary for tile GID. + !#zh 通过 GID ï¼ŒèŽ·å–æŒ‡å®šçš„属性。 + @param GID GID @example ```js - var newVec2 = node.convertTouchToNodeSpace(touch); + let properties = titledMap.getPropertiesForGID(GID); + cc.log("Properties: " + properties); ``` */ - convertTouchToNodeSpace(touch: Touch): Vec2; + getPropertiesForGID(GID: number): any; + } + /** Class for tiled map asset handling. */ + export class TiledMapAsset extends Asset { + textures: Texture2D[]; + textureNames: string[]; + textureSizes: Size[]; + imageLayerTextures: Texture2D[]; + imageLayerTextureNames: string[]; + } + /** !#en Renders the TMX object group. + !#zh 渲染 tmx object group。 */ + export class TiledObjectGroup extends Component { /** - !#en converts a cc.Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative). - !#zh 转æ¢ä¸€ä¸ª cc.Touchï¼ˆä¸–ç•Œåæ ‡ï¼‰åˆ°ä¸€ä¸ªå±€éƒ¨åæ ‡ï¼Œè¯¥æ–¹æ³•åŸºäºŽèŠ‚ç‚¹åæ ‡ã€‚ - @param touch The touch object + !#en Offset position of child objects. + !#zh 获å–å对象的åç§»ä½ç½®ã€‚ @example ```js - var newVec2 = node.convertTouchToNodeSpaceAR(touch); + let offset = tMXObjectGroup.getPositionOffset(); ``` */ - convertTouchToNodeSpaceAR(touch: Touch): Vec2; + getPositionOffset(): Vec2; /** - !#en - Returns a "local" axis aligned bounding box of the node. <br/> - The returned box is relative only to its parent. - !#zh è¿”å›žçˆ¶èŠ‚åæ ‡ç³»ä¸‹çš„è½´å‘对é½çš„包围盒。 + !#en List of properties stored in a dictionary. + !#zh ä»¥æ˜ å°„çš„å½¢å¼èŽ·å–属性列表。 @example ```js - var boundingBox = node.getBoundingBox(); + let offset = tMXObjectGroup.getProperties(); ``` */ - getBoundingBox(): Rect; + getProperties(): any; /** - !#en - Returns a "world" axis aligned bounding box of the node.<br/> - The bounding box contains self and active children's world bounding box. - !#zh - è¿”å›žèŠ‚ç‚¹åœ¨ä¸–ç•Œåæ ‡ç³»ä¸‹çš„对é½è½´å‘的包围盒(AABB)。<br/> - 该边框包å«è‡ªèº«å’Œå·²æ¿€æ´»çš„å节点的世界边框。 + !#en Gets the Group name. + !#zh 获å–组å称。 @example ```js - var newRect = node.getBoundingBoxToWorld(); + let groupName = tMXObjectGroup.getGroupName; ``` */ - getBoundingBoxToWorld(): Rect; + getGroupName(): string; /** !#en - Adds a child to the node with z order and name. - !#zh - æ·»åŠ å节点,并且å¯ä»¥ä¿®æ”¹è¯¥èŠ‚ç‚¹çš„ 局部 Z 顺åºå’Œåå—。 - @param child A child node - @param zIndex Z order for drawing priority. Please refer to zIndex property - @param name A name to identify the node easily. Please refer to name property + Return the object for the specific object name. <br /> + It will return the 1st object found on the array for the given name. + !#zh èŽ·å–æŒ‡å®šçš„对象。 + @param objectName objectName @example ```js - node.addChild(newNode, 1, "node"); + let object = tMXObjectGroup.getObject("Group"); ``` */ - addChild(child: Node, zIndex?: number, name?: string): void; + getObject(objectName: string): any; /** - !#en Stops all running actions and schedulers. - !#zh åœæ¢æ‰€æœ‰æ£åœ¨æ’放的动作和计时器。 + !#en Gets the objects. + !#zh 获å–对象数组。 @example ```js - node.cleanup(); + let objects = tMXObjectGroup.getObjects(); ``` */ - cleanup(): void; - /** - !#en Sorts the children array depends on children's zIndex and arrivalOrder, - normally you won't need to invoke this function. - !#zh æ ¹æ®å节点的 zIndex å’Œ arrivalOrder 进行排åºï¼Œæ£å¸¸æƒ…况下开å‘者ä¸éœ€è¦æ‰‹åŠ¨è°ƒç”¨è¿™ä¸ªå‡½æ•°ã€‚ - */ - sortAllChildren(): void; + getObjects(): any[]; + } + /** !#en TiledTile can control the specified map tile. + It will apply the node rotation, scale, translate to the map tile. + You can change the TiledTile's gid to change the map tile's style. + !#zh TiledTile å¯ä»¥å•独对æŸä¸€ä¸ªåœ°å›¾å—进行æ“作。 + 他会将节点的旋转,缩放,平移æ“作应用在这个地图å—上,并å¯ä»¥é€šè¿‡æ›´æ¢å½“å‰åœ°å›¾å—çš„ gid æ¥æ›´æ¢åœ°å›¾å—çš„æ˜¾ç¤ºæ ·å¼ã€‚ */ + export class TiledTile extends Component { + /** !#en Specify the TiledTile horizontal coordinate,use map tile as the unit. + !#zh 指定 TiledTile 的横å‘åæ ‡ï¼Œä»¥åœ°å›¾å—为å•ä½ */ + x: number; + /** !#en Specify the TiledTile vertical coordinate,use map tile as the unit. + !#zh 指定 TiledTile 的纵å‘åæ ‡ï¼Œä»¥åœ°å›¾å—为å•ä½ */ + y: number; + /** !#en Specify the TiledTile gid. + !#zh 指定 TiledTile çš„ gid 值 */ + gid: number; + } + /** !#en cc.WebView is a component for display web pages in the game. Because different platforms have different authorization, API and control methods for WebView component. And have not yet formed a unified standard, only Web, iOS, and Android platforms are currently supported. + !#zh WebView 组件,用于在游æˆä¸æ˜¾ç¤ºç½‘页。由于ä¸åŒå¹³å°å¯¹äºŽ WebView 组件的授æƒã€APIã€æŽ§åˆ¶æ–¹å¼éƒ½ä¸åŒï¼Œè¿˜æ²¡æœ‰å½¢æˆç»Ÿä¸€çš„æ ‡å‡†ï¼Œæ‰€ä»¥ç›®å‰åªæ”¯æŒ Webã€iOS å’Œ Android å¹³å°ã€‚ */ + export class WebView extends Component { + /** !#en A given URL to be loaded by the WebView, it should have a http or https prefix. + !#zh 指定 WebView åŠ è½½çš„ç½‘å€ï¼Œå®ƒåº”该是一个 http 或者 https 开头的å—符串 */ + url: string; + /** !#en The webview's event callback , it will be triggered when certain webview event occurs. + !#zh WebView çš„å›žè°ƒäº‹ä»¶ï¼Œå½“ç½‘é¡µåŠ è½½è¿‡ç¨‹ä¸ï¼ŒåŠ è½½å®ŒæˆåŽæˆ–è€…åŠ è½½å‡ºé”™æ—¶éƒ½ä¼šå›žè°ƒæ¤å‡½æ•° */ + webviewLoadedEvents: Component.EventHandler[]; /** !#en - Returns the displayed opacity of Node, - the difference between displayed opacity and opacity is that displayed opacity is calculated based on opacity and parent node's opacity when cascade opacity enabled. + Set javascript interface scheme (see also setOnJSCallback). <br/> + Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.<br/> + Please refer to the official documentation for more details. !#zh - 获å–èŠ‚ç‚¹æ˜¾ç¤ºé€æ˜Žåº¦ï¼Œ - æ˜¾ç¤ºé€æ˜Žåº¦å’Œé€æ˜Žåº¦ä¹‹é—´çš„ä¸åŒä¹‹å¤„在于当å¯ç”¨çº§è¿žé€æ˜Žåº¦æ—¶ï¼Œ - æ˜¾ç¤ºé€æ˜Žåº¦æ˜¯åŸºäºŽè‡ªèº«é€æ˜Žåº¦å’Œçˆ¶èŠ‚ç‚¹é€æ˜Žåº¦è®¡ç®—的。 + 设置 JavaScript æŽ¥å£æ–¹æ¡ˆï¼ˆä¸Ž 'setOnJSCallback' é…套使用)。<br/> + 注æ„ï¼šåªæ”¯æŒ Android å’Œ iOS ,Web 端用法请å‰å¾€å®˜æ–¹æ–‡æ¡£æŸ¥çœ‹ã€‚<br/> + 详情请å‚阅官方文档 + @param scheme scheme */ - getDisplayedOpacity(): number; + setJavascriptInterfaceScheme(scheme: string): void; /** !#en - Returns the displayed color of Node, - the difference between displayed color and color is that displayed color is calculated based on color and parent node's color when cascade color enabled. + This callback called when load URL that start with javascript + interface scheme (see also setJavascriptInterfaceScheme). <br/> + Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.<br/> + Please refer to the official documentation for more details. !#zh - 获å–节点的显示颜色, - 显示颜色和颜色之间的ä¸åŒä¹‹å¤„在于当å¯ç”¨çº§è¿žé¢œè‰²æ—¶ï¼Œ - 显示颜色是基于自身颜色和父节点颜色计算的。 - */ - getDisplayedColor(): Color; - /** !#en Cascade opacity is removed from v2.0 - Indicate whether node's opacity value affect its child nodes, default value is true. - !#zh 逿˜Žåº¦çº§è”功能从 v2.0 开始已移除 - 节点的ä¸é€æ˜Žåº¦å€¼æ˜¯å¦å½±å“å…¶å节点,默认值为 true。 */ - cascadeOpacity: boolean; - /** - !#en Cascade opacity is removed from v2.0 - Returns whether node's opacity value affect its child nodes. - !#zh 逿˜Žåº¦çº§è”功能从 v2.0 开始已移除 - 返回节点的ä¸é€æ˜Žåº¦å€¼æ˜¯å¦å½±å“å…¶å节点。 - */ - isCascadeOpacityEnabled(): boolean; - /** - !#en Cascade opacity is removed from v2.0 - Enable or disable cascade opacity, if cascade enabled, child nodes' opacity will be the multiplication of parent opacity and its own opacity. - !#zh 逿˜Žåº¦çº§è”功能从 v2.0 开始已移除 - å¯ç”¨æˆ–ç¦ç”¨çº§è¿žä¸é€æ˜Žåº¦ï¼Œå¦‚果级连å¯ç”¨ï¼Œå节点的ä¸é€æ˜Žåº¦å°†æ˜¯çˆ¶ä¸é€æ˜Žåº¦ä¹˜ä¸Šå®ƒè‡ªå·±çš„ä¸é€æ˜Žåº¦ã€‚ - @param cascadeOpacityEnabled cascadeOpacityEnabled - */ - setCascadeOpacityEnabled(cascadeOpacityEnabled: boolean): void; - /** - !#en Opacity modify RGB have been removed since v2.0 - Set whether color should be changed with the opacity value, - useless in ccsg.Node, but this function is override in some class to have such behavior. - !#zh 逿˜Žåº¦å½±å“颜色é…置已ç»è¢«åºŸå¼ƒ - è®¾ç½®æ›´æ”¹é€æ˜Žåº¦æ—¶æ˜¯å¦ä¿®æ”¹RGB值, - @param opacityValue opacityValue + å½“åŠ è½½ URL 以 JavaScript æŽ¥å£æ–¹æ¡ˆå¼€å§‹æ—¶è°ƒç”¨è¿™ä¸ªå›žè°ƒå‡½æ•°ã€‚<br/> + 注æ„ï¼šåªæ”¯æŒ Android å’Œ iOS,Web 端用法请å‰å¾€å®˜æ–¹æ–‡æ¡£æŸ¥çœ‹ã€‚ + 详情请å‚阅官方文档 + @param callback callback */ - setOpacityModifyRGB(opacityValue: boolean): void; + setOnJSCallback(callback: Function): void; /** - !#en Opacity modify RGB have been removed since v2.0 - Get whether color should be changed with the opacity value. - !#zh 逿˜Žåº¦å½±å“颜色é…置已ç»è¢«åºŸå¼ƒ - èŽ·å–æ›´æ”¹é€æ˜Žåº¦æ—¶æ˜¯å¦ä¿®æ”¹RGB值。 + !#en + Evaluates JavaScript in the context of the currently displayed page. <br/> + Please refer to the official document for more details <br/> + Note: Cross domain issues need to be resolved by yourself <br/> + !#zh + 执行 WebView 内部页é¢è„šæœ¬ï¼ˆè¯¦æƒ…è¯·å‚阅官方文档) <br/> + 注æ„:需è¦è‡ªè¡Œè§£å†³è·¨åŸŸé—®é¢˜ + @param str str */ - isOpacityModifyRGB(): boolean; - } - /** !#en - cc.Scene is a subclass of cc.Node that is used only as an abstract concept.<br/> - cc.Scene and cc.Node are almost identical with the difference that users can not modify cc.Scene manually. - !#zh - cc.Scene 是 cc.Node çš„å类,仅作为一个抽象的概念。<br/> - cc.Scene å’Œ cc.Node 有点ä¸åŒï¼Œç”¨æˆ·ä¸åº”直接修改 cc.Scene。 */ - export class Scene extends Node { - /** !#en Indicates whether all (directly or indirectly) static referenced assets of this scene are releasable by default after scene unloading. - !#zh 指示该场景ä¸ç›´æŽ¥æˆ–é—´æŽ¥é™æ€å¼•ç”¨åˆ°çš„æ‰€æœ‰èµ„æºæ˜¯å¦é»˜è®¤åœ¨åœºæ™¯åˆ‡æ¢åŽè‡ªåŠ¨é‡Šæ”¾ã€‚ */ - autoReleaseAssets: boolean; - } - /** !#en - Class of private entities in Cocos Creator scenes.<br/> - The PrivateNode is hidden in editor, and completely transparent to users.<br/> - It's normally used as Node's private content created by components in parent node.<br/> - So in theory private nodes are not children, they are part of the parent node.<br/> - Private node have two important characteristics:<br/> - 1. It has the minimum z index and cannot be modified, because they can't be displayed over real children.<br/> - 2. The positioning of private nodes is also special, they will consider the left bottom corner of the parent node's bounding box as the origin of local coordinates.<br/> - In this way, they can be easily kept inside the bounding box.<br/> - Currently, it's used by RichText component and TileMap component. - !#zh - Cocos Creator 场景ä¸çš„ç§æœ‰èŠ‚ç‚¹ç±»ã€‚<br/> - ç§æœ‰èŠ‚ç‚¹åœ¨ç¼–è¾‘å™¨ä¸ä¸å¯è§ï¼Œå¯¹ç”¨æˆ·é€æ˜Žã€‚<br/> - é€šå¸¸ç§æœ‰èŠ‚ç‚¹æ˜¯è¢«ä¸€äº›ç‰¹æ®Šçš„ç»„ä»¶åˆ›å»ºå‡ºæ¥ä½œä¸ºçˆ¶èŠ‚ç‚¹çš„ä¸€éƒ¨åˆ†è€Œå˜åœ¨çš„,ç†è®ºä¸Šæ¥è¯´ï¼Œå®ƒä»¬ä¸æ˜¯å节点,而是父节点的组æˆéƒ¨åˆ†ã€‚<br/> - ç§æœ‰èŠ‚ç‚¹æœ‰ä¸¤ä¸ªéžå¸¸é‡è¦çš„特性:<br/> - 1. å®ƒæœ‰ç€æœ€å°çš„æ¸²æŸ“排åºçš„ Z è½´æ·±åº¦ï¼Œå¹¶ä¸”æ— æ³•è¢«æ›´æ”¹ï¼Œå› ä¸ºå®ƒä»¬ä¸èƒ½è¢«æ˜¾ç¤ºåœ¨å…¶ä»–æ£å¸¸å节点之上。<br/> - 2. 它的定ä½ä¹Ÿæ˜¯ç‰¹æ®Šçš„ï¼Œå¯¹äºŽç§æœ‰èŠ‚ç‚¹æ¥è¯´ï¼Œçˆ¶èŠ‚ç‚¹åŒ…å›´ç›’çš„å·¦ä¸‹è§’æ˜¯å®ƒçš„å±€éƒ¨åæ ‡ç³»åŽŸç‚¹ï¼Œè¿™ä¸ªåŽŸç‚¹ç›¸å½“äºŽçˆ¶èŠ‚ç‚¹çš„ä½ç½®å‡åŽ»å®ƒé”šç‚¹çš„åç§»ã€‚è¿™æ ·ç§æœ‰èŠ‚ç‚¹å¯ä»¥æ¯”较容易被控制在包围盒之ä¸ã€‚<br/> - ç›®å‰åœ¨å¼•擎ä¸ï¼ŒRichText å’Œ TileMap 都有å¯èƒ½ç”Ÿæˆç§æœ‰èŠ‚ç‚¹ã€‚ */ - export class PrivateNode extends Node { + evaluateJS(str: string): void; /** + !#en if you don't need the WebView and it isn't in any running Scene, you should + call the destroy method on this component or the associated node explicitly. + Otherwise, the created DOM element won't be removed from web page. + !#zh + å¦‚æžœä½ ä¸å†ä½¿ç”¨ WebViewï¼Œå¹¶ä¸”ç»„ä»¶æœªæ·»åŠ åˆ°åœºæ™¯ä¸ï¼Œé‚£ä¹ˆä½ 必须手动对组件或所在节点调用 destroy。 + è¿™æ ·æ‰èƒ½ç§»é™¤ç½‘页上的 DOM 节点,é¿å… Web å¹³å°å†…å˜æ³„露。 - @param name name + @example + ```js + webview.node.parent = null; // or webview.node.removeFromParent(false); + // when you don't need webview anymore + webview.node.destroy(); + ``` */ - constructor(name?: string); + destroy(): boolean; } /** !#en - Scheduler is responsible of triggering the scheduled callbacks.<br/> - You should not use NSTimer. Instead use this class.<br/> - <br/> - There are 2 different types of callbacks (selectors):<br/> - - update callback: the 'update' callback will be called every frame. You can customize the priority.<br/> - - custom callback: A custom callback will be called every frame, or with a custom interval of time<br/> - <br/> - The 'custom selectors' should be avoided when possible. It is faster, - and consumes less memory to use the 'update callback'. * - !#zh - Scheduler 是负责触å‘回调函数的类。<br/> - 通常情况下,建议使用 cc.director.getScheduler() æ¥èŽ·å–系统定时器。<br/> - 有两ç§ä¸åŒç±»åž‹çš„定时器:<br/> - - update 定时器:æ¯ä¸€å¸§éƒ½ä¼šè§¦å‘。您å¯ä»¥è‡ªå®šä¹‰ä¼˜å…ˆçº§ã€‚<br/> - - 自定义定时器:自定义定时器å¯ä»¥æ¯ä¸€å¸§æˆ–者自定义的时间间隔触å‘。<br/> - 如果希望æ¯å¸§éƒ½è§¦å‘,应该使用 update 定时器,使用 update 定时器更快,而且消耗更少的内å˜ã€‚ */ - export class Scheduler { - /** - !#en This method should be called for any target which needs to schedule tasks, and this method should be called before any scheduler API usage. - This method will add a `_id` property if it doesn't exist. - !#zh 任何需è¦ç”¨ Scheduler 管ç†ä»»åŠ¡çš„å¯¹è±¡ä¸»ä½“éƒ½åº”è¯¥è°ƒç”¨è¿™ä¸ªæ–¹æ³•ï¼Œå¹¶ä¸”åº”è¯¥åœ¨è°ƒç”¨ä»»ä½• Scheduler API 之å‰è°ƒç”¨è¿™ä¸ªæ–¹æ³•。 - è¿™ä¸ªæ–¹æ³•ä¼šç»™å¯¹è±¡æ·»åŠ ä¸€ä¸ª `_id` 属性,如果这个属性ä¸å˜åœ¨çš„è¯ã€‚ - @param target target - */ - enableForTarget(target: any): void; + cc.NodePool is the cache pool designed for node type.<br/> + It can helps you to improve your game performance for objects which need frequent release and recreate operations<br/> + + It's recommended to create cc.NodePool instances by node type, the type corresponds to node type in game design, not the class, + for example, a prefab is a specific node type. <br/> + When you create a node pool, you can pass a Component which contains `unuse`, `reuse` functions to control the content of node.<br/> + + Some common use case is :<br/> + 1. Bullets in game (die very soon, massive creation and recreation, no side effect on other objects)<br/> + 2. Blocks in candy crash (massive creation and recreation)<br/> + etc... + !#zh + cc.NodePool 是用于管ç†èŠ‚ç‚¹å¯¹è±¡çš„å¯¹è±¡ç¼“å˜æ± 。<br/> + 它å¯ä»¥å¸®åŠ©æ‚¨æé«˜æ¸¸æˆæ€§èƒ½ï¼Œé€‚用于优化对象的åå¤åˆ›å»ºå’Œé”€æ¯<br/> + ä»¥å‰ cocos2d-x ä¸çš„ cc.pool 和新的节点事件注册系统ä¸å…¼å®¹ï¼Œå› æ¤è¯·ä½¿ç”¨ cc.NodePool æ¥ä»£æ›¿ã€‚ + + æ–°çš„ NodePool 需è¦å®žä¾‹åŒ–ä¹‹åŽæ‰èƒ½ä½¿ç”¨ï¼Œæ¯ç§ä¸åŒçš„èŠ‚ç‚¹å¯¹è±¡æ± éœ€è¦ä¸€ä¸ªä¸åŒçš„å¯¹è±¡æ± å®žä¾‹ï¼Œè¿™é‡Œçš„ç§ç±»å¯¹åº”于游æˆä¸çš„节点设计,一个 prefab 相当于一个ç§ç±»çš„节点。<br/> + åœ¨åˆ›å»ºç¼“å†²æ± æ—¶ï¼Œå¯ä»¥ä¼ å…¥ä¸€ä¸ªåŒ…å« unuse, reuse 函数的组件类型用于节点的回收和å¤ç”¨é€»è¾‘。<br/> + + 一些常è§çš„用例是:<br/> + 1.在游æˆä¸çš„å弹(æ»äº¡å¾ˆå¿«ï¼Œé¢‘ç¹åˆ›å»ºï¼Œå¯¹å…¶ä»–å¯¹è±¡æ— å‰¯ä½œç”¨ï¼‰<br/> + 2.ç³–æžœç²‰ç¢Žä¼ å¥‡ä¸çš„æœ¨å—(频ç¹åˆ›å»ºï¼‰ã€‚ + ç‰ç‰.... */ + export class NodePool { /** !#en - Modifies the time of all scheduled callbacks.<br/> - You can use this property to create a 'slow motion' or 'fast forward' effect.<br/> - Default is 1.0. To create a 'slow motion' effect, use values below 1.0.<br/> - To create a 'fast forward' effect, use values higher than 1.0.<br/> - Note:It will affect EVERY scheduled selector / action. + Constructor for creating a pool for a specific node template (usually a prefab). You can pass a component (type or name) argument for handling event for reusing and recycling node. !#zh - 设置时间间隔的缩放比例。<br/> - 您å¯ä»¥ä½¿ç”¨è¿™ä¸ªæ–¹æ³•æ¥åˆ›å»ºä¸€ä¸ª “slow motion(慢动作)†或 “fast forward(快进)†的效果。<br/> - 默认是 1.0。è¦åˆ›å»ºä¸€ä¸ª “slow motion(慢动作)†效果,使用值低于 1.0。<br/> - è¦ä½¿ç”¨ “fast forward(快进)†效果,使用值大于 1.0。<br/> - 注æ„:它影å“该 Scheduler 下管ç†çš„æ‰€æœ‰å®šæ—¶å™¨ã€‚ - @param timeScale timeScale + ä½¿ç”¨æž„é€ å‡½æ•°æ¥åˆ›å»ºä¸€ä¸ªèŠ‚ç‚¹ä¸“ç”¨çš„å¯¹è±¡æ± ï¼Œæ‚¨å¯ä»¥ä¼ 递一个组件类型或å称,用于处ç†èŠ‚ç‚¹å›žæ”¶å’Œå¤ç”¨æ—¶çš„事件逻辑。 + @param poolHandlerComp !#en The constructor or the class name of the component to control the unuse/reuse logic. !#zh 处ç†èŠ‚ç‚¹å›žæ”¶å’Œå¤ç”¨äº‹ä»¶é€»è¾‘的组件类型或å称。 + + @example + ```js + properties: { + template: cc.Prefab + }, + onLoad () { + // MyTemplateHandler is a component with 'unuse' and 'reuse' to handle events when node is reused or recycled. + this.myPool = new cc.NodePool('MyTemplateHandler'); + } + ``` */ - setTimeScale(timeScale: number): void; + constructor(poolHandlerComp?: {prototype: Component}|string); + /** !#en The pool handler component, it could be the class name or the constructor. + !#zh ç¼“å†²æ± å¤„ç†ç»„件,用于节点的回收和å¤ç”¨é€»è¾‘,这个属性å¯ä»¥æ˜¯ç»„ä»¶ç±»åæˆ–ç»„ä»¶çš„æž„é€ å‡½æ•°ã€‚ */ + poolHandlerComp: Function|string; /** - !#en Returns time scale of scheduler. - !#zh èŽ·å–æ—¶é—´é—´éš”的缩放比例。 + !#en The current available size in the pool + !#zh 获å–当å‰ç¼“å†²æ± çš„å¯ç”¨å¯¹è±¡æ•°é‡ */ - getTimeScale(): number; + size(): number; /** - !#en 'update' the scheduler. (You should NEVER call this method, unless you know what you are doing.) - !#zh update 调度函数。(ä¸åº”该直接调用这个方法,除éžå®Œå…¨äº†è§£è¿™ä¹ˆåšçš„结果) - @param dt delta time + !#en Destroy all cached nodes in the pool + !#zh 销æ¯å¯¹è±¡æ± ä¸ç¼“å˜çš„æ‰€æœ‰èŠ‚ç‚¹ */ - update(dt: number): void; + clear(): void; /** - !#en - <p> - The scheduled method will be called every 'interval' seconds.<br/> - If paused is YES, then it won't be called until it is resumed.<br/> - If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.<br/> - If the callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.<br/> - repeat let the action be repeated repeat + 1 times, use cc.macro.REPEAT_FOREVER to let the action run continuously<br/> - delay is the amount of time the action will wait before it'll start<br/> - </p> - !#zh - 指定回调函数,调用对象ç‰ä¿¡æ¯æ¥æ·»åŠ ä¸€ä¸ªæ–°çš„å®šæ—¶å™¨ã€‚<br/> - 如果 paused 值为 true,那么直到 resume 被调用æ‰å¼€å§‹è®¡æ—¶ã€‚<br/> - 当时间间隔达到指定值时,设置的回调函数将会被调用。<br/> - 如果 interval 值为 0,那么回调函数æ¯ä¸€å¸§éƒ½ä¼šè¢«è°ƒç”¨ï¼Œä½†å¦‚æžœæ˜¯è¿™æ ·ï¼Œ - 建议使用 scheduleUpdateForTarget 代替。<br/> - 如果回调函数已ç»è¢«å®šæ—¶å™¨ä½¿ç”¨ï¼Œé‚£ä¹ˆåªä¼šæ›´æ–°ä¹‹å‰å®šæ—¶å™¨çš„æ—¶é—´é—´éš”傿•°ï¼Œä¸ä¼šè®¾ç½®æ–°çš„定时器。<br/> - repeat 值å¯ä»¥è®©å®šæ—¶å™¨è§¦å‘ repeat + 1 次,使用 cc.macro.REPEAT_FOREVER - å¯ä»¥è®©å®šæ—¶å™¨ä¸€ç›´å¾ªçŽ¯è§¦å‘。<br/> - delay 值指定延迟时间,定时器会在延迟指定的时间之åŽå¼€å§‹è®¡æ—¶ã€‚ - @param callback callback - @param target target - @param interval interval - @param repeat repeat - @param delay delay - @param paused paused + !#en Put a new Node into the pool. + It will automatically remove the node from its parent without cleanup. + It will also invoke unuse method of the poolHandlerComp if exist. + !#zh å‘ç¼“å†²æ± ä¸å˜å…¥ä¸€ä¸ªä¸å†éœ€è¦çš„节点对象。 + è¿™ä¸ªå‡½æ•°ä¼šè‡ªåŠ¨å°†ç›®æ ‡èŠ‚ç‚¹ä»Žçˆ¶èŠ‚ç‚¹ä¸Šç§»é™¤ï¼Œä½†æ˜¯ä¸ä¼šè¿›è¡Œ cleanup æ“作。 + 这个函数会调用 poolHandlerComp çš„ unuse 函数,如果组件和函数都å˜åœ¨çš„è¯ã€‚ + @param obj obj @example ```js - //register a schedule to scheduler - cc.director.getScheduler().schedule(callback, this, interval, !this._isRunning); + let myNode = cc.instantiate(this.template); + this.myPool.put(myNode); + ``` + */ + put(obj: Node): void; + /** + !#en Get a obj from pool, if no available object in pool, null will be returned. + This function will invoke the reuse function of poolHandlerComp if exist. + !#zh 获å–å¯¹è±¡æ± ä¸çš„å¯¹è±¡ï¼Œå¦‚æžœå¯¹è±¡æ± æ²¡æœ‰å¯ç”¨å¯¹è±¡ï¼Œåˆ™è¿”回空。 + 这个函数会调用 poolHandlerComp çš„ reuse 函数,如果组件和函数都å˜åœ¨çš„è¯ã€‚ + @param params !#en Params to pass to 'reuse' method in poolHandlerComp !#zh å‘ poolHandlerComp ä¸çš„ 'reuse' å‡½æ•°ä¼ é€’çš„å‚æ•° + @example + ```js + let newNode = this.myPool.get(); ``` */ - schedule(callback: Function, target: any, interval: number, repeat: number, delay: number, paused?: boolean): void; - schedule(callback: Function, target: any, interval: number, paused?: boolean): void; + get(...params: any[]): Node; + } + /** !#en + Camera is usefull when making reel game or other games which need scroll screen. + Using camera will be more efficient than moving node to scroll screen. + Camera + !#zh + æ‘„åƒæœºåœ¨åˆ¶ä½œå·è½´æˆ–是其他需è¦ç§»åЍå±å¹•çš„æ¸¸æˆæ—¶æ¯”è¾ƒæœ‰ç”¨ï¼Œä½¿ç”¨æ‘„åƒæœºå°†ä¼šæ¯”移动节点æ¥ç§»åЍå±å¹•æ›´åŠ é«˜æ•ˆã€‚ */ + export class Camera extends Component { + /** !#en + The camera zoom ratio, only support 2D camera. + !#zh + æ‘„åƒæœºç¼©æ”¾æ¯”率, åªæ”¯æŒ 2D camera。 */ + zoomRatio: number; + /** !#en + Field of view. The width of the Camera’s view angle, measured in degrees along the local Y axis. + !#zh + å†³å®šæ‘„åƒæœºè§†è§’çš„å®½åº¦ï¼Œå½“æ‘„åƒæœºå¤„于é€è§†æŠ•影模å¼ä¸‹è¿™ä¸ªå±žæ€§æ‰ä¼šç”Ÿæ•ˆã€‚ */ + fov: number; + /** !#en + The viewport size of the Camera when set to orthographic projection. + !#zh + æ‘„åƒæœºåœ¨æ£äº¤æŠ•影模å¼ä¸‹çš„视窗大å°ã€‚ */ + orthoSize: number; + /** !#en + The near clipping plane. + !#zh + æ‘„åƒæœºçš„近剪è£é¢ã€‚ */ + nearClip: number; + /** !#en + The far clipping plane. + !#zh + æ‘„åƒæœºçš„远剪è£é¢ã€‚ */ + farClip: number; + /** !#en + Is the camera orthographic (true) or perspective (false)? + !#zh + è®¾ç½®æ‘„åƒæœºçš„æŠ•å½±æ¨¡å¼æ˜¯æ£äº¤è¿˜æ˜¯é€è§†æ¨¡å¼ã€‚ */ + ortho: boolean; + /** !#en + Four values (0 ~ 1) that indicate where on the screen this camera view will be drawn. + !#zh + å†³å®šæ‘„åƒæœºç»˜åˆ¶åœ¨å±å¹•上哪个ä½ç½®ï¼Œå€¼ä¸ºï¼ˆ0 ~ 1)。 */ + rect: Rect; + /** !#en + This is used to render parts of the scene selectively. + !#zh + å†³å®šæ‘„åƒæœºä¼šæ¸²æŸ“场景的哪一部分。 */ + cullingMask: number; + /** !#en + Determining what to clear when camera rendering. + !#zh + å†³å®šæ‘„åƒæœºæ¸²æŸ“时会清除哪些状æ€ã€‚ */ + clearFlags: Camera.ClearFlags; + /** !#en + The color with which the screen will be cleared. + !#zh + æ‘„åƒæœºç”¨äºŽæ¸…除å±å¹•的背景色。 */ + backgroundColor: Color; + /** !#en + Camera's depth in the camera rendering order. Cameras with higher depth are rendered after cameras with lower depth. + !#zh + æ‘„åƒæœºæ·±åº¦ã€‚ç”¨äºŽå†³å®šæ‘„åƒæœºçš„æ¸²æŸ“顺åºï¼Œå€¼è¶Šå¤§æ¸²æŸ“在越上层。 */ + depth: number; + /** !#en + Destination render texture. + Usually cameras render directly to screen, but for some effects it is useful to make a camera render into a texture. + !#zh + æ‘„åƒæœºæ¸²æŸ“çš„ç›®æ ‡ RenderTexture。 + ä¸€èˆ¬æ‘„åƒæœºä¼šç›´æŽ¥æ¸²æŸ“到å±å¹•上,但是有一些效果å¯ä»¥ä½¿ç”¨æ‘„åƒæœºæ¸²æŸ“到 RenderTexture 上å†å¯¹ RenderTexture è¿›è¡Œå¤„ç†æ¥å®žçŽ°ã€‚ */ + targetTexture: RenderTexture; + /** !#en + Sets the camera's render stages. + !#zh + è®¾ç½®æ‘„åƒæœºæ¸²æŸ“的阶段 */ + renderStages: number; + /** !#en Whether auto align camera viewport to screen + !#zh 是å¦è‡ªåŠ¨å°†æ‘„åƒæœºçš„视å£å¯¹å‡†å±å¹• */ + alignWithScreen: boolean; + /** !#en + The primary camera in the scene. Returns the rear most rendered camera, which is the camera with the lowest depth. + !#zh + 当å‰åœºæ™¯ä¸æ¿€æ´»çš„ä¸»æ‘„åƒæœºã€‚将会返回渲染在å±å¹•最底层,也就是 depth 最å°çš„æ‘„åƒæœºã€‚ */ + static main: Camera; + /** !#en + All enabled cameras. + !#zh + 当剿¿€æ´»çš„æ‰€æœ‰æ‘„åƒæœºã€‚ */ + static cameras: Camera[]; /** !#en - Schedules the update callback for a given target, - During every frame after schedule started, the "update" function of target will be invoked. + Get the first camera which the node belong to. !#zh - 使用指定的优先级为指定的对象设置 update 定时器。 - update 定时器æ¯ä¸€å¸§éƒ½ä¼šè¢«è§¦å‘ï¼Œè§¦å‘æ—¶è‡ªåŠ¨è°ƒç”¨æŒ‡å®šå¯¹è±¡çš„ "update" 函数。 - 优先级的值越低,定时器被触å‘的越早。 - @param target target - @param priority priority - @param paused paused + 获å–èŠ‚ç‚¹æ‰€åœ¨çš„ç¬¬ä¸€ä¸ªæ‘„åƒæœºã€‚ + @param node node */ - scheduleUpdate(target: any, priority: number, paused: boolean): void; + static findCamera(node: Node): Camera; /** !#en - Unschedules a callback for a callback and a given target. - If you want to unschedule the "update", use `unscheduleUpdate()` + Get the screen to world matrix, only support 2D camera which alignWithScreen is true. !#zh - å–æ¶ˆæŒ‡å®šå¯¹è±¡å®šæ—¶å™¨ã€‚ - 如果需è¦å–消 update 定时器,请使用 unscheduleUpdate()。 - @param callback The callback to be unscheduled - @param target The target bound to the callback. + 获å–å±å¹•åæ ‡ç³»åˆ°ä¸–ç•Œåæ ‡ç³»çš„矩阵,åªé€‚用于 alignWithScreen 为 true çš„ 2D æ‘„åƒæœºã€‚ + @param out the matrix to receive the result */ - unschedule(callback: Function, target: any): void; + getScreenToWorldMatrix2D(out: Mat4): Mat4; /** - !#en Unschedules the update callback for a given target. - !#zh å–æ¶ˆæŒ‡å®šå¯¹è±¡çš„ update 定时器。 - @param target The target to be unscheduled. + !#en + Get the world to camera matrix, only support 2D camera which alignWithScreen is true. + !#zh + 获å–ä¸–ç•Œåæ ‡ç³»åˆ°æ‘„åƒæœºåæ ‡ç³»çš„çŸ©é˜µï¼Œåªé€‚用于 alignWithScreen 为 true çš„ 2D æ‘„åƒæœºã€‚ + @param out the matrix to receive the result */ - unscheduleUpdate(target: any): void; + getWorldToScreenMatrix2D(out: Mat4): Mat4; /** !#en - Unschedules all scheduled callbacks for a given target. - This also includes the "update" callback. - !#zh å–æ¶ˆæŒ‡å®šå¯¹è±¡çš„æ‰€æœ‰å®šæ—¶å™¨ï¼ŒåŒ…括 update 定时器。 - @param target The target to be unscheduled. + Convert point from screen to world. + !#zh + å°†åæ ‡ä»Žå±å¹•åæ ‡ç³»è½¬æ¢åˆ°ä¸–ç•Œåæ ‡ç³»ã€‚ + @param screenPosition screenPosition + @param out out + */ + getScreenToWorldPoint(screenPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3; + /** + !#en + Convert point from world to screen. + !#zh + å°†åæ ‡ä»Žä¸–ç•Œåæ ‡ç³»è½¬åŒ–到å±å¹•åæ ‡ç³»ã€‚ + @param worldPosition worldPosition + @param out out */ - unscheduleAllForTarget(target: any): void; + getWorldToScreenPoint(worldPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3; /** !#en - Unschedules all scheduled callbacks from all targets including the system callbacks.<br/> - You should NEVER call this method, unless you know what you are doing. + Get a ray from screen position !#zh - å–æ¶ˆæ‰€æœ‰å¯¹è±¡çš„æ‰€æœ‰å®šæ—¶å™¨ï¼ŒåŒ…括系统定时器。<br/> - ä¸è¦è°ƒç”¨æ¤å‡½æ•°ï¼Œé™¤éžä½ ç¡®å®šä½ åœ¨åšä»€ä¹ˆã€‚ + 从å±å¹•åæ ‡èŽ·å–一æ¡å°„线 + @param screenPos screenPos */ - unscheduleAll(): void; + getRay(screenPos: Vec2): geomUtils.Ray; /** !#en - Unschedules all callbacks from all targets with a minimum priority.<br/> - You should only call this with `PRIORITY_NON_SYSTEM_MIN` or higher. + Check whether the node is in the camera. !#zh - å–æ¶ˆæ‰€æœ‰ä¼˜å…ˆçº§çš„值大于指定优先级的定时器。<br/> - ä½ åº”è¯¥åªå–消优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。 - @param minPriority The minimum priority of selector to be unscheduled. Which means, all selectors which - priority is higher than minPriority will be unscheduled. - */ - unscheduleAllWithMinPriority(minPriority: number): void; - /** - !#en Checks whether a callback for a given target is scheduled. - !#zh æ£€æŸ¥æŒ‡å®šçš„å›žè°ƒå‡½æ•°å’Œå›žè°ƒå¯¹è±¡ç»„åˆæ˜¯å¦å˜åœ¨å®šæ—¶å™¨ã€‚ - @param callback The callback to check. - @param target The target of the callback. + 检测节点是å¦è¢«æ¤æ‘„åƒæœºå½±å“ + @param node the node which need to check */ - isScheduled(callback: Function, target: any): boolean; + containsNode(node: Node): boolean; /** !#en - Pause all selectors from all targets.<br/> - You should NEVER call this method, unless you know what you are doing. + Render the camera manually. !#zh - æš‚åœæ‰€æœ‰å¯¹è±¡çš„æ‰€æœ‰å®šæ—¶å™¨ã€‚<br/> - ä¸è¦è°ƒç”¨è¿™ä¸ªæ–¹æ³•,除éžä½ 知é“ä½ æ£åœ¨åšä»€ä¹ˆã€‚ + æ‰‹åŠ¨æ¸²æŸ“æ‘„åƒæœºã€‚ + @param rootNode rootNode */ - pauseAllTargets(): void; + render(rootNode?: Node): void; /** !#en - Pause all selectors from all targets with a minimum priority. <br/> - You should only call this with kCCPriorityNonSystemMin or higher. + Returns the matrix that transform the node's (local) space coordinates into the camera's space coordinates. !#zh - æš‚åœæ‰€æœ‰ä¼˜å…ˆçº§çš„值大于指定优先级的定时器。<br/> - ä½ åº”è¯¥åªæš‚åœä¼˜å…ˆçº§çš„值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。 - @param minPriority minPriority + è¿”å›žä¸€ä¸ªå°†èŠ‚ç‚¹åæ ‡ç³»è½¬æ¢åˆ°æ‘„åƒæœºåæ ‡ç³»ä¸‹çš„çŸ©é˜µ + @param node the node which should transform */ - pauseAllTargetsWithMinPriority(minPriority: number): void; + getNodeToCameraTransform(node: Node): AffineTransform; /** !#en - Resume selectors on a set of targets.<br/> - This can be useful for undoing a call to pauseAllCallbacks. + Conver a camera coordinates point to world coordinates. !#zh - æ¢å¤æŒ‡å®šæ•°ç»„䏿‰€æœ‰å¯¹è±¡çš„定时器。<br/> - 这个函数是 pauseAllCallbacks 的逆æ“作。 - @param targetsToResume targetsToResume + å°†ä¸€ä¸ªæ‘„åƒæœºåæ ‡ç³»ä¸‹çš„ç‚¹è½¬æ¢åˆ°ä¸–ç•Œåæ ‡ç³»ä¸‹ã€‚ + @param point the point which should transform + @param out the point to receive the result */ - resumeTargets(targetsToResume: any[]): void; + getCameraToWorldPoint(point: Vec2, out?: Vec2): Vec2; /** !#en - Pauses the target.<br/> - All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.<br/> - If the target is not present, nothing happens. + Conver a world coordinates point to camera coordinates. !#zh - æš‚åœæŒ‡å®šå¯¹è±¡çš„定时器。<br/> - 指定对象的所有定时器都会被暂åœã€‚<br/> - 如果指定的对象没有定时器,什么也ä¸ä¼šå‘生。 - @param target target + å°†ä¸€ä¸ªä¸–ç•Œåæ ‡ç³»ä¸‹çš„点转æ¢åˆ°æ‘„åƒæœºåæ ‡ç³»ä¸‹ã€‚ + @param point point + @param out the point to receive the result */ - pauseTarget(target: any): void; + getWorldToCameraPoint(point: Vec2, out?: Vec2): Vec2; /** !#en - Resumes the target.<br/> - The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.<br/> - If the target is not present, nothing happens. + Get the camera to world matrix !#zh - æ¢å¤æŒ‡å®šå¯¹è±¡çš„æ‰€æœ‰å®šæ—¶å™¨ã€‚<br/> - 指定对象的所有定时器将继ç»å·¥ä½œã€‚<br/> - 如果指定的对象没有定时器,什么也ä¸ä¼šå‘生。 - @param target target + èŽ·å–æ‘„åƒæœºåæ ‡ç³»åˆ°ä¸–ç•Œåæ ‡ç³»çš„矩阵 + @param out the matrix to receive the result */ - resumeTarget(target: any): void; + getCameraToWorldMatrix(out: Mat4): Mat4; /** - !#en Returns whether or not the target is paused. - !#zh è¿”å›žæŒ‡å®šå¯¹è±¡çš„å®šæ—¶å™¨æ˜¯å¦æš‚åœäº†ã€‚ - @param target target + !#en + Get the world to camera matrix + !#zh + 获å–ä¸–ç•Œåæ ‡ç³»åˆ°æ‘„åƒæœºåæ ‡ç³»çš„çŸ©é˜µ + @param out the matrix to receive the result */ - isTargetPaused(target: any): boolean; - /** !#en Priority level reserved for system services. - !#zh 系统æœåŠ¡çš„ä¼˜å…ˆçº§ã€‚ */ - static PRIORITY_SYSTEM: number; - /** !#en Minimum priority level for user scheduling. - !#zh 用户调度最低优先级。 */ - static PRIORITY_NON_SYSTEM: number; + getWorldToCameraMatrix(out: Mat4): Mat4; } /** !#en The Light Component @@ -5779,10 +5980,10 @@ declare namespace cc { ``` */ loadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], options: Record<string, any>, onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, data: any) => void): void; - loadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], options: Record<string, any>, onComplete: (err: Error, data: any) => void): void; - loadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], options: Record<string, any>): void; loadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, data: any) => void): void; + loadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], options: Record<string, any>, onComplete: (err: Error, data: any) => void): void; loadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], onComplete: (err: Error, data: any) => void): void; + loadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], options: Record<string, any>): void; loadAny(requests: string | string[] | Record<string, any> | Record<string, any>[]): void; /** !#en @@ -5804,8 +6005,8 @@ declare namespace cc { ``` */ preloadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], options: Record<string, any>, onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void; - preloadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], options: Record<string, any>, onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void; preloadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void; + preloadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], options: Record<string, any>, onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void; preloadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void; preloadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], options: Record<string, any>): void; preloadAny(requests: string | string[] | Record<string, any> | Record<string, any>[]): void; @@ -5825,8 +6026,8 @@ declare namespace cc { ``` */ postLoadNative(asset: cc.Asset, options: Record<string, any>, onComplete: (err: Error) => void): void; - postLoadNative(asset: cc.Asset, options: Record<string, any>): void; postLoadNative(asset: cc.Asset, onComplete: (err: Error) => void): void; + postLoadNative(asset: cc.Asset, options: Record<string, any>): void; postLoadNative(asset: cc.Asset): void; /** !#en @@ -5842,11 +6043,12 @@ declare namespace cc { ```js cc.assetManager.loadRemote('http://www.cloud.com/test1.jpg', (err, texture) => console.log(err)); cc.assetManager.loadRemote('http://www.cloud.com/test2.mp3', (err, audioClip) => console.log(err)); + cc.assetManager.loadRemote('http://www.cloud.com/test3', { ext: '.png' }, (err, texture) => console.log(err)); ``` */ loadRemote<T extends cc.Asset>(url: string, options: Record<string, any>, onComplete: (err: Error, asset: T) => void): void; - loadRemote<T extends cc.Asset>(url: string, options: Record<string, any>): void; loadRemote<T extends cc.Asset>(url: string, onComplete: (err: Error, asset: T) => void): void; + loadRemote<T extends cc.Asset>(url: string, options: Record<string, any>): void; loadRemote<T extends cc.Asset>(url: string): void; /** !#en @@ -5863,10 +6065,10 @@ declare namespace cc { loadScript('http://localhost:8080/index.js', null, (err) => console.log(err)); ``` */ - loadScript(url: string|string[], options: Record<string, any>, onComplete: (err: Error) => void): void;; - loadScript(url: string|string[], options: Record<string, any>): void;; - loadScript(url: string|string[], onComplete: (err: Error) => void): void;; - loadScript(url: string|string[]): void;; + loadScript(url: string|string[], options: Record<string, any>, onComplete: (err: Error) => void): void; + loadScript(url: string|string[], onComplete: (err: Error) => void): void; + loadScript(url: string|string[], options: Record<string, any>): void; + loadScript(url: string|string[]): void; /** !#en load bundle @@ -5883,8 +6085,8 @@ declare namespace cc { ``` */ loadBundle(nameOrUrl: string, options: Record<string, any>, onComplete: (err: Error, bundle: cc.AssetManager.Bundle) => void): void; - loadBundle(nameOrUrl: string, options: Record<string, any>): void; loadBundle(nameOrUrl: string, onComplete: (err: Error, bundle: cc.AssetManager.Bundle) => void): void; + loadBundle(nameOrUrl: string, options: Record<string, any>): void; loadBundle(nameOrUrl: string): void; /** !#en @@ -6232,365 +6434,98 @@ declare namespace cc { 最大å¯ä»¥è¢«å•æ¬¡æ‰¹å¤„ç†æ¸²æŸ“的顶点数é‡ã€‚ */ static BATCH_VERTEX_COUNT: number; /** !#en - Whether or not enabled tiled map auto culling. If you set the TiledMap skew or rotation, then need to manually disable this, otherwise, the rendering will be wrong. - !#zh - 是å¦å¼€å¯ç“¦ç‰‡åœ°å›¾çš„自动è£å‡åŠŸèƒ½ã€‚ç“¦ç‰‡åœ°å›¾å¦‚æžœè®¾ç½®äº† skew, rotation æˆ–è€…é‡‡ç”¨äº†æ‘„åƒæœºçš„è¯ï¼Œéœ€è¦æ‰‹åЍ关é—,å¦åˆ™æ¸²æŸ“会出错。 */ - static ENABLE_TILEDMAP_CULLING: boolean; - /** !#en - Boolean that indicates if the canvas contains an alpha channel, default sets to false for better performance. - Though if you want to make your canvas background transparent and show other dom elements at the background, - you can set it to true before `cc.game.run`. - Web only. - !#zh - 用于设置 Canvas èƒŒæ™¯æ˜¯å¦æ”¯æŒ alpha 通é“,默认为 falseï¼Œè¿™æ ·å¯ä»¥æœ‰æ›´é«˜çš„æ€§èƒ½è¡¨çŽ°ã€‚ - å¦‚æžœä½ å¸Œæœ› Canvas èƒŒæ™¯æ˜¯é€æ˜Žçš„,并显示背åŽçš„å…¶ä»– DOM å…ƒç´ ï¼Œä½ å¯ä»¥åœ¨ `cc.game.run` 之å‰å°†è¿™ä¸ªå€¼è®¾ä¸º true。 - ä»…æ”¯æŒ Web */ - static ENABLE_TRANSPARENT_CANVAS: boolean; - /** !#en - Boolean that indicates if the WebGL context is created with `antialias` option turned on, default value is false. - Set it to true could make your game graphics slightly smoother, like texture hard edges when rotated. - Whether to use this really depend on your game design and targeted platform, - device with retina display usually have good detail on graphics with or without this option, - you probably don't want antialias if your game style is pixel art based. - Also, it could have great performance impact with some browser / device using software MSAA. - You can set it to true before `cc.game.run`. - Web only. - !#zh - 用于设置在创建 WebGL Context 时是å¦å¼€å¯æŠ—锯齿选项,默认值是 false。 - 将这个选项设置为 true ä¼šè®©ä½ çš„æ¸¸æˆç”»é¢ç¨ç¨å¹³æ»‘一些,比如旋转硬边贴图时的锯齿。是å¦å¼€å¯è¿™ä¸ªé€‰é¡¹å¾ˆå¤§ç¨‹åº¦ä¸Šå–å†³äºŽä½ çš„æ¸¸æˆå’Œé¢å‘的平å°ã€‚ - 在大多数拥有 retina 级别å±å¹•çš„è®¾å¤‡ä¸Šç”¨æˆ·å¾€å¾€æ— æ³•åŒºåˆ†è¿™ä¸ªé€‰é¡¹å¸¦æ¥çš„å˜åŒ–ï¼›å¦‚æžœä½ çš„æ¸¸æˆé€‰æ‹©åƒç´ è‰ºæœ¯é£Žæ ¼ï¼Œä½ ä¹Ÿå¤šåŠä¸ä¼šæƒ³å¼€å¯è¿™ä¸ªé€‰é¡¹ã€‚ - åŒæ—¶ï¼Œåœ¨å°‘部分使用软件级别抗锯齿算法的设备或æµè§ˆå™¨ä¸Šï¼Œè¿™ä¸ªé€‰é¡¹ä¼šå¯¹æ€§èƒ½äº§ç”Ÿæ¯”较大的影å“。 - ä½ å¯ä»¥åœ¨ `cc.game.run` 之å‰è®¾ç½®è¿™ä¸ªå€¼ï¼Œå¦åˆ™å®ƒä¸ä¼šç”Ÿæ•ˆã€‚ - ä»…æ”¯æŒ Web */ - static ENABLE_WEBGL_ANTIALIAS: boolean; - /** !#en - Whether or not enable auto culling. - This feature have been removed in v2.0 new renderer due to overall performance consumption. - We have no plan currently to re-enable auto culling. - If your game have more dynamic objects, we suggest to disable auto culling. - If your game have more static objects, we suggest to enable auto culling. - !#zh - 是å¦å¼€å¯è‡ªåЍè£å‡åŠŸèƒ½ï¼Œå¼€å¯è£å‡åŠŸèƒ½å°†ä¼šæŠŠåœ¨å±å¹•外的物体从渲染队列ä¸åŽ»é™¤æŽ‰ã€‚ - 这个功能在 v2.0 的新渲染器ä¸è¢«ç§»é™¤äº†ï¼Œå› 为它在大多数游æˆä¸æ‰€å¸¦æ¥çš„æŸè€—è¦é«˜äºŽæ€§èƒ½çš„æå‡ï¼Œç›®å‰æˆ‘ä»¬æ²¡æœ‰è®¡åˆ’é‡æ–°æ”¯æŒè‡ªåЍè£å‰ªã€‚ - 如果游æˆä¸çš„动æ€ç‰©ä½“比较多的è¯ï¼Œå»ºè®®å°†æ¤é€‰é¡¹å…³é—。 - 如果游æˆä¸çš„陿€ç‰©ä½“比较多的è¯ï¼Œå»ºè®®å°†æ¤é€‰é¡¹æ‰“开。 */ - static ENABLE_CULLING: boolean; - /** !#en - Whether to clear the original image cache after uploaded a texture to GPU. If cleared, [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) will not be supported. - Normally you don't need to enable this option on the web platform, because Image object doesn't consume too much memory. - But on WeChat Game platform, the current version cache decoded data in Image object, which has high memory usage. - So we enabled this option by default on WeChat, so that we can release Image cache immediately after uploaded to GPU. - !#zh - 是å¦åœ¨å°†è´´å›¾ä¸Šä¼ 至 GPU 之åŽåˆ 除原始图片缓å˜ï¼Œåˆ 除之åŽå›¾ç‰‡å°†æ— 法进行 [动æ€åˆå›¾](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 - 在 Web å¹³å°ï¼Œä½ 通常ä¸éœ€è¦å¼€å¯è¿™ä¸ªé€‰é¡¹ï¼Œå› 为在 Web å¹³å° Image 对象所å 用的内å˜å¾ˆå°ã€‚ - ä½†æ˜¯åœ¨å¾®ä¿¡å°æ¸¸æˆå¹³å°çš„当å‰ç‰ˆæœ¬ï¼ŒImage 对象会缓å˜è§£ç åŽçš„图片数æ®ï¼Œå®ƒæ‰€å 用的内å˜ç©ºé—´å¾ˆå¤§ã€‚ - 所以我们在微信平å°é»˜è®¤å¼€å¯äº†è¿™ä¸ªé€‰é¡¹ï¼Œè¿™æ ·æˆ‘们就å¯ä»¥åœ¨ä¸Šä¼ GL 贴图之åŽç«‹å³é‡Šæ”¾ Image 对象的内å˜ï¼Œé¿å…过高的内å˜å 用。 */ - static CLEANUP_IMAGE_CACHE: boolean; - /** !#en - Whether or not show mesh wire frame. - !#zh - æ˜¯å¦æ˜¾ç¤ºç½‘æ ¼çš„çº¿æ¡†ã€‚ */ - static SHOW_MESH_WIREFRAME: boolean; - /** !#en - Whether or not show mesh normal. - !#zh - æ˜¯å¦æ˜¾ç¤ºç½‘æ ¼çš„æ³•çº¿ã€‚ */ - static SHOW_MESH_NORMAL: boolean; - /** !#en - Whether to enable multi-touch. - !#zh - 是å¦å¼€å¯å¤šç‚¹è§¦æ‘¸ */ - static ENABLE_MULTI_TOUCH: boolean; - /** References: - https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap - https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap - - !#en - Whether to use image bitmap first. - - !#zh - 是å¦ä¼˜å…ˆä½¿ç”¨ image bitmap */ - static ALLOW_IMAGE_BITMAP: boolean; - /** !#en - The image format supported by the engine defaults, and the supported formats may differ in different build platforms and device types. - Currently all platform and device support ['.webp', '.jpg', '.jpeg', '.bmp', '.png'], The iOS mobile platform also supports the PVR format。 - !#zh - 引擎默认支æŒçš„å›¾ç‰‡æ ¼å¼ï¼Œæ”¯æŒçš„æ ¼å¼å¯èƒ½åœ¨ä¸åŒçš„æž„建平å°å’Œè®¾å¤‡ç±»åž‹ä¸Šæœ‰æ‰€å·®åˆ«ã€‚ - ç›®å‰æ‰€æœ‰å¹³å°å’Œè®¾å¤‡æ”¯æŒçš„æ ¼å¼æœ‰ ['.webp', '.jpg', '.jpeg', '.bmp', '.png']. å¦å¤– Ios 手机平å°è¿˜é¢å¤–支æŒäº† PVR æ ¼å¼ã€‚ */ - static SUPPORT_TEXTURE_FORMATS: string[]; - } - /** !#en Box Collider. - !#zh 包围盒碰撞组件 */ - export class BoxCollider extends Collider implements Collider.Box { - /** !#en - Collider info in world coordinate. - !#zh - ç¢°æ’žä½“çš„ä¸–ç•Œåæ ‡ç³»ä¸‹çš„ä¿¡æ¯ã€‚ */ - world: ColliderInfo; - /** !#en Position offset - !#zh ä½ç½®åç§»é‡ */ - offset: Vec2; - /** !#en Box size - !#zh åŒ…å›´ç›’å¤§å° */ - size: Size; - } - /** !#en Circle Collider. - !#zh 圆形碰撞组件 */ - export class CircleCollider extends Collider implements Collider.Circle { - /** !#en - Collider info in world coordinate. - !#zh - ç¢°æ’žä½“çš„ä¸–ç•Œåæ ‡ç³»ä¸‹çš„ä¿¡æ¯ã€‚ */ - world: ColliderInfo; - /** !#en Position offset - !#zh ä½ç½®åç§»é‡ */ - offset: Vec2; - /** !#en Circle radius - !#zh 圆形åŠå¾„ */ - radius: number; - } - /** !#en Collider component base class. - !#zh 碰撞组件基类 */ - export class Collider extends Component { - /** !#en Tag. If a node has several collider components, you can judge which type of collider is collided according to the tag. - !#zh æ ‡ç¾ã€‚当一个节点上有多个碰撞组件时,在å‘生碰撞åŽï¼Œå¯ä»¥ä½¿ç”¨æ¤æ ‡ç¾æ¥åˆ¤æ–是节点上的哪个碰撞组件被碰撞了。 */ - tag: number; - } - /** !#en - Collider Info. - !#zh - 碰撞体信æ¯ã€‚ */ - export class ColliderInfo { - /** !#en - Collider aabb information of last frame - !#zh - 碰撞体上一帧的 aabb ä¿¡æ¯ */ - preAabb: Rect; - /** !#en - Collider aabb information of current frame - !#zh - 碰撞体当å‰å¸§çš„ aabb ä¿¡æ¯ */ - aabb: Rect; - /** !#en - Collider matrix - !#zh - ç¢°æ’žä½“çš„çŸ©é˜µä¿¡æ¯ */ - matrix: Mat4; - /** !#en - Collider radius (for CircleCollider) + Whether or not enabled tiled map auto culling. If you set the TiledMap skew or rotation, then need to manually disable this, otherwise, the rendering will be wrong. !#zh - 碰撞体的åŠå¾„(åªå¯¹ CircleCollider 有效) */ - radius: number; + 是å¦å¼€å¯ç“¦ç‰‡åœ°å›¾çš„自动è£å‡åŠŸèƒ½ã€‚ç“¦ç‰‡åœ°å›¾å¦‚æžœè®¾ç½®äº† skew, rotation æˆ–è€…é‡‡ç”¨äº†æ‘„åƒæœºçš„è¯ï¼Œéœ€è¦æ‰‹åЍ关é—,å¦åˆ™æ¸²æŸ“会出错。 */ + static ENABLE_TILEDMAP_CULLING: boolean; /** !#en - Collider position (for CircleCollider) + Boolean that indicates if the canvas contains an alpha channel, default sets to false for better performance. + Though if you want to make your canvas background transparent and show other dom elements at the background, + you can set it to true before `cc.game.run`. + Web only. !#zh - 碰撞体的ä½ç½®ï¼ˆåªå¯¹ CircleCollider 有效) */ - position: Vec2; + 用于设置 Canvas èƒŒæ™¯æ˜¯å¦æ”¯æŒ alpha 通é“,默认为 falseï¼Œè¿™æ ·å¯ä»¥æœ‰æ›´é«˜çš„æ€§èƒ½è¡¨çŽ°ã€‚ + å¦‚æžœä½ å¸Œæœ› Canvas èƒŒæ™¯æ˜¯é€æ˜Žçš„,并显示背åŽçš„å…¶ä»– DOM å…ƒç´ ï¼Œä½ å¯ä»¥åœ¨ `cc.game.run` 之å‰å°†è¿™ä¸ªå€¼è®¾ä¸º true。 + ä»…æ”¯æŒ Web */ + static ENABLE_TRANSPARENT_CANVAS: boolean; /** !#en - Collider points (for BoxCollider and PolygonCollider) + Boolean that indicates if the WebGL context is created with `antialias` option turned on, default value is false. + Set it to true could make your game graphics slightly smoother, like texture hard edges when rotated. + Whether to use this really depend on your game design and targeted platform, + device with retina display usually have good detail on graphics with or without this option, + you probably don't want antialias if your game style is pixel art based. + Also, it could have great performance impact with some browser / device using software MSAA. + You can set it to true before `cc.game.run`. + Web only. !#zh - 碰撞体的顶点信æ¯ï¼ˆåªå¯¹ BoxCollider å’Œ PolygonCollider 有效) */ - points: Vec2[]; - } - /** !#en - A simple collision manager class. - It will calculate whether the collider collides other colliders, if collides then call the callbacks. - !#zh - 一个简å•的碰撞组件管ç†ç±»ï¼Œç”¨äºŽå¤„ç†èŠ‚ç‚¹ä¹‹é—´çš„ç¢°æ’žç»„ä»¶æ˜¯å¦äº§ç”Ÿäº†ç¢°æ’žï¼Œå¹¶è°ƒç”¨ç›¸åº”回调函数。 */ - export class CollisionManager implements EventTarget { + 用于设置在创建 WebGL Context 时是å¦å¼€å¯æŠ—锯齿选项,默认值是 false。 + 将这个选项设置为 true ä¼šè®©ä½ çš„æ¸¸æˆç”»é¢ç¨ç¨å¹³æ»‘一些,比如旋转硬边贴图时的锯齿。是å¦å¼€å¯è¿™ä¸ªé€‰é¡¹å¾ˆå¤§ç¨‹åº¦ä¸Šå–å†³äºŽä½ çš„æ¸¸æˆå’Œé¢å‘的平å°ã€‚ + 在大多数拥有 retina 级别å±å¹•çš„è®¾å¤‡ä¸Šç”¨æˆ·å¾€å¾€æ— æ³•åŒºåˆ†è¿™ä¸ªé€‰é¡¹å¸¦æ¥çš„å˜åŒ–ï¼›å¦‚æžœä½ çš„æ¸¸æˆé€‰æ‹©åƒç´ è‰ºæœ¯é£Žæ ¼ï¼Œä½ ä¹Ÿå¤šåŠä¸ä¼šæƒ³å¼€å¯è¿™ä¸ªé€‰é¡¹ã€‚ + åŒæ—¶ï¼Œåœ¨å°‘部分使用软件级别抗锯齿算法的设备或æµè§ˆå™¨ä¸Šï¼Œè¿™ä¸ªé€‰é¡¹ä¼šå¯¹æ€§èƒ½äº§ç”Ÿæ¯”较大的影å“。 + ä½ å¯ä»¥åœ¨ `cc.game.run` 之å‰è®¾ç½®è¿™ä¸ªå€¼ï¼Œå¦åˆ™å®ƒä¸ä¼šç”Ÿæ•ˆã€‚ + ä»…æ”¯æŒ Web */ + static ENABLE_WEBGL_ANTIALIAS: boolean; /** !#en + Whether or not enable auto culling. + This feature have been removed in v2.0 new renderer due to overall performance consumption. + We have no plan currently to re-enable auto culling. + If your game have more dynamic objects, we suggest to disable auto culling. + If your game have more static objects, we suggest to enable auto culling. !#zh - 是å¦å¼€å¯ç¢°æ’žç®¡ç†ï¼Œé»˜è®¤ä¸ºä¸å¼€å¯ */ - enabled: boolean; + 是å¦å¼€å¯è‡ªåЍè£å‡åŠŸèƒ½ï¼Œå¼€å¯è£å‡åŠŸèƒ½å°†ä¼šæŠŠåœ¨å±å¹•外的物体从渲染队列ä¸åŽ»é™¤æŽ‰ã€‚ + 这个功能在 v2.0 的新渲染器ä¸è¢«ç§»é™¤äº†ï¼Œå› 为它在大多数游æˆä¸æ‰€å¸¦æ¥çš„æŸè€—è¦é«˜äºŽæ€§èƒ½çš„æå‡ï¼Œç›®å‰æˆ‘ä»¬æ²¡æœ‰è®¡åˆ’é‡æ–°æ”¯æŒè‡ªåЍè£å‰ªã€‚ + 如果游æˆä¸çš„动æ€ç‰©ä½“比较多的è¯ï¼Œå»ºè®®å°†æ¤é€‰é¡¹å…³é—。 + 如果游æˆä¸çš„陿€ç‰©ä½“比较多的è¯ï¼Œå»ºè®®å°†æ¤é€‰é¡¹æ‰“开。 */ + static ENABLE_CULLING: boolean; /** !#en + Whether to clear the original image cache after uploaded a texture to GPU. If cleared, [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) will not be supported. + Normally you don't need to enable this option on the web platform, because Image object doesn't consume too much memory. + But on WeChat Game platform, the current version cache decoded data in Image object, which has high memory usage. + So we enabled this option by default on WeChat, so that we can release Image cache immediately after uploaded to GPU. !#zh - 是å¦ç»˜åˆ¶ç¢°æ’žç»„件的包围盒,默认为ä¸ç»˜åˆ¶ */ - enabledDrawBoundingBox: boolean; + 是å¦åœ¨å°†è´´å›¾ä¸Šä¼ 至 GPU 之åŽåˆ 除原始图片缓å˜ï¼Œåˆ 除之åŽå›¾ç‰‡å°†æ— 法进行 [动æ€åˆå›¾](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 + 在 Web å¹³å°ï¼Œä½ 通常ä¸éœ€è¦å¼€å¯è¿™ä¸ªé€‰é¡¹ï¼Œå› 为在 Web å¹³å° Image 对象所å 用的内å˜å¾ˆå°ã€‚ + ä½†æ˜¯åœ¨å¾®ä¿¡å°æ¸¸æˆå¹³å°çš„当å‰ç‰ˆæœ¬ï¼ŒImage 对象会缓å˜è§£ç åŽçš„图片数æ®ï¼Œå®ƒæ‰€å 用的内å˜ç©ºé—´å¾ˆå¤§ã€‚ + 所以我们在微信平å°é»˜è®¤å¼€å¯äº†è¿™ä¸ªé€‰é¡¹ï¼Œè¿™æ ·æˆ‘们就å¯ä»¥åœ¨ä¸Šä¼ GL 贴图之åŽç«‹å³é‡Šæ”¾ Image 对象的内å˜ï¼Œé¿å…过高的内å˜å 用。 */ + static CLEANUP_IMAGE_CACHE: boolean; /** !#en + Whether or not show mesh wire frame. !#zh - 是å¦ç»˜åˆ¶ç¢°æ’žç»„件的形状,默认为ä¸ç»˜åˆ¶ */ - enabledDebugDraw: boolean; - /** - !#en Checks whether the EventTarget object has any callback registered for a specific type of event. - !#zh æ£€æŸ¥äº‹ä»¶ç›®æ ‡å¯¹è±¡æ˜¯å¦æœ‰ä¸ºç‰¹å®šç±»åž‹çš„事件注册的回调。 - @param type The type of event. - */ - hasEventListener(type: string): boolean; - /** - !#en - Register an callback of a specific event type on the EventTarget. - This type of event should be triggered via `emit`. + æ˜¯å¦æ˜¾ç¤ºç½‘æ ¼çš„çº¿æ¡†ã€‚ */ + static SHOW_MESH_WIREFRAME: boolean; + /** !#en + Whether or not show mesh normal. !#zh - æ³¨å†Œäº‹ä»¶ç›®æ ‡çš„ç‰¹å®šäº‹ä»¶ç±»åž‹å›žè°ƒã€‚è¿™ç§ç±»åž‹çš„事件应该被 `emit` 触å‘。 - @param type A string representing the event type to listen for. - @param callback The callback that will be invoked when the event is dispatched. - The callback is ignored if it is a duplicate (the callbacks are unique). - @param target The target (this object) to invoke the callback, can be null - - @example - ```js - eventTarget.on('fire', function () { - cc.log("fire in the hole"); - }, node); - ``` - */ - on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T; - /** - !#en - Removes the listeners previously registered with the same type, callback, target and or useCapture, - if only type is passed as parameter, all listeners registered with that type will be removed. + æ˜¯å¦æ˜¾ç¤ºç½‘æ ¼çš„æ³•çº¿ã€‚ */ + static SHOW_MESH_NORMAL: boolean; + /** !#en + Whether to enable multi-touch. !#zh - åˆ é™¤ä¹‹å‰ç”¨åŒç±»åž‹ï¼Œå›žè°ƒï¼Œç›®æ ‡æˆ– useCapture 注册的事件监å¬å™¨ï¼Œå¦‚æžœåªä¼ 递 typeï¼Œå°†ä¼šåˆ é™¤ type 类型的所有事件监å¬å™¨ã€‚ - @param type A string representing the event type being removed. - @param callback The callback to remove. - @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + 是å¦å¼€å¯å¤šç‚¹è§¦æ‘¸ */ + static ENABLE_MULTI_TOUCH: boolean; + /** References: + https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap + https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap - @example - ```js - // 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'); - ``` - */ - off(type: string, callback?: Function, target?: any): void; - /** - !#en Removes all callbacks previously registered with the same target (passed as parameter). - This is not for removing all listeners in the current event target, - and this is not for removing all listeners the target parameter have registered. - It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. - !#zh åœ¨å½“å‰ EventTarget ä¸Šåˆ é™¤æŒ‡å®šç›®æ ‡ï¼ˆtarget 傿•°ï¼‰æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ - è¿™ä¸ªå‡½æ•°æ— æ³•åˆ é™¤å½“å‰ EventTarget 的所有事件监å¬å™¨ï¼Œä¹Ÿæ— æ³•åˆ é™¤ target 傿•°æ‰€æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ - 这个函数åªèƒ½åˆ 除 target 傿•°åœ¨å½“å‰ EventTarget 上注册的所有事件监å¬å™¨ã€‚ - @param target The target to be searched for all related listeners - */ - targetOff(target: any): void; - /** !#en - Register an callback of a specific event type on the EventTarget, - the callback will remove itself after the first time it is triggered. - !#zh - æ³¨å†Œäº‹ä»¶ç›®æ ‡çš„ç‰¹å®šäº‹ä»¶ç±»åž‹å›žè°ƒï¼Œå›žè°ƒä¼šåœ¨ç¬¬ä¸€æ—¶é—´è¢«è§¦å‘åŽåˆ 除自身。 - @param type A string representing the event type to listen for. - @param callback The callback that will be invoked when the event is dispatched. - The callback is ignored if it is a duplicate (the callbacks are unique). - @param target The target (this object) to invoke the callback, can be null + Whether to use image bitmap first. If enabled, memory usage will increase. - @example - ```js - eventTarget.once('fire', function () { - cc.log("this is the callback and will be invoked only once"); - }, node); - ``` - */ - once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; - /** - !#en - Send an event with the event object. !#zh - 通过事件对象派å‘事件 - @param event event - */ - dispatchEvent(event: Event): void; - } - /** !#en Intersection helper class - !#zh 辅助类,用于测试形状与形状是å¦ç›¸äº¤ */ - export class Intersection { - /** - !#en Test line and line - !#zh 测试线段与线段是å¦ç›¸äº¤ - @param a1 The start point of the first line - @param a2 The end point of the first line - @param b1 The start point of the second line - @param b2 The end point of the second line - */ - static lineLine(a1: Vec2, a2: Vec2, b1: Vec2, b2: Vec2): boolean; - /** - !#en Test line and rect - !#zh 测试线段与矩形是å¦ç›¸äº¤ - @param a1 The start point of the line - @param a2 The end point of the line - @param b The rect - */ - static lineRect(a1: Vec2, a2: Vec2, b: Rect): boolean; - /** - !#en Test line and polygon - !#zh 测试线段与多边形是å¦ç›¸äº¤ - @param a1 The start point of the line - @param a2 The end point of the line - @param b The polygon, a set of points - */ - static linePolygon(a1: Vec2, a2: Vec2, b: Vec2[]): boolean; - /** - !#en Test rect and rect - !#zh 测试矩形与矩形是å¦ç›¸äº¤ - @param a The first rect - @param b The second rect - */ - static rectRect(a: Rect, b: Rect): boolean; - /** - !#en Test rect and polygon - !#zh 测试矩形与多边形是å¦ç›¸äº¤ - @param a The rect - @param b The polygon, a set of points - */ - static rectPolygon(a: Rect, b: Vec2[]): boolean; - /** - !#en Test polygon and polygon - !#zh 测试多边形与多边形是å¦ç›¸äº¤ - @param a The first polygon, a set of points - @param b The second polygon, a set of points - */ - static polygonPolygon(a: Vec2[], b: Vec2[]): boolean; - /** - !#en Test circle and circle - !#zh 测试圆形与圆形是å¦ç›¸äº¤ - @param a Object contains position and radius - @param b Object contains position and radius - */ - static circleCircle(a: {position: Vec2, radius: number}, b: {position: Vec2, radius: number}): boolean; - /** - !#en Test polygon and circle - !#zh 测试矩形与圆形是å¦ç›¸äº¤ - @param polygon The Polygon, a set of points - @param circle Object contains position and radius - */ - static polygonCircle(polygon: Vec2[], circle: {position: Vec2, radius: number}): boolean; - /** - !#en Test whether the point is in the polygon - !#zh 测试一个点是å¦åœ¨ä¸€ä¸ªå¤šè¾¹å½¢ä¸ - @param point The point - @param polygon The polygon, a set of points - */ - static pointInPolygon(point: Vec2, polygon: Vec2[]): boolean; - /** - !#en Calculate the distance of point to line. - !#zh 计算点到直线的è·ç¦»ã€‚如果这是一æ¡çº¿æ®µå¹¶ä¸”垂足ä¸åœ¨çº¿æ®µå†…,则会计算点到线段端点的è·ç¦»ã€‚ - @param point The point - @param start The start point of line - @param end The end point of line - @param isSegment whether this line is a segment - */ - static pointLineDistance(point: Vec2, start: Vec2, end: Vec2, isSegment: boolean): number; - } - /** !#en Polygon Collider. - !#zh 多边形碰撞组件 */ - export class PolygonCollider extends Collider implements Collider.Polygon { + 是å¦ä¼˜å…ˆä½¿ç”¨ image bitmap,å¯ç”¨ä¹‹åŽï¼Œå†…å˜å 用会å˜é«˜ */ + static ALLOW_IMAGE_BITMAP: boolean; /** !#en - Collider info in world coordinate. + Whether to use native TTF renderer which is faster but layout slightly different. + !#zh - ç¢°æ’žä½“çš„ä¸–ç•Œåæ ‡ç³»ä¸‹çš„ä¿¡æ¯ã€‚ */ - world: ColliderInfo; - /** !#en Position offset - !#zh ä½ç½®åç§»é‡ */ - offset: Vec2; - /** !#en Polygon points - !#zh 多边形顶点数组 */ - points: Vec2[]; + 是å¦ä½¿ç”¨åŽŸç”Ÿçš„æ–‡æœ¬æ¸²æŸ“æœºåˆ¶, 布局和编辑器有差异. */ + static ENABLE_NATIVE_TTF_RENDERER: boolean; + /** !#en + The image format supported by the engine defaults, and the supported formats may differ in different build platforms and device types. + Currently all platform and device support ['.webp', '.jpg', '.jpeg', '.bmp', '.png'], The iOS mobile platform also supports the PVR format。 + !#zh + 引擎默认支æŒçš„å›¾ç‰‡æ ¼å¼ï¼Œæ”¯æŒçš„æ ¼å¼å¯èƒ½åœ¨ä¸åŒçš„æž„建平å°å’Œè®¾å¤‡ç±»åž‹ä¸Šæœ‰æ‰€å·®åˆ«ã€‚ + ç›®å‰æ‰€æœ‰å¹³å°å’Œè®¾å¤‡æ”¯æŒçš„æ ¼å¼æœ‰ ['.webp', '.jpg', '.jpeg', '.bmp', '.png']. å¦å¤– Ios 手机平å°è¿˜é¢å¤–支æŒäº† PVR æ ¼å¼ã€‚ */ + static SUPPORT_TEXTURE_FORMATS: string[]; } /** !#en Class for audio data handling. !#zh 音频资æºç±»ã€‚ */ @@ -6683,7 +6618,14 @@ declare namespace cc { 通过事件对象派å‘事件 @param event event */ - dispatchEvent(event: Event): void; + dispatchEvent(event: Event): void; + /** + !#en + Destroy all callbackInfos. + !#zh + 销æ¯è®°å½•的事件 + */ + clear(): void; } /** !#en Class for BitmapFont handling. !#zh ä½å›¾å—体资æºç±»ã€‚ */ @@ -6873,330 +6815,87 @@ declare namespace cc { !#zh 设置 SpriteFrame 是å¦ç¿»è½¬ y è½´ @param flipY flipY */ - setFlipY(flipY: boolean): void; - /** - !#en Returns the rect of the sprite frame in the texture. - !#zh èŽ·å– SpriteFrame 的纹ç†çŸ©å½¢åŒºåŸŸ - */ - getRect(): Rect; - /** - !#en Sets the rect of the sprite frame in the texture. - !#zh 设置 SpriteFrame 的纹ç†çŸ©å½¢åŒºåŸŸ - @param rect rect - */ - setRect(rect: Rect): void; - /** - !#en Returns the original size of the trimmed image. - !#zh 获å–修剪å‰çš„åŽŸå§‹å¤§å° - */ - getOriginalSize(): Size; - /** - !#en Sets the original size of the trimmed image. - !#zh 设置修剪å‰çš„åŽŸå§‹å¤§å° - @param size size - */ - setOriginalSize(size: Size): void; - /** - !#en Returns the texture of the frame. - !#zh 获å–使用的纹ç†å®žä¾‹ - */ - getTexture(): Texture2D; - /** - !#en Returns the offset of the frame in the texture. - !#zh 获å–åç§»é‡ - */ - getOffset(): Vec2; - /** - !#en Sets the offset of the frame in the texture. - !#zh 设置åç§»é‡ - @param offsets offsets - */ - setOffset(offsets: Vec2): void; - /** - !#en Clone the sprite frame. - !#zh 克隆 SpriteFrame - */ - clone(): SpriteFrame; - /** - !#en Set SpriteFrame with Texture, rect, rotated, offset and originalSize.<br/> - !#zh 通过 Texture,rect,rotated,offset å’Œ originalSize 设置 SpriteFrame。 - @param texture texture - @param rect rect - @param rotated rotated - @param offset offset - @param originalSize originalSize - */ - setTexture(texture: Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size): boolean; - /** - !#en If a loading scene (or prefab) is marked as `asyncLoadAssets`, all the textures of the SpriteFrame which - associated by user's custom Components in the scene, will not preload automatically. - These textures will be load when Sprite component is going to render the SpriteFrames. - You can call this method if you want to load the texture early. - !#zh å½“åŠ è½½ä¸çš„场景或 Prefab è¢«æ ‡è®°ä¸º `asyncLoadAssets` 时,用户在场景ä¸ç”±è‡ªå®šä¹‰ç»„ä»¶å…³è”到的所有 SpriteFrame 的贴图都ä¸ä¼šè¢«æå‰åŠ è½½ã€‚ - åªæœ‰å½“ Sprite ç»„ä»¶è¦æ¸²æŸ“这些 SpriteFrame 时,æ‰ä¼šæ£€æŸ¥è´´å›¾æ˜¯å¦åŠ è½½ã€‚å¦‚æžœä½ å¸Œæœ›åŠ è½½è¿‡ç¨‹æå‰ï¼Œä½ å¯ä»¥æ‰‹å·¥è°ƒç”¨è¿™ä¸ªæ–¹æ³•。 - - @example - ```js - if (spriteFrame.textureLoaded()) { - this._onSpriteFrameLoaded(); - } - else { - spriteFrame.once('load', this._onSpriteFrameLoaded, this); - spriteFrame.ensureLoadTexture(); - } - ``` - */ - ensureLoadTexture(): void; - /** - !#en - If you do not need to use the SpriteFrame temporarily, you can call this method so that its texture could be garbage collected. Then when you need to render the SpriteFrame, you should call `ensureLoadTexture` manually to reload texture. - !#zh - å½“ä½ æš‚æ—¶ä¸å†ä½¿ç”¨è¿™ä¸ª SpriteFrame 时,å¯ä»¥è°ƒç”¨è¿™ä¸ªæ–¹æ³•æ¥ä¿è¯å¼•用的贴图对象能被 GC。然åŽå½“ä½ è¦æ¸²æŸ“ SpriteFrame æ—¶ï¼Œä½ éœ€è¦æ‰‹åŠ¨è°ƒç”¨ `ensureLoadTexture` æ¥é‡æ–°åŠ è½½è´´å›¾ã€‚ - */ - clearTexture(): void; - /** - !#en Checks whether the EventTarget object has any callback registered for a specific type of event. - !#zh æ£€æŸ¥äº‹ä»¶ç›®æ ‡å¯¹è±¡æ˜¯å¦æœ‰ä¸ºç‰¹å®šç±»åž‹çš„事件注册的回调。 - @param type The type of event. - */ - hasEventListener(type: string): boolean; - /** - !#en - Register an callback of a specific event type on the EventTarget. - This type of event should be triggered via `emit`. - !#zh - æ³¨å†Œäº‹ä»¶ç›®æ ‡çš„ç‰¹å®šäº‹ä»¶ç±»åž‹å›žè°ƒã€‚è¿™ç§ç±»åž‹çš„事件应该被 `emit` 触å‘。 - @param type A string representing the event type to listen for. - @param callback The callback that will be invoked when the event is dispatched. - The callback is ignored if it is a duplicate (the callbacks are unique). - @param target The target (this object) to invoke the callback, can be null - - @example - ```js - eventTarget.on('fire', function () { - cc.log("fire in the hole"); - }, node); - ``` - */ - on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T; - /** - !#en - Removes the listeners previously registered with the same type, callback, target and or useCapture, - if only type is passed as parameter, all listeners registered with that type will be removed. - !#zh - åˆ é™¤ä¹‹å‰ç”¨åŒç±»åž‹ï¼Œå›žè°ƒï¼Œç›®æ ‡æˆ– useCapture 注册的事件监å¬å™¨ï¼Œå¦‚æžœåªä¼ 递 typeï¼Œå°†ä¼šåˆ é™¤ type 类型的所有事件监å¬å™¨ã€‚ - @param type A string representing the event type being removed. - @param callback The callback to remove. - @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed - - @example - ```js - // 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'); - ``` - */ - off(type: string, callback?: Function, target?: any): void; - /** - !#en Removes all callbacks previously registered with the same target (passed as parameter). - This is not for removing all listeners in the current event target, - and this is not for removing all listeners the target parameter have registered. - It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. - !#zh åœ¨å½“å‰ EventTarget ä¸Šåˆ é™¤æŒ‡å®šç›®æ ‡ï¼ˆtarget 傿•°ï¼‰æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ - è¿™ä¸ªå‡½æ•°æ— æ³•åˆ é™¤å½“å‰ EventTarget 的所有事件监å¬å™¨ï¼Œä¹Ÿæ— æ³•åˆ é™¤ target 傿•°æ‰€æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ - 这个函数åªèƒ½åˆ 除 target 傿•°åœ¨å½“å‰ EventTarget 上注册的所有事件监å¬å™¨ã€‚ - @param target The target to be searched for all related listeners - */ - targetOff(target: any): void; - /** - !#en - Register an callback of a specific event type on the EventTarget, - the callback will remove itself after the first time it is triggered. - !#zh - æ³¨å†Œäº‹ä»¶ç›®æ ‡çš„ç‰¹å®šäº‹ä»¶ç±»åž‹å›žè°ƒï¼Œå›žè°ƒä¼šåœ¨ç¬¬ä¸€æ—¶é—´è¢«è§¦å‘åŽåˆ 除自身。 - @param type A string representing the event type to listen for. - @param callback The callback that will be invoked when the event is dispatched. - The callback is ignored if it is a duplicate (the callbacks are unique). - @param target The target (this object) to invoke the callback, can be null - - @example - ```js - eventTarget.once('fire', function () { - cc.log("this is the callback and will be invoked only once"); - }, node); - ``` - */ - once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; - /** - !#en - Send an event with the event object. - !#zh - 通过事件对象派å‘事件 - @param event event - */ - dispatchEvent(event: Event): void; - } - /** !#en Class for TTFFont handling. - !#zh TTF å—体资æºç±»ã€‚ */ - export class TTFFont extends Font { - } - /** !#en Class for text file. - !#zh 文本资æºç±»ã€‚ */ - export class TextAsset extends Asset { - /** The text contents of the resource. */ - text: string; - } - /** This class allows to easily create OpenGL or Canvas 2D textures from images or raw data. */ - export class Texture2D extends Asset implements EventTarget { - /** !#en Sets whether generate mipmaps for the texture - !#zh 是å¦ä¸ºçº¹ç†è®¾ç½®ç”Ÿæˆ mipmaps。 */ - genMipmaps: boolean; - /** !#en - Sets whether texture can be packed into texture atlas. - If need use texture uv in custom Effect, please sets packable to false. - !#zh - è®¾ç½®çº¹ç†æ˜¯å¦å…许å‚与åˆå›¾ã€‚ - 如果需è¦åœ¨è‡ªå®šä¹‰ Effect ä¸ä½¿ç”¨çº¹ç† UV,需è¦ç¦æ¢è¯¥é€‰é¡¹ã€‚ */ - packable: boolean; - /** !#en - Whether the texture is loaded or not - !#zh - 贴图是å¦å·²ç»æˆåŠŸåŠ è½½ */ - loaded: boolean; - /** !#en - Texture width in pixel - !#zh - 贴图åƒç´ 宽度 */ - width: number; - /** !#en - Texture height in pixel - !#zh - 贴图åƒç´ 高度 */ - height: number; - /** - !#en - Get renderer texture implementation object - extended from render.Texture2D - !#zh 返回渲染器内部贴图对象 - */ - getImpl(): void; - /** - Update texture options, not available in Canvas render mode. - image, format, premultiplyAlpha can not be updated in native. - @param options options - */ - update(options: {image: DOMImageElement; genMipmaps: boolean; format: Texture2D.PixelFormat; minFilter: Texture2D.Filter; magFilter: Texture2D.Filter; wrapS: WrapMode; wrapT: WrapMode; premultiplyAlpha: boolean; }): void; - /** - !#en - Init with HTML element. - !#zh 用 HTML Image 或 Canvas 对象åˆå§‹åŒ–贴图。 - @param element element - - @example - ```js - var img = new Image(); - img.src = dataURL; - texture.initWithElement(img); - ``` - */ - initWithElement(element: HTMLImageElement|HTMLCanvasElement): void; - /** - !#en - Intializes with texture data in ArrayBufferView. - !#zh 使用一个å˜å‚¨åœ¨ ArrayBufferView ä¸çš„å›¾åƒæ•°æ®ï¼ˆraw data)åˆå§‹åŒ–æ•°æ®ã€‚ - @param data data - @param pixelFormat pixelFormat - @param pixelsWidth pixelsWidth - @param pixelsHeight pixelsHeight - */ - initWithData(data: ArrayBufferView, pixelFormat: number, pixelsWidth: number, pixelsHeight: number): boolean; + setFlipY(flipY: boolean): void; /** - !#en - HTMLElement Object getter, available only on web.<br/> - Note: texture is packed into texture atlas by default<br/> - you should set texture.packable as false before getting Html element object. - !#zh 获å–当å‰è´´å›¾å¯¹åº”çš„ HTML Image 或 Canvas 对象,åªåœ¨ Web å¹³å°ä¸‹æœ‰æ•ˆã€‚<br/> - 注æ„:<br/> - texture 默认å‚与动æ€åˆå›¾ï¼Œå¦‚果需è¦èŽ·å–到æ£ç¡®çš„ Html å…ƒç´ å¯¹è±¡ï¼Œéœ€è¦å…ˆè®¾ç½® texture.packable 为 false + !#en Returns the rect of the sprite frame in the texture. + !#zh èŽ·å– SpriteFrame 的纹ç†çŸ©å½¢åŒºåŸŸ */ - getHtmlElementObj(): HTMLImageElement; + getRect(): Rect; /** - !#en - Destory this texture and immediately release its video memory. (Inherit from cc.Object.destroy)<br> - After destroy, this object is not usable anymore. - You can use cc.isValid(obj) to check whether the object is destroyed before accessing it. - !#zh - 销æ¯è¯¥è´´å›¾ï¼Œå¹¶ç«‹å³é‡Šæ”¾å®ƒå¯¹åº”的显å˜ã€‚(继承自 cc.Object.destroy)<br/> - 销æ¯åŽï¼Œè¯¥å¯¹è±¡ä¸å†å¯ç”¨ã€‚您å¯ä»¥åœ¨è®¿é—®å¯¹è±¡ä¹‹å‰ä½¿ç”¨ cc.isValid(obj) æ¥æ£€æŸ¥å¯¹è±¡æ˜¯å¦å·²è¢«é”€æ¯ã€‚ + !#en Sets the rect of the sprite frame in the texture. + !#zh 设置 SpriteFrame 的纹ç†çŸ©å½¢åŒºåŸŸ + @param rect rect */ - destroy(): boolean; + setRect(rect: Rect): void; /** - !#en - Pixel format of the texture. - !#zh 获å–纹ç†çš„åƒç´ æ ¼å¼ã€‚ + !#en Returns the original size of the trimmed image. + !#zh 获å–修剪å‰çš„åŽŸå§‹å¤§å° */ - getPixelFormat(): number; + getOriginalSize(): Size; /** - !#en - Whether or not the texture has their Alpha premultiplied. - !#zh 检查纹ç†åœ¨ä¸Šä¼ GPU 时预乘选项是å¦å¼€å¯ã€‚ + !#en Sets the original size of the trimmed image. + !#zh 设置修剪å‰çš„åŽŸå§‹å¤§å° + @param size size */ - hasPremultipliedAlpha(): boolean; + setOriginalSize(size: Size): void; /** - !#en - Handler of texture loaded event. - Since v2.0, you don't need to invoke this function, it will be invoked automatically after texture loaded. - !#zh è´´å›¾åŠ è½½äº‹ä»¶å¤„ç†å™¨ã€‚v2.0 之åŽä½ å°†ä¸åœ¨éœ€è¦æ‰‹åŠ¨æ‰§è¡Œè¿™ä¸ªå‡½æ•°ï¼Œå®ƒä¼šåœ¨è´´å›¾åŠ è½½æˆåŠŸä¹‹åŽè‡ªåŠ¨æ‰§è¡Œã€‚ - @param premultiplied premultiplied + !#en Returns the texture of the frame. + !#zh 获å–使用的纹ç†å®žä¾‹ */ - handleLoadedTexture(premultiplied?: boolean): void; + getTexture(): Texture2D; /** - !#en - Description of cc.Texture2D. - !#zh cc.Texture2D æè¿°ã€‚ + !#en Returns the offset of the frame in the texture. + !#zh 获å–åç§»é‡ */ - description(): string; + getOffset(): Vec2; /** - !#en - Release texture, please use destroy instead. - !#zh 释放纹ç†ï¼Œè¯·ä½¿ç”¨ destroy 替代。 + !#en Sets the offset of the frame in the texture. + !#zh 设置åç§»é‡ + @param offsets offsets */ - releaseTexture(): void; + setOffset(offsets: Vec2): void; /** - !#en Sets the wrap s and wrap t options. <br/> - If the texture size is NPOT (non power of 2), then in can only use gl.CLAMP_TO_EDGE in gl.TEXTURE_WRAP_{S,T}. - !#zh 设置纹ç†åŒ…装模å¼ã€‚ - 若纹ç†è´´å›¾å°ºå¯¸æ˜¯ NPOT(non power of 2),则åªèƒ½ä½¿ç”¨ Texture2D.WrapMode.CLAMP_TO_EDGE。 - @param wrapS wrapS - @param wrapT wrapT + !#en Clone the sprite frame. + !#zh 克隆 SpriteFrame */ - setTexParameters(wrapS: Texture2D.WrapMode, wrapT: Texture2D.WrapMode): void; + clone(): SpriteFrame; /** - !#en Sets the minFilter and magFilter options - !#zh 设置纹ç†è´´å›¾ç¼©å°å’Œæ”¾å¤§è¿‡æ»¤å™¨ç®—法选项。 - @param minFilter minFilter - @param magFilter magFilter + !#en Set SpriteFrame with Texture, rect, rotated, offset and originalSize.<br/> + !#zh 通过 Texture,rect,rotated,offset å’Œ originalSize 设置 SpriteFrame。 + @param texture texture + @param rect rect + @param rotated rotated + @param offset offset + @param originalSize originalSize */ - setFilters(minFilter: Texture2D.Filter, magFilter: Texture2D.Filter): void; + setTexture(texture: Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size): boolean; /** - !#en - Sets the flipY options - !#zh 设置贴图的纵å‘翻转选项。 - @param flipY flipY + !#en If a loading scene (or prefab) is marked as `asyncLoadAssets`, all the textures of the SpriteFrame which + associated by user's custom Components in the scene, will not preload automatically. + These textures will be load when Sprite component is going to render the SpriteFrames. + You can call this method if you want to load the texture early. + !#zh å½“åŠ è½½ä¸çš„场景或 Prefab è¢«æ ‡è®°ä¸º `asyncLoadAssets` 时,用户在场景ä¸ç”±è‡ªå®šä¹‰ç»„ä»¶å…³è”到的所有 SpriteFrame 的贴图都ä¸ä¼šè¢«æå‰åŠ è½½ã€‚ + åªæœ‰å½“ Sprite ç»„ä»¶è¦æ¸²æŸ“这些 SpriteFrame 时,æ‰ä¼šæ£€æŸ¥è´´å›¾æ˜¯å¦åŠ è½½ã€‚å¦‚æžœä½ å¸Œæœ›åŠ è½½è¿‡ç¨‹æå‰ï¼Œä½ å¯ä»¥æ‰‹å·¥è°ƒç”¨è¿™ä¸ªæ–¹æ³•。 + + @example + ```js + if (spriteFrame.textureLoaded()) { + this._onSpriteFrameLoaded(); + } + else { + spriteFrame.once('load', this._onSpriteFrameLoaded, this); + spriteFrame.ensureLoadTexture(); + } + ``` */ - setFlipY(flipY: boolean): void; + ensureLoadTexture(): void; /** !#en - Sets the premultiply alpha options - !#zh 设置贴图的预乘选项。 - @param premultiply premultiply + If you do not need to use the SpriteFrame temporarily, you can call this method so that its texture could be garbage collected. Then when you need to render the SpriteFrame, you should call `ensureLoadTexture` manually to reload texture. + !#zh + å½“ä½ æš‚æ—¶ä¸å†ä½¿ç”¨è¿™ä¸ª SpriteFrame 时,å¯ä»¥è°ƒç”¨è¿™ä¸ªæ–¹æ³•æ¥ä¿è¯å¼•用的贴图对象能被 GC。然åŽå½“ä½ è¦æ¸²æŸ“ SpriteFrame æ—¶ï¼Œä½ éœ€è¦æ‰‹åŠ¨è°ƒç”¨ `ensureLoadTexture` æ¥é‡æ–°åŠ è½½è´´å›¾ã€‚ */ - setPremultiplyAlpha(premultiply: boolean): void; + clearTexture(): void; /** !#en Checks whether the EventTarget object has any callback registered for a specific type of event. !#zh æ£€æŸ¥äº‹ä»¶ç›®æ ‡å¯¹è±¡æ˜¯å¦æœ‰ä¸ºç‰¹å®šç±»åž‹çš„事件注册的回调。 @@ -7282,342 +6981,356 @@ declare namespace cc { 通过事件对象派å‘事件 @param event event */ - dispatchEvent(event: Event): void; - } - /** !#en - Camera is usefull when making reel game or other games which need scroll screen. - Using camera will be more efficient than moving node to scroll screen. - Camera - !#zh - æ‘„åƒæœºåœ¨åˆ¶ä½œå·è½´æˆ–是其他需è¦ç§»åЍå±å¹•çš„æ¸¸æˆæ—¶æ¯”è¾ƒæœ‰ç”¨ï¼Œä½¿ç”¨æ‘„åƒæœºå°†ä¼šæ¯”移动节点æ¥ç§»åЍå±å¹•æ›´åŠ é«˜æ•ˆã€‚ */ - export class Camera extends Component { - /** !#en - The camera zoom ratio, only support 2D camera. - !#zh - æ‘„åƒæœºç¼©æ”¾æ¯”率, åªæ”¯æŒ 2D camera。 */ - zoomRatio: number; - /** !#en - Field of view. The width of the Camera’s view angle, measured in degrees along the local Y axis. - !#zh - å†³å®šæ‘„åƒæœºè§†è§’çš„å®½åº¦ï¼Œå½“æ‘„åƒæœºå¤„于é€è§†æŠ•影模å¼ä¸‹è¿™ä¸ªå±žæ€§æ‰ä¼šç”Ÿæ•ˆã€‚ */ - fov: number; - /** !#en - The viewport size of the Camera when set to orthographic projection. - !#zh - æ‘„åƒæœºåœ¨æ£äº¤æŠ•影模å¼ä¸‹çš„视窗大å°ã€‚ */ - orthoSize: number; - /** !#en - The near clipping plane. - !#zh - æ‘„åƒæœºçš„近剪è£é¢ã€‚ */ - nearClip: number; - /** !#en - The far clipping plane. - !#zh - æ‘„åƒæœºçš„远剪è£é¢ã€‚ */ - farClip: number; - /** !#en - Is the camera orthographic (true) or perspective (false)? - !#zh - è®¾ç½®æ‘„åƒæœºçš„æŠ•å½±æ¨¡å¼æ˜¯æ£äº¤è¿˜æ˜¯é€è§†æ¨¡å¼ã€‚ */ - ortho: boolean; - /** !#en - Four values (0 ~ 1) that indicate where on the screen this camera view will be drawn. - !#zh - å†³å®šæ‘„åƒæœºç»˜åˆ¶åœ¨å±å¹•上哪个ä½ç½®ï¼Œå€¼ä¸ºï¼ˆ0 ~ 1)。 */ - rect: Rect; - /** !#en - This is used to render parts of the scene selectively. - !#zh - å†³å®šæ‘„åƒæœºä¼šæ¸²æŸ“场景的哪一部分。 */ - cullingMask: number; - /** !#en - Determining what to clear when camera rendering. - !#zh - å†³å®šæ‘„åƒæœºæ¸²æŸ“时会清除哪些状æ€ã€‚ */ - clearFlags: Camera.ClearFlags; - /** !#en - The color with which the screen will be cleared. - !#zh - æ‘„åƒæœºç”¨äºŽæ¸…除å±å¹•的背景色。 */ - backgroundColor: Color; - /** !#en - Camera's depth in the camera rendering order. Cameras with higher depth are rendered after cameras with lower depth. + dispatchEvent(event: Event): void; + /** + !#en + Destroy all callbackInfos. !#zh - æ‘„åƒæœºæ·±åº¦ã€‚ç”¨äºŽå†³å®šæ‘„åƒæœºçš„æ¸²æŸ“顺åºï¼Œå€¼è¶Šå¤§æ¸²æŸ“在越上层。 */ - depth: number; + 销æ¯è®°å½•的事件 + */ + clear(): void; + } + /** !#en Class for TTFFont handling. + !#zh TTF å—体资æºç±»ã€‚ */ + export class TTFFont extends Font { + } + /** !#en Class for text file. + !#zh 文本资æºç±»ã€‚ */ + export class TextAsset extends Asset { + /** The text contents of the resource. */ + text: string; + } + /** This class allows to easily create OpenGL or Canvas 2D textures from images or raw data. */ + export class Texture2D extends Asset implements EventTarget { + /** !#en Sets whether generate mipmaps for the texture + !#zh 是å¦ä¸ºçº¹ç†è®¾ç½®ç”Ÿæˆ mipmaps。 */ + genMipmaps: boolean; /** !#en - Destination render texture. - Usually cameras render directly to screen, but for some effects it is useful to make a camera render into a texture. + Sets whether texture can be packed into texture atlas. + If need use texture uv in custom Effect, please sets packable to false. !#zh - æ‘„åƒæœºæ¸²æŸ“çš„ç›®æ ‡ RenderTexture。 - ä¸€èˆ¬æ‘„åƒæœºä¼šç›´æŽ¥æ¸²æŸ“到å±å¹•上,但是有一些效果å¯ä»¥ä½¿ç”¨æ‘„åƒæœºæ¸²æŸ“到 RenderTexture 上å†å¯¹ RenderTexture è¿›è¡Œå¤„ç†æ¥å®žçŽ°ã€‚ */ - targetTexture: RenderTexture; + è®¾ç½®çº¹ç†æ˜¯å¦å…许å‚与åˆå›¾ã€‚ + 如果需è¦åœ¨è‡ªå®šä¹‰ Effect ä¸ä½¿ç”¨çº¹ç† UV,需è¦ç¦æ¢è¯¥é€‰é¡¹ã€‚ */ + packable: boolean; /** !#en - Sets the camera's render stages. + Whether the texture is loaded or not !#zh - è®¾ç½®æ‘„åƒæœºæ¸²æŸ“的阶段 */ - renderStages: number; - /** !#en Whether auto align camera viewport to screen - !#zh 是å¦è‡ªåŠ¨å°†æ‘„åƒæœºçš„视å£å¯¹å‡†å±å¹• */ - alignWithScreen: boolean; + 贴图是å¦å·²ç»æˆåŠŸåŠ è½½ */ + loaded: boolean; /** !#en - The primary camera in the scene. Returns the rear most rendered camera, which is the camera with the lowest depth. + Texture width in pixel !#zh - 当å‰åœºæ™¯ä¸æ¿€æ´»çš„ä¸»æ‘„åƒæœºã€‚将会返回渲染在å±å¹•最底层,也就是 depth 最å°çš„æ‘„åƒæœºã€‚ */ - static main: Camera; + 贴图åƒç´ 宽度 */ + width: number; /** !#en - All enabled cameras. - !#zh - 当剿¿€æ´»çš„æ‰€æœ‰æ‘„åƒæœºã€‚ */ - static cameras: Camera[]; - /** - !#en - Get the first camera which the node belong to. - !#zh - 获å–èŠ‚ç‚¹æ‰€åœ¨çš„ç¬¬ä¸€ä¸ªæ‘„åƒæœºã€‚ - @param node node - */ - static findCamera(node: Node): Camera; - /** - !#en - Get the screen to world matrix, only support 2D camera which alignWithScreen is true. - !#zh - 获å–å±å¹•åæ ‡ç³»åˆ°ä¸–ç•Œåæ ‡ç³»çš„矩阵,åªé€‚用于 alignWithScreen 为 true çš„ 2D æ‘„åƒæœºã€‚ - @param out the matrix to receive the result - */ - getScreenToWorldMatrix2D(out: Mat4): Mat4; - /** - !#en - Get the world to camera matrix, only support 2D camera which alignWithScreen is true. - !#zh - 获å–ä¸–ç•Œåæ ‡ç³»åˆ°æ‘„åƒæœºåæ ‡ç³»çš„çŸ©é˜µï¼Œåªé€‚用于 alignWithScreen 为 true çš„ 2D æ‘„åƒæœºã€‚ - @param out the matrix to receive the result - */ - getWorldToScreenMatrix2D(out: Mat4): Mat4; - /** - !#en - Convert point from screen to world. + Texture height in pixel !#zh - å°†åæ ‡ä»Žå±å¹•åæ ‡ç³»è½¬æ¢åˆ°ä¸–ç•Œåæ ‡ç³»ã€‚ - @param screenPosition screenPosition - @param out out - */ - getScreenToWorldPoint(screenPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3; + 贴图åƒç´ 高度 */ + height: number; /** !#en - Convert point from world to screen. - !#zh - å°†åæ ‡ä»Žä¸–ç•Œåæ ‡ç³»è½¬åŒ–到å±å¹•åæ ‡ç³»ã€‚ - @param worldPosition worldPosition - @param out out + Get renderer texture implementation object + extended from render.Texture2D + !#zh 返回渲染器内部贴图对象 */ - getWorldToScreenPoint(worldPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3; + getImpl(): void; /** - !#en - Get a ray from screen position - !#zh - 从å±å¹•åæ ‡èŽ·å–一æ¡å°„线 - @param screenPos screenPos + Update texture options, not available in Canvas render mode. + image, format, premultiplyAlpha can not be updated in native. + @param options options */ - getRay(screenPos: Vec2): geomUtils.Ray; + update(options: {image: DOMImageElement; genMipmaps: boolean; format: Texture2D.PixelFormat; minFilter: Texture2D.Filter; magFilter: Texture2D.Filter; wrapS: WrapMode; wrapT: WrapMode; premultiplyAlpha: boolean; }): void; /** !#en - Check whether the node is in the camera. - !#zh - 检测节点是å¦è¢«æ¤æ‘„åƒæœºå½±å“ - @param node the node which need to check + Init with HTML element. + !#zh 用 HTML Image 或 Canvas 对象åˆå§‹åŒ–贴图。 + @param element element + + @example + ```js + var img = new Image(); + img.src = dataURL; + texture.initWithElement(img); + ``` */ - containsNode(node: Node): boolean; + initWithElement(element: HTMLImageElement|HTMLCanvasElement): void; /** !#en - Render the camera manually. - !#zh - æ‰‹åŠ¨æ¸²æŸ“æ‘„åƒæœºã€‚ - @param rootNode rootNode + Intializes with texture data in ArrayBufferView. + !#zh 使用一个å˜å‚¨åœ¨ ArrayBufferView ä¸çš„å›¾åƒæ•°æ®ï¼ˆraw data)åˆå§‹åŒ–æ•°æ®ã€‚ + @param data data + @param pixelFormat pixelFormat + @param pixelsWidth pixelsWidth + @param pixelsHeight pixelsHeight */ - render(rootNode?: Node): void; + initWithData(data: ArrayBufferView, pixelFormat: number, pixelsWidth: number, pixelsHeight: number): boolean; /** !#en - Returns the matrix that transform the node's (local) space coordinates into the camera's space coordinates. - !#zh - è¿”å›žä¸€ä¸ªå°†èŠ‚ç‚¹åæ ‡ç³»è½¬æ¢åˆ°æ‘„åƒæœºåæ ‡ç³»ä¸‹çš„çŸ©é˜µ - @param node the node which should transform + HTMLElement Object getter, available only on web.<br/> + Note: texture is packed into texture atlas by default<br/> + you should set texture.packable as false before getting Html element object. + !#zh 获å–当å‰è´´å›¾å¯¹åº”çš„ HTML Image 或 Canvas 对象,åªåœ¨ Web å¹³å°ä¸‹æœ‰æ•ˆã€‚<br/> + 注æ„:<br/> + texture 默认å‚与动æ€åˆå›¾ï¼Œå¦‚果需è¦èŽ·å–到æ£ç¡®çš„ Html å…ƒç´ å¯¹è±¡ï¼Œéœ€è¦å…ˆè®¾ç½® texture.packable 为 false */ - getNodeToCameraTransform(node: Node): AffineTransform; + getHtmlElementObj(): HTMLImageElement; /** !#en - Conver a camera coordinates point to world coordinates. + Destory this texture and immediately release its video memory. (Inherit from cc.Object.destroy)<br> + After destroy, this object is not usable anymore. + You can use cc.isValid(obj) to check whether the object is destroyed before accessing it. !#zh - å°†ä¸€ä¸ªæ‘„åƒæœºåæ ‡ç³»ä¸‹çš„ç‚¹è½¬æ¢åˆ°ä¸–ç•Œåæ ‡ç³»ä¸‹ã€‚ - @param point the point which should transform - @param out the point to receive the result + 销æ¯è¯¥è´´å›¾ï¼Œå¹¶ç«‹å³é‡Šæ”¾å®ƒå¯¹åº”的显å˜ã€‚(继承自 cc.Object.destroy)<br/> + 销æ¯åŽï¼Œè¯¥å¯¹è±¡ä¸å†å¯ç”¨ã€‚您å¯ä»¥åœ¨è®¿é—®å¯¹è±¡ä¹‹å‰ä½¿ç”¨ cc.isValid(obj) æ¥æ£€æŸ¥å¯¹è±¡æ˜¯å¦å·²è¢«é”€æ¯ã€‚ */ - getCameraToWorldPoint(point: Vec2, out?: Vec2): Vec2; + destroy(): boolean; /** !#en - Conver a world coordinates point to camera coordinates. - !#zh - å°†ä¸€ä¸ªä¸–ç•Œåæ ‡ç³»ä¸‹çš„点转æ¢åˆ°æ‘„åƒæœºåæ ‡ç³»ä¸‹ã€‚ - @param point point - @param out the point to receive the result + Pixel format of the texture. + !#zh 获å–纹ç†çš„åƒç´ æ ¼å¼ã€‚ */ - getWorldToCameraPoint(point: Vec2, out?: Vec2): Vec2; + getPixelFormat(): number; /** !#en - Get the camera to world matrix - !#zh - èŽ·å–æ‘„åƒæœºåæ ‡ç³»åˆ°ä¸–ç•Œåæ ‡ç³»çš„矩阵 - @param out the matrix to receive the result + Whether or not the texture has their Alpha premultiplied. + !#zh 检查纹ç†åœ¨ä¸Šä¼ GPU 时预乘选项是å¦å¼€å¯ã€‚ */ - getCameraToWorldMatrix(out: Mat4): Mat4; + hasPremultipliedAlpha(): boolean; /** !#en - Get the world to camera matrix - !#zh - 获å–ä¸–ç•Œåæ ‡ç³»åˆ°æ‘„åƒæœºåæ ‡ç³»çš„çŸ©é˜µ - @param out the matrix to receive the result - */ - getWorldToCameraMatrix(out: Mat4): Mat4; - } - /** !#en The touch event class - !#zh å°è£…了触摸相关的信æ¯ã€‚ */ - export class Touch { - /** - !#en Returns the current touch location in OpenGL coordinates.〠- !#zh 获å–当å‰è§¦ç‚¹ä½ç½®ã€‚ - */ - getLocation(): Vec2; - /** - !#en Returns X axis location value. - !#zh 获å–当å‰è§¦ç‚¹ X è½´ä½ç½®ã€‚ - */ - getLocationX(): number; - /** - !#en Returns Y axis location value. - !#zh 获å–当å‰è§¦ç‚¹ Y è½´ä½ç½®ã€‚ - */ - getLocationY(): number; - /** - !#en Returns the previous touch location in OpenGL coordinates. - !#zh 获å–触点在上一次事件时的ä½ç½®å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 + Handler of texture loaded event. + Since v2.0, you don't need to invoke this function, it will be invoked automatically after texture loaded. + !#zh è´´å›¾åŠ è½½äº‹ä»¶å¤„ç†å™¨ã€‚v2.0 之åŽä½ å°†ä¸åœ¨éœ€è¦æ‰‹åŠ¨æ‰§è¡Œè¿™ä¸ªå‡½æ•°ï¼Œå®ƒä¼šåœ¨è´´å›¾åŠ è½½æˆåŠŸä¹‹åŽè‡ªåŠ¨æ‰§è¡Œã€‚ + @param premultiplied premultiplied */ - getPreviousLocation(): Vec2; + handleLoadedTexture(premultiplied?: boolean): void; /** - !#en Returns the start touch location in OpenGL coordinates. - !#zh 获å–触点è½ä¸‹æ—¶çš„ä½ç½®å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 + !#en + Description of cc.Texture2D. + !#zh cc.Texture2D æè¿°ã€‚ */ - getStartLocation(): Vec2; + description(): string; /** - !#en Returns the delta distance from the previous touche to the current one in screen coordinates. - !#zh 获å–触点è·ç¦»ä¸Šä¸€æ¬¡äº‹ä»¶ç§»åŠ¨çš„è·ç¦»å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 + !#en + Release texture, please use destroy instead. + !#zh 释放纹ç†ï¼Œè¯·ä½¿ç”¨ destroy 替代。 */ - getDelta(): Vec2; + releaseTexture(): void; /** - !#en Returns the current touch location in screen coordinates. - !#zh 获å–当å‰äº‹ä»¶åœ¨æ¸¸æˆçª—å£å†…çš„åæ ‡ä½ç½®å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 + !#en Sets the wrap s and wrap t options. <br/> + If the texture size is NPOT (non power of 2), then in can only use gl.CLAMP_TO_EDGE in gl.TEXTURE_WRAP_{S,T}. + !#zh 设置纹ç†åŒ…装模å¼ã€‚ + 若纹ç†è´´å›¾å°ºå¯¸æ˜¯ NPOT(non power of 2),则åªèƒ½ä½¿ç”¨ Texture2D.WrapMode.CLAMP_TO_EDGE。 + @param wrapS wrapS + @param wrapT wrapT */ - getLocationInView(): Vec2; + setWrapMode(wrapS: Texture2D.WrapMode, wrapT: Texture2D.WrapMode): void; /** - !#en Returns the previous touch location in screen coordinates. - !#zh 获å–触点在上一次事件时在游æˆçª—å£ä¸çš„ä½ç½®å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 + !#en Sets the minFilter and magFilter options + !#zh 设置纹ç†è´´å›¾ç¼©å°å’Œæ”¾å¤§è¿‡æ»¤å™¨ç®—法选项。 + @param minFilter minFilter + @param magFilter magFilter */ - getPreviousLocationInView(): Vec2; + setFilters(minFilter: Texture2D.Filter, magFilter: Texture2D.Filter): void; /** - !#en Returns the start touch location in screen coordinates. - !#zh 获å–触点è½ä¸‹æ—¶åœ¨æ¸¸æˆçª—å£ä¸çš„ä½ç½®å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 + !#en + Sets the flipY options + !#zh 设置贴图的纵å‘翻转选项。 + @param flipY flipY */ - getStartLocationInView(): Vec2; + setFlipY(flipY: boolean): void; /** - !#en Returns the id of cc.Touch. - !#zh è§¦ç‚¹çš„æ ‡è¯† ID,å¯ä»¥ç”¨æ¥åœ¨å¤šç‚¹è§¦æ‘¸ä¸è·Ÿè¸ªè§¦ç‚¹ã€‚ + !#en + Sets the premultiply alpha options + !#zh 设置贴图的预乘选项。 + @param premultiply premultiply */ - getID(): number; + setPremultiplyAlpha(premultiply: boolean): void; /** - !#en Sets information to touch. - !#zh 设置触摸相关的信æ¯ã€‚用于监控触摸事件。 - @param id id - @param x x - @param y y + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh æ£€æŸ¥äº‹ä»¶ç›®æ ‡å¯¹è±¡æ˜¯å¦æœ‰ä¸ºç‰¹å®šç±»åž‹çš„事件注册的回调。 + @param type The type of event. */ - setTouchInfo(id: number, x: number, y: number): void; - } - /** !#en Mesh Asset. - !#zh ç½‘æ ¼èµ„æºã€‚ */ - export class Mesh extends Asset implements EventTarget { - /** !#en Get ir set the sub meshes. - !#zh 设置或者获å–åç½‘æ ¼ã€‚ */ - subMeshes: InputAssembler[]; + hasEventListener(type: string): boolean; /** !#en - Init vertex buffer according to the vertex format. + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. !#zh - æ ¹æ®é¡¶ç‚¹æ ¼å¼åˆå§‹åŒ–顶点内å˜ã€‚ - @param vertexFormat vertex format - @param vertexCount how much vertex should be create in this buffer. - @param dynamic whether or not to use dynamic buffer. - @param index index + æ³¨å†Œäº‹ä»¶ç›®æ ‡çš„ç‰¹å®šäº‹ä»¶ç±»åž‹å›žè°ƒã€‚è¿™ç§ç±»åž‹çš„事件应该被 `emit` 触å‘。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` */ - init(vertexFormat: gfx.VertexFormat, vertexCount: number, dynamic?: boolean, index?: boolean): void; + on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T; /** !#en - Set the vertex values. + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. !#zh - è®¾ç½®é¡¶ç‚¹æ•°æ® - @param name the attribute name, e.g. gfx.ATTR_POSITION - @param values the vertex values + åˆ é™¤ä¹‹å‰ç”¨åŒç±»åž‹ï¼Œå›žè°ƒï¼Œç›®æ ‡æˆ– useCapture 注册的事件监å¬å™¨ï¼Œå¦‚æžœåªä¼ 递 typeï¼Œå°†ä¼šåˆ é™¤ type 类型的所有事件监å¬å™¨ã€‚ + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // 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'); + ``` */ - setVertices(name: string, values: Vec2[]|Vec3[]|Color[]|number[]|Uint8Array|Float32Array): void; + off(type: string, callback?: Function, target?: any): void; /** - !#en - Set the sub mesh indices. - !#zh - 设置åç½‘æ ¼ç´¢å¼•ã€‚ - @param indices the sub mesh indices. - @param index sub mesh index. - @param dynamic whether or not to use dynamic buffer. + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh åœ¨å½“å‰ EventTarget ä¸Šåˆ é™¤æŒ‡å®šç›®æ ‡ï¼ˆtarget 傿•°ï¼‰æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ + è¿™ä¸ªå‡½æ•°æ— æ³•åˆ é™¤å½“å‰ EventTarget 的所有事件监å¬å™¨ï¼Œä¹Ÿæ— æ³•åˆ é™¤ target 傿•°æ‰€æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ + 这个函数åªèƒ½åˆ 除 target 傿•°åœ¨å½“å‰ EventTarget 上注册的所有事件监å¬å™¨ã€‚ + @param target The target to be searched for all related listeners */ - setIndices(indices: number[]|Uint16Array|Uint8Array, index?: number, dynamic?: boolean): void; + targetOff(target: any): void; /** !#en - Set the sub mesh primitive type. + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. !#zh - 设置åç½‘æ ¼ç»˜åˆ¶çº¿æ¡çš„æ–¹å¼ã€‚ - @param type type - @param index index + æ³¨å†Œäº‹ä»¶ç›®æ ‡çš„ç‰¹å®šäº‹ä»¶ç±»åž‹å›žè°ƒï¼Œå›žè°ƒä¼šåœ¨ç¬¬ä¸€æ—¶é—´è¢«è§¦å‘åŽåˆ 除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` */ - setPrimitiveType(type: number, index: number): void; + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; /** !#en - Clear the buffer data. + Send an event with the event object. !#zh - æ¸…é™¤ç½‘æ ¼åˆ›å»ºçš„å†…å˜æ•°æ®ã€‚ - */ - clear(): void; - /** - !#en Set mesh bounding box - !#zh è®¾ç½®ç½‘æ ¼çš„åŒ…å›´ç›’ - @param min min - @param max max - */ - setBoundingBox(min: Vec3, max: Vec3): void; - /** - !#en Read the specified attributes of the subgrid into the target buffer. - !#zh 读å–åç½‘æ ¼çš„æŒ‡å®šå±žæ€§åˆ°ç›®æ ‡ç¼“å†²åŒºä¸ã€‚ - @param primitiveIndex The subgrid index. - @param attributeName attribute name. - @param buffer The target buffer. - @param stride The byte interval between adjacent attributes in the target buffer. - @param offset The offset of the first attribute in the target buffer. + 通过事件对象派å‘事件 + @param event event */ - copyAttribute(primitiveIndex: number, attributeName: string, buffer: ArrayBuffer, stride: number, offset: number): boolean; + dispatchEvent(event: Event): void; /** - !#en Read the index data of the subgrid into the target array. - !#zh 读å–åç½‘æ ¼çš„ç´¢å¼•æ•°æ®åˆ°ç›®æ ‡æ•°ç»„ä¸ã€‚ - @param primitiveIndex The subgrid index. - @param outputArray The target array. + !#en + Destroy all callbackInfos. + !#zh + 销æ¯è®°å½•的事件 */ - copyIndices(primitiveIndex: number, outputArray: DataView): boolean; + clear(): void; + } + /** !#en Box Collider. + !#zh 包围盒碰撞组件 */ + export class BoxCollider extends Collider implements Collider.Box { + /** !#en + Collider info in world coordinate. + !#zh + ç¢°æ’žä½“çš„ä¸–ç•Œåæ ‡ç³»ä¸‹çš„ä¿¡æ¯ã€‚ */ + world: ColliderInfo; + /** !#en Position offset + !#zh ä½ç½®åç§»é‡ */ + offset: Vec2; + /** !#en Box size + !#zh åŒ…å›´ç›’å¤§å° */ + size: Size; + } + /** !#en Circle Collider. + !#zh 圆形碰撞组件 */ + export class CircleCollider extends Collider implements Collider.Circle { + /** !#en + Collider info in world coordinate. + !#zh + ç¢°æ’žä½“çš„ä¸–ç•Œåæ ‡ç³»ä¸‹çš„ä¿¡æ¯ã€‚ */ + world: ColliderInfo; + /** !#en Position offset + !#zh ä½ç½®åç§»é‡ */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形åŠå¾„ */ + radius: number; + } + /** !#en Collider component base class. + !#zh 碰撞组件基类 */ + export class Collider extends Component { + /** !#en Tag. If a node has several collider components, you can judge which type of collider is collided according to the tag. + !#zh æ ‡ç¾ã€‚当一个节点上有多个碰撞组件时,在å‘生碰撞åŽï¼Œå¯ä»¥ä½¿ç”¨æ¤æ ‡ç¾æ¥åˆ¤æ–是节点上的哪个碰撞组件被碰撞了。 */ + tag: number; + } + /** !#en + Collider Info. + !#zh + 碰撞体信æ¯ã€‚ */ + export class ColliderInfo { + /** !#en + Collider aabb information of last frame + !#zh + 碰撞体上一帧的 aabb ä¿¡æ¯ */ + preAabb: Rect; + /** !#en + Collider aabb information of current frame + !#zh + 碰撞体当å‰å¸§çš„ aabb ä¿¡æ¯ */ + aabb: Rect; + /** !#en + Collider matrix + !#zh + ç¢°æ’žä½“çš„çŸ©é˜µä¿¡æ¯ */ + matrix: Mat4; + /** !#en + Collider radius (for CircleCollider) + !#zh + 碰撞体的åŠå¾„(åªå¯¹ CircleCollider 有效) */ + radius: number; + /** !#en + Collider position (for CircleCollider) + !#zh + 碰撞体的ä½ç½®ï¼ˆåªå¯¹ CircleCollider 有效) */ + position: Vec2; + /** !#en + Collider points (for BoxCollider and PolygonCollider) + !#zh + 碰撞体的顶点信æ¯ï¼ˆåªå¯¹ BoxCollider å’Œ PolygonCollider 有效) */ + points: Vec2[]; + } + /** !#en + A simple collision manager class. + It will calculate whether the collider collides other colliders, if collides then call the callbacks. + !#zh + 一个简å•的碰撞组件管ç†ç±»ï¼Œç”¨äºŽå¤„ç†èŠ‚ç‚¹ä¹‹é—´çš„ç¢°æ’žç»„ä»¶æ˜¯å¦äº§ç”Ÿäº†ç¢°æ’žï¼Œå¹¶è°ƒç”¨ç›¸åº”回调函数。 */ + export class CollisionManager implements EventTarget { + /** !#en + !#zh + 是å¦å¼€å¯ç¢°æ’žç®¡ç†ï¼Œé»˜è®¤ä¸ºä¸å¼€å¯ */ + enabled: boolean; + /** !#en + !#zh + 是å¦ç»˜åˆ¶ç¢°æ’žç»„件的包围盒,默认为ä¸ç»˜åˆ¶ */ + enabledDrawBoundingBox: boolean; + /** !#en + !#zh + 是å¦ç»˜åˆ¶ç¢°æ’žç»„件的形状,默认为ä¸ç»˜åˆ¶ */ + enabledDebugDraw: boolean; /** !#en Checks whether the EventTarget object has any callback registered for a specific type of event. !#zh æ£€æŸ¥äº‹ä»¶ç›®æ ‡å¯¹è±¡æ˜¯å¦æœ‰ä¸ºç‰¹å®šç±»åž‹çš„事件注册的回调。 @@ -7703,240 +7416,243 @@ declare namespace cc { 通过事件对象派å‘事件 @param event event */ - dispatchEvent(event: Event): void; - } - /** !#en - Mesh Renderer Component - !#zh - ç½‘æ ¼æ¸²æŸ“ç»„ä»¶ */ - export class MeshRenderer extends RenderComponent { - /** !#en - The mesh which the renderer uses. - !#zh - è®¾ç½®ä½¿ç”¨çš„ç½‘æ ¼ */ - mesh: Mesh; - /** !#en - Whether the mesh should receive shadows. - !#zh - ç½‘æ ¼æ˜¯å¦æŽ¥å—å…‰æºæŠ•å°„çš„é˜´å½± */ - receiveShadows: boolean; - /** !#en - Shadow Casting Mode - !#zh - ç½‘æ ¼æŠ•å°„é˜´å½±çš„æ¨¡å¼ */ - shadowCastingMode: MeshRenderer.ShadowCastingMode; - /** !#en - Enable auto merge mesh, only support when mesh's VertexFormat, PrimitiveType, materials are all the same + dispatchEvent(event: Event): void; + /** + !#en + Destroy all callbackInfos. !#zh - å¼€å¯è‡ªåЍåˆå¹¶ mesh åŠŸèƒ½ï¼Œåªæœ‰åœ¨ç½‘æ ¼çš„ é¡¶ç‚¹æ ¼å¼ï¼ŒPrimitiveType, 使用的æè´¨ 都一致的情况下æ‰ä¼šæœ‰æ•ˆ */ - enableAutoBatch: boolean; + 销æ¯è®°å½•的事件 + */ + clear(): void; } - /** The class BufferRange denotes a range of the buffer. */ - export class BufferRange { - /** The offset of the range. */ - offset: number; - /** The length of the range. */ - length: number; + /** !#en Intersection helper class + !#zh 辅助类,用于测试形状与形状是å¦ç›¸äº¤ */ + export class Intersection { + /** + !#en Test line and line + !#zh 测试线段与线段是å¦ç›¸äº¤ + @param a1 The start point of the first line + @param a2 The end point of the first line + @param b1 The start point of the second line + @param b2 The end point of the second line + */ + static lineLine(a1: Vec2, a2: Vec2, b1: Vec2, b2: Vec2): boolean; + /** + !#en Test line and rect + !#zh 测试线段与矩形是å¦ç›¸äº¤ + @param a1 The start point of the line + @param a2 The end point of the line + @param b The rect + */ + static lineRect(a1: Vec2, a2: Vec2, b: Rect): boolean; + /** + !#en Test line and polygon + !#zh 测试线段与多边形是å¦ç›¸äº¤ + @param a1 The start point of the line + @param a2 The end point of the line + @param b The polygon, a set of points + */ + static linePolygon(a1: Vec2, a2: Vec2, b: Vec2[]): boolean; + /** + !#en Test rect and rect + !#zh 测试矩形与矩形是å¦ç›¸äº¤ + @param a The first rect + @param b The second rect + */ + static rectRect(a: Rect, b: Rect): boolean; + /** + !#en Test rect and polygon + !#zh 测试矩形与多边形是å¦ç›¸äº¤ + @param a The rect + @param b The polygon, a set of points + */ + static rectPolygon(a: Rect, b: Vec2[]): boolean; + /** + !#en Test polygon and polygon + !#zh 测试多边形与多边形是å¦ç›¸äº¤ + @param a The first polygon, a set of points + @param b The second polygon, a set of points + */ + static polygonPolygon(a: Vec2[], b: Vec2[]): boolean; + /** + !#en Test circle and circle + !#zh 测试圆形与圆形是å¦ç›¸äº¤ + @param a Object contains position and radius + @param b Object contains position and radius + */ + static circleCircle(a: {position: Vec2, radius: number}, b: {position: Vec2, radius: number}): boolean; + /** + !#en Test polygon and circle + !#zh 测试矩形与圆形是å¦ç›¸äº¤ + @param polygon The Polygon, a set of points + @param circle Object contains position and radius + */ + static polygonCircle(polygon: Vec2[], circle: {position: Vec2, radius: number}): boolean; + /** + !#en Test whether the point is in the polygon + !#zh 测试一个点是å¦åœ¨ä¸€ä¸ªå¤šè¾¹å½¢ä¸ + @param point The point + @param polygon The polygon, a set of points + */ + static pointInPolygon(point: Vec2, polygon: Vec2[]): boolean; + /** + !#en Calculate the distance of point to line. + !#zh 计算点到直线的è·ç¦»ã€‚如果这是一æ¡çº¿æ®µå¹¶ä¸”垂足ä¸åœ¨çº¿æ®µå†…,则会计算点到线段端点的è·ç¦»ã€‚ + @param point The point + @param start The start point of line + @param end The end point of line + @param isSegment whether this line is a segment + */ + static pointLineDistance(point: Vec2, start: Vec2, end: Vec2, isSegment: boolean): number; } - /** undefined */ - export class VertexFormat { - /** The data range of this bundle. - This range of data is essentially mapped to a GPU vertex buffer. */ - data: BufferRange; - /** The attribute formats. */ - formats: VertexFormat; - /** The vertex bundle that the primitive use. */ - vertexBundleIndices: number[]; - /** The data range of the primitive. - This range of data is essentially mapped to a GPU indices buffer. */ - data: BufferRange; - /** The type of this primitive's indices. */ - indexUnit: number; - /** The primitive's topology. */ - topology: number; + /** !#en Polygon Collider. + !#zh 多边形碰撞组件 */ + export class PolygonCollider extends Collider implements Collider.Polygon { + /** !#en + Collider info in world coordinate. + !#zh + ç¢°æ’žä½“çš„ä¸–ç•Œåæ ‡ç³»ä¸‹çš„ä¿¡æ¯ã€‚ */ + world: ColliderInfo; + /** !#en Position offset + !#zh ä½ç½®åç§»é‡ */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: Vec2[]; } - /** !#en The animation component is used to play back animations. - - Animation provide several events to register: - - play : Emit when begin playing animation - - stop : Emit when stop playing animation - - pause : Emit when pause animation - - resume : Emit when resume animation - - lastframe : If animation repeat count is larger than 1, emit when animation play to the last frame - - finished : Emit when finish playing animation - - !#zh Animation ç»„ä»¶ç”¨äºŽæ’æ”¾åŠ¨ç”»ã€‚ - - Animation æä¾›äº†ä¸€ç³»åˆ—坿³¨å†Œçš„事件: - - play : å¼€å§‹æ’æ”¾æ—¶ - - stop : åœæ¢æ’放时 - - pause : æš‚åœæ’放时 - - resume : æ¢å¤æ’放时 - - lastframe : å‡å¦‚动画循环次数大于 1ï¼Œå½“åŠ¨ç”»æ’æ”¾åˆ°æœ€åŽä¸€å¸§æ—¶ - - finished : åŠ¨ç”»æ’æ”¾å®Œæˆæ—¶ */ - export class Animation extends Component implements EventTarget { - /** !#en Animation will play the default clip when start game. - !#zh åœ¨å‹¾é€‰è‡ªåŠ¨æ’æ”¾æˆ–调用 play() æ—¶é»˜è®¤æ’æ”¾çš„动画剪辑。 */ - defaultClip: AnimationClip; - /** !#en Current played clip. - !#zh 当剿’放的动画剪辑。 */ - currentClip: AnimationClip; - /** !#en Whether the animation should auto play the default clip when start game. - !#zh 是å¦åœ¨è¿è¡Œæ¸¸æˆåŽè‡ªåŠ¨æ’æ”¾é»˜è®¤åŠ¨ç”»å‰ªè¾‘ã€‚ */ - playOnLoad: boolean; + /** !#en The touch event class + !#zh å°è£…了触摸相关的信æ¯ã€‚ */ + export class Touch { /** - !#en Get all the clips used in this animation. - !#zh 获å–动画组件上的所有动画剪辑。 + !#en Returns the current touch location in OpenGL coordinates.〠+ !#zh 获å–当å‰è§¦ç‚¹ä½ç½®ã€‚ */ - getClips(): AnimationClip[]; + getLocation(): Vec2; /** - !#en Plays an animation and stop other animations. - !#zh æ’æ”¾æŒ‡å®šçš„åŠ¨ç”»ï¼Œå¹¶ä¸”åœæ¢å½“剿£åœ¨æ’æ”¾åŠ¨ç”»ã€‚å¦‚æžœæ²¡æœ‰æŒ‡å®šåŠ¨ç”»ï¼Œåˆ™æ’æ”¾é»˜è®¤åŠ¨ç”»ã€‚ - @param name The name of animation to play. If no name is supplied then the default animation will be played. - @param startTime play an animation from startTime - - @example - ```js - var animCtrl = this.node.getComponent(cc.Animation); - animCtrl.play("linear"); - ``` + !#en Returns X axis location value. + !#zh 获å–当å‰è§¦ç‚¹ X è½´ä½ç½®ã€‚ */ - play(name?: string, startTime?: number): AnimationState; + getLocationX(): number; /** - !#en - Plays an additive animation, it will not stop other animations. - If there are other animations playing, then will play several animations at the same time. - !#zh æ’æ”¾æŒ‡å®šçš„动画(将ä¸ä¼šåœæ¢å½“剿’æ”¾çš„åŠ¨ç”»ï¼‰ã€‚å¦‚æžœæ²¡æœ‰æŒ‡å®šåŠ¨ç”»ï¼Œåˆ™æ’æ”¾é»˜è®¤åŠ¨ç”»ã€‚ - @param name The name of animation to play. If no name is supplied then the default animation will be played. - @param startTime play an animation from startTime - - @example - ```js - // linear_1 and linear_2 at the same time playing. - var animCtrl = this.node.getComponent(cc.Animation); - animCtrl.playAdditive("linear_1"); - animCtrl.playAdditive("linear_2"); - ``` + !#en Returns Y axis location value. + !#zh 获å–当å‰è§¦ç‚¹ Y è½´ä½ç½®ã€‚ */ - playAdditive(name?: string, startTime?: number): AnimationState; + getLocationY(): number; /** - !#en Stops an animation named name. If no name is supplied then stops all playing animations that were started with this Animation. <br/> - Stopping an animation also Rewinds it to the Start. - !#zh åœæ¢æŒ‡å®šçš„动画。如果没有指定åå—ï¼Œåˆ™åœæ¢å½“剿£åœ¨æ’放的动画。 - @param name The animation to stop, if not supplied then stops all playing animations. + !#en Returns the previous touch location in OpenGL coordinates. + !#zh 获å–触点在上一次事件时的ä½ç½®å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 */ - stop(name?: string): void; + getPreviousLocation(): Vec2; /** - !#en Pauses an animation named name. If no name is supplied then pauses all playing animations that were started with this Animation. - !#zh æš‚åœå½“剿ˆ–者指定的动画。如果没有指定åå—,则暂åœå½“剿£åœ¨æ’放的动画。 - @param name The animation to pauses, if not supplied then pauses all playing animations. + !#en Returns the start touch location in OpenGL coordinates. + !#zh 获å–触点è½ä¸‹æ—¶çš„ä½ç½®å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 */ - pause(name?: string): void; + getStartLocation(): Vec2; /** - !#en Resumes an animation named name. If no name is supplied then resumes all paused animations that were started with this Animation. - !#zh 釿–°æ’放指定的动画,如果没有指定åå—ï¼Œåˆ™é‡æ–°æ’æ”¾å½“å‰æ£åœ¨æ’放的动画。 - @param name The animation to resumes, if not supplied then resumes all paused animations. + !#en Returns the delta distance from the previous touche to the current one in screen coordinates. + !#zh 获å–触点è·ç¦»ä¸Šä¸€æ¬¡äº‹ä»¶ç§»åŠ¨çš„è·ç¦»å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 */ - resume(name?: string): void; + getDelta(): Vec2; /** - !#en Make an animation named name go to the specified time. If no name is supplied then make all animations go to the specified time. - !#zh è®¾ç½®æŒ‡å®šåŠ¨ç”»çš„æ’æ”¾æ—¶é—´ã€‚如果没有指定åå—ï¼Œåˆ™è®¾ç½®å½“å‰æ’æ”¾åŠ¨ç”»çš„æ’æ”¾æ—¶é—´ã€‚ - @param time The time to go to - @param name Specified animation name, if not supplied then make all animations go to the time. + !#en Returns the current touch location in screen coordinates. + !#zh 获å–当å‰äº‹ä»¶åœ¨æ¸¸æˆçª—å£å†…çš„åæ ‡ä½ç½®å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 */ - setCurrentTime(time?: number, name?: string): void; + getLocationInView(): Vec2; /** - !#en Returns the animation state named name. If no animation with the specified name, the function will return null. - !#zh 获å–当剿ˆ–者指定的动画状æ€ï¼Œå¦‚果未找到指定动画剪辑则返回 null。 - @param name name + !#en Returns the previous touch location in screen coordinates. + !#zh 获å–触点在上一次事件时在游æˆçª—å£ä¸çš„ä½ç½®å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 */ - getAnimationState(name: string): AnimationState; + getPreviousLocationInView(): Vec2; /** - !#en Adds a clip to the animation with name newName. If a clip with that name already exists it will be replaced with the new clip. - !#zh æ·»åŠ åŠ¨ç”»å‰ªè¾‘ï¼Œå¹¶ä¸”å¯ä»¥é‡æ–°è®¾ç½®è¯¥åŠ¨ç”»å‰ªè¾‘çš„å称。 - @param clip the clip to add - @param newName newName + !#en Returns the start touch location in screen coordinates. + !#zh 获å–触点è½ä¸‹æ—¶åœ¨æ¸¸æˆçª—å£ä¸çš„ä½ç½®å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 */ - addClip(clip: AnimationClip, newName?: string): AnimationState; + getStartLocationInView(): Vec2; /** - !#en - Remove clip from the animation list. This will remove the clip and any animation states based on it. - If there are animation states depand on the clip are playing or clip is defaultClip, it will not delete the clip. - But if force is true, then will always remove the clip and any animation states based on it. If clip is defaultClip, defaultClip will be reset to null - !#zh - 从动画列表ä¸ç§»é™¤æŒ‡å®šçš„动画剪辑,<br/> - 如果ä¾èµ–于 clip çš„ AnimationState æ£åœ¨æ’放或者 clip 是 defaultClip çš„è¯ï¼Œé»˜è®¤æ˜¯ä¸ä¼šåˆ 除 clip 的。 - 但是如果 force 傿•°ä¸º trueï¼Œåˆ™ä¼šå¼ºåˆ¶åœæ¢è¯¥åŠ¨ç”»ï¼Œç„¶åŽç§»é™¤è¯¥åŠ¨ç”»å‰ªè¾‘å’Œç›¸å…³çš„åŠ¨ç”»ã€‚è¿™æ—¶å€™å¦‚æžœ clip 是 defaultClip,defaultClip 将会被é‡ç½®ä¸º null。 - @param clip clip - @param force If force is true, then will always remove the clip and any animation states based on it. + !#en Returns the id of cc.Touch. + !#zh è§¦ç‚¹çš„æ ‡è¯† ID,å¯ä»¥ç”¨æ¥åœ¨å¤šç‚¹è§¦æ‘¸ä¸è·Ÿè¸ªè§¦ç‚¹ã€‚ */ - removeClip(clip: AnimationClip, force?: boolean): void; + getID(): number; /** - !#en - Samples animations at the current state.<br/> - This is useful when you explicitly want to set up some animation state, and sample it once. - !#zh 对指定或当å‰åŠ¨ç”»è¿›è¡Œé‡‡æ ·ã€‚ä½ å¯ä»¥æ‰‹åŠ¨å°†åŠ¨ç”»è®¾ç½®åˆ°æŸä¸€ä¸ªçжæ€ï¼Œç„¶åŽé‡‡æ ·ä¸€æ¬¡ã€‚ - @param name name + !#en Sets information to touch. + !#zh 设置触摸相关的信æ¯ã€‚用于监控触摸事件。 + @param id id + @param x x + @param y y */ - sample(name: string): void; + setTouchInfo(id: number, x: number, y: number): void; + } + /** !#en + EventTarget is an object to which an event is dispatched when something has occurred. + Entity are the most common event targets, but other objects can be event targets too. + + Event targets are an important part of the Fireball event model. + The event target serves as the focal point for how events flow through the scene graph. + When an event such as a mouse click or a keypress occurs, Fireball dispatches an event object + into the event flow from the root of the hierarchy. The event object then makes its way through + the scene graph until it reaches the event target, at which point it begins its return trip through + the scene graph. This round-trip journey to the event target is conceptually divided into three phases: + - The capture phase comprises the journey from the root to the last node before the event target's node + - The target phase comprises only the event target node + - The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the tree + See also: http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + + Event targets can implement the following methods: + - _getCapturingTargets + - _getBubblingTargets + + !#zh + äº‹ä»¶ç›®æ ‡æ˜¯äº‹ä»¶è§¦å‘æ—¶ï¼Œåˆ†æ´¾çš„事件对象,Node 是最常è§çš„äº‹ä»¶ç›®æ ‡ï¼Œ + 但是其他对象也å¯ä»¥æ˜¯äº‹ä»¶ç›®æ ‡ã€‚<br/> */ + export class EventTarget extends CallbacksInvoker { + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh æ£€æŸ¥äº‹ä»¶ç›®æ ‡å¯¹è±¡æ˜¯å¦æœ‰ä¸ºç‰¹å®šç±»åž‹çš„事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; /** !#en - Register animation event callback. - The event arguments will provide the AnimationState which emit the event. - When play an animation, will auto register the event callback to the AnimationState, and unregister the event callback from the AnimationState when animation stopped. + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. !#zh - 注册动画事件回调。 - 回调的事件里将会附上å‘é€äº‹ä»¶çš„ AnimationState。 - å½“æ’æ”¾ä¸€ä¸ªåŠ¨ç”»æ—¶ï¼Œä¼šè‡ªåŠ¨å°†äº‹ä»¶æ³¨å†Œåˆ°å¯¹åº”çš„ AnimationState ä¸Šï¼Œåœæ¢æ’放时会将事件从这个 AnimationState ä¸Šå–æ¶ˆæ³¨å†Œã€‚ + æ³¨å†Œäº‹ä»¶ç›®æ ‡çš„ç‰¹å®šäº‹ä»¶ç±»åž‹å›žè°ƒã€‚è¿™ç§ç±»åž‹çš„事件应该被 `emit` 触å‘。 @param type A string representing the event type to listen for. @param callback The callback that will be invoked when the event is dispatched. The callback is ignored if it is a duplicate (the callbacks are unique). - @param state state @param target The target (this object) to invoke the callback, can be null - @param useCapture When set to true, the capture argument prevents callback - from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. - When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. - Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. @example ```js - onPlay: function (type, state) { - // callback - } - - // register event to all animation - animation.on('play', this.onPlay, this); + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); ``` */ - on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; - on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; - on(type: string, callback: (type: string, state: cc.AnimationState) => void, target?: any, useCapture?: boolean): (type: string, state: cc.AnimationState) => void; + on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T; /** !#en - Unregister animation event callback. + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. !#zh - å–æ¶ˆæ³¨å†ŒåŠ¨ç”»äº‹ä»¶å›žè°ƒã€‚ + åˆ é™¤ä¹‹å‰ç”¨åŒç±»åž‹ï¼Œå›žè°ƒï¼Œç›®æ ‡æˆ– useCapture 注册的事件监å¬å™¨ï¼Œå¦‚æžœåªä¼ 递 typeï¼Œå°†ä¼šåˆ é™¤ type 类型的所有事件监å¬å™¨ã€‚ @param type A string representing the event type being removed. @param callback The callback to remove. @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed - @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. - If not specified, useCapture defaults to false. If a callback was registered twice, - one with capture and one without, each must be removed separately. Removal of a capturing callback - does not affect a non-capturing version of the same listener, and vice versa. @example ```js - // unregister event to all animation - animation.off('play', this.onPlay, this); - ``` - */ - off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; - /** - !#en Checks whether the EventTarget object has any callback registered for a specific type of event. - !#zh æ£€æŸ¥äº‹ä»¶ç›®æ ‡å¯¹è±¡æ˜¯å¦æœ‰ä¸ºç‰¹å®šç±»åž‹çš„事件注册的回调。 - @param type The type of event. + // 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'); + ``` */ - hasEventListener(type: string): boolean; + off(type: string, callback?: Function, target?: any): void; /** !#en Removes all callbacks previously registered with the same target (passed as parameter). This is not for removing all listeners in the current event target, @@ -7974,1273 +7690,1079 @@ declare namespace cc { 通过事件对象派å‘事件 @param event event */ - dispatchEvent(event: Event): void; - } - /** !#en Audio Source. - !#zh 音频æºç»„件,能对音频剪辑。 */ - export class AudioSource extends Component { - /** !#en - Is the audio source playing (Read Only). <br/> - Note: isPlaying is not supported for Native platforms. - !#zh - è¯¥éŸ³é¢‘å‰ªè¾‘æ˜¯å¦æ£æ’放(åªè¯»ï¼‰ã€‚<br/> - 注æ„:Native å¹³å°æš‚æ—¶ä¸æ”¯æŒ isPlaying。 */ - isPlaying: boolean; - /** !#en The clip of the audio source to play. - !#zh è¦æ’放的音频剪辑。 */ - clip: AudioClip; - /** !#en The volume of the audio source. - !#zh 音频æºçš„音é‡ï¼ˆ0.0 ~ 1.0)。 */ - volume: number; - /** !#en Is the audio source mute? - !#zh 是å¦é™éŸ³éŸ³é¢‘æºã€‚Mute 是设置音é‡ä¸º 0ï¼Œå–æ¶ˆé™éŸ³æ˜¯æ¢å¤åŽŸæ¥çš„音é‡ã€‚ */ - mute: boolean; - /** !#en Is the audio source looping? - !#zh éŸ³é¢‘æºæ˜¯å¦å¾ªçŽ¯æ’æ”¾ï¼Ÿ */ - loop: boolean; - /** !#en If set to true, the audio source will automatically start playing on onEnable. - !#zh 如果设置为 true,音频æºå°†åœ¨ onEnable æ—¶è‡ªåŠ¨æ’æ”¾ã€‚ */ - playOnLoad: boolean; - /** - !#en Plays the clip. - !#zh æ’æ”¾éŸ³é¢‘剪辑。 - */ - play(): void; - /** - !#en Stops the clip. - !#zh åœæ¢å½“å‰éŸ³é¢‘剪辑。 - */ - stop(): void; - /** - !#en Pause the clip. - !#zh æš‚åœå½“å‰éŸ³é¢‘剪辑。 - */ - pause(): void; - /** - !#en Resume the clip. - !#zh æ¢å¤æ’放。 - */ - resume(): void; - /** - !#en Rewind playing music. - !#zh ä»Žå¤´å¼€å§‹æ’æ”¾ã€‚ - */ - rewind(): void; - /** - !#en Get current time - !#zh 获å–当å‰çš„æ’æ”¾æ—¶é—´ - */ - getCurrentTime(): number; - /** - !#en Set current time - !#zh 设置当å‰çš„æ’æ”¾æ—¶é—´ - @param time time - */ - setCurrentTime(time: number): number; - /** - !#en Get audio duration - !#zh 获å–当å‰éŸ³é¢‘的长度 - */ - getDuration(): number; - } - /** !#en - This component will block all input events (mouse and touch) within the bounding box of the node, preventing the input from penetrating into the underlying node, typically for the background of the top UI.<br> - This component does not have any API interface and can be added directly to the scene to take effect. - !#zh - 该组件将拦截所属节点 bounding box å†…çš„æ‰€æœ‰è¾“å…¥äº‹ä»¶ï¼ˆé¼ æ ‡å’Œè§¦æ‘¸ï¼‰ï¼Œé˜²æ¢è¾“入穿é€åˆ°ä¸‹å±‚节点,一般用于上层 UI 的背景。<br> - 该组件没有任何 API 接å£ï¼Œç›´æŽ¥æ·»åŠ åˆ°åœºæ™¯å³å¯ç”Ÿæ•ˆã€‚ */ - export class BlockInputEvents extends Component { - } - /** !#en - Button has 4 Transition types<br/> - When Button state changed:<br/> - If Transition type is Button.Transition.NONE, Button will do nothing<br/> - If Transition type is Button.Transition.COLOR, Button will change target's color<br/> - If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite<br/> - If Transition type is Button.Transition.SCALE, Button will change target node's scale<br/> - - Button will trigger 5 events:<br/> - Button.EVENT_TOUCH_DOWN<br/> - Button.EVENT_TOUCH_UP<br/> - Button.EVENT_HOVER_IN<br/> - Button.EVENT_HOVER_MOVE<br/> - Button.EVENT_HOVER_OUT<br/> - User can get the current clicked node with 'event.target' from event object which is passed as parameter in the callback function of click event. - - !#zh - 按钮组件。å¯ä»¥è¢«æŒ‰ä¸‹ï¼Œæˆ–者点击。 - - 按钮å¯ä»¥é€šè¿‡ä¿®æ”¹ Transition æ¥è®¾ç½®æŒ‰é’®çжæ€è¿‡æ¸¡çš„æ–¹å¼ï¼š - - - Button.Transition.NONE // ä¸åšä»»ä½•过渡 - - Button.Transition.COLOR // 进行颜色之间过渡 - - Button.Transition.SPRITE // 进行精çµä¹‹é—´è¿‡æ¸¡ - - Button.Transition.SCALE // 进行缩放过渡 - - 按钮å¯ä»¥ç»‘定事件(但是必须è¦åœ¨æŒ‰é’®çš„ Node 上æ‰èƒ½ç»‘定事件):<br/> - 以下事件å¯ä»¥åœ¨å…¨å¹³å°ä¸Šéƒ½è§¦å‘: - - - cc.Node.EventType.TOUCH_START // 按下时事件 - - cc.Node.EventType.TOUCH_Move // 按ä½ç§»åЍåŽäº‹ä»¶ - - cc.Node.EventType.TOUCH_END // æŒ‰ä¸‹åŽæ¾å¼€åŽäº‹ä»¶ - - cc.Node.EventType.TOUCH_CANCEL // æŒ‰ä¸‹å–æ¶ˆäº‹ä»¶ - - 以下事件åªåœ¨ PC å¹³å°ä¸Šè§¦å‘: - - - cc.Node.EventType.MOUSE_DOWN // é¼ æ ‡æŒ‰ä¸‹æ—¶äº‹ä»¶ - - cc.Node.EventType.MOUSE_MOVE // é¼ æ ‡æŒ‰ä½ç§»åЍåŽäº‹ä»¶ - - cc.Node.EventType.MOUSE_ENTER // é¼ æ ‡è¿›å…¥ç›®æ ‡äº‹ä»¶ - - cc.Node.EventType.MOUSE_LEAVE // é¼ æ ‡ç¦»å¼€ç›®æ ‡äº‹ä»¶ - - cc.Node.EventType.MOUSE_UP // é¼ æ ‡æ¾å¼€äº‹ä»¶ - - cc.Node.EventType.MOUSE_WHEEL // é¼ æ ‡æ»šè½®äº‹ä»¶ - - 用户å¯ä»¥é€šè¿‡èŽ·å– __点击事件__ å›žè°ƒå‡½æ•°çš„å‚æ•° event çš„ target 属性获å–当å‰ç‚¹å‡»å¯¹è±¡ã€‚ */ - export class Button extends Component implements GraySpriteState { - /** !#en - Whether the Button is disabled. - If true, the Button will trigger event and do transition. - !#zh - 按钮事件是å¦è¢«å“应,如果为 false,则按钮将被ç¦ç”¨ã€‚ */ - interactable: boolean; - /** !#en When this flag is true, Button target sprite will turn gray when interactable is false. - !#zh å¦‚æžœè¿™ä¸ªæ ‡è®°ä¸º true,当 button çš„ interactable 属性为 false 的时候,会使用内置 shader 让 button çš„ target 节点的 sprite 组件å˜ç° */ - enableAutoGrayEffect: boolean; - /** !#en Transition type - !#zh æŒ‰é’®çŠ¶æ€æ”¹å˜æ—¶è¿‡æ¸¡æ–¹å¼ã€‚ */ - transition: Button.Transition; - /** !#en Normal state color. - !#zh 普通状æ€ä¸‹æŒ‰é’®æ‰€æ˜¾ç¤ºçš„颜色。 */ - normalColor: Color; - /** !#en Pressed state color - !#zh æŒ‰ä¸‹çŠ¶æ€æ—¶æŒ‰é’®æ‰€æ˜¾ç¤ºçš„颜色。 */ - pressedColor: Color; - /** !#en Hover state color - !#zh 悬åœçжæ€ä¸‹æŒ‰é’®æ‰€æ˜¾ç¤ºçš„颜色。 */ - hoverColor: Color; - /** !#en Disabled state color - !#zh ç¦ç”¨çжæ€ä¸‹æŒ‰é’®æ‰€æ˜¾ç¤ºçš„颜色。 */ - disabledColor: Color; - /** !#en Color and Scale transition duration - !#zh 颜色过渡和缩放过渡时所需时间 */ - duration: number; - /** !#en When user press the button, the button will zoom to a scale. - The final scale of the button equals (button original scale * zoomScale) - !#zh 当用户点击按钮åŽï¼ŒæŒ‰é’®ä¼šç¼©æ”¾åˆ°ä¸€ä¸ªå€¼ï¼Œè¿™ä¸ªå€¼ç‰äºŽ Button 原始 scale * zoomScale */ - zoomScale: number; - /** !#en Normal state sprite - !#zh 普通状æ€ä¸‹æŒ‰é’®æ‰€æ˜¾ç¤ºçš„ Sprite 。 */ - normalSprite: SpriteFrame; - /** !#en Pressed state sprite - !#zh æŒ‰ä¸‹çŠ¶æ€æ—¶æŒ‰é’®æ‰€æ˜¾ç¤ºçš„ Sprite 。 */ - pressedSprite: SpriteFrame; - /** !#en Hover state sprite - !#zh 悬åœçжæ€ä¸‹æŒ‰é’®æ‰€æ˜¾ç¤ºçš„ Sprite 。 */ - hoverSprite: SpriteFrame; - /** !#en Disabled state sprite - !#zh ç¦ç”¨çжæ€ä¸‹æŒ‰é’®æ‰€æ˜¾ç¤ºçš„ Sprite 。 */ - disabledSprite: SpriteFrame; - /** !#en - Transition target. - When Button state changed: - If Transition type is Button.Transition.NONE, Button will do nothing - If Transition type is Button.Transition.COLOR, Button will change target's color - If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite - !#zh - 需è¦è¿‡æ¸¡çš„ç›®æ ‡ã€‚ - 当剿Œ‰é’®çŠ¶æ€æ”¹å˜è§„则: - -如果 Transition type 选择 Button.Transition.NONE,按钮ä¸åšä»»ä½•过渡。 - -如果 Transition type 选择 Button.Transition.COLORï¼ŒæŒ‰é’®ä¼šå¯¹ç›®æ ‡é¢œè‰²è¿›è¡Œé¢œè‰²ä¹‹é—´çš„è¿‡æ¸¡ã€‚ - -如果 Transition type 选择 Button.Transition.Spriteï¼ŒæŒ‰é’®ä¼šå¯¹ç›®æ ‡ Sprite 进行 Sprite 之间的过渡。 */ - target: Node; - /** !#en If Button is clicked, it will trigger event's handler - !#zh 按钮的点击事件列表。 */ - clickEvents: Component.EventHandler[]; - /** !#en The normal material. - !#zh æ£å¸¸çжæ€çš„æè´¨ã€‚ */ - normalMaterial: Material; - /** !#en The gray material. - !#zh ç½®ç°çжæ€çš„æè´¨ã€‚ */ - grayMaterial: Material; - } - /** !#zh: 作为 UI æ ¹èŠ‚ç‚¹ï¼Œä¸ºæ‰€æœ‰å节点æä¾›è§†çª—四边的ä½ç½®ä¿¡æ¯ä»¥ä¾›å¯¹é½ï¼Œå¦å¤–æä¾›å±å¹•适é…ç–略接å£ï¼Œæ–¹ä¾¿ä»Žç¼–辑器设置。 - 注:由于本节点的尺寸会跟éšå±å¹•拉伸,所以 anchorPoint åªæ”¯æŒ (0.5, 0.5),å¦åˆ™é€‚é…ä¸åŒå±å¹•æ—¶åæ ‡ä¼šæœ‰å差。 */ - export class Canvas extends Component { - /** !#en Current active canvas, the scene should only have one active canvas at the same time. - !#zh 当剿¿€æ´»çš„画布组件,场景åŒä¸€æ—¶é—´åªèƒ½æœ‰ä¸€ä¸ªæ¿€æ´»çš„画布。 */ - static instance: Canvas; - /** !#en The desigin resolution for current scene. - !#zh 当å‰åœºæ™¯è®¾è®¡åˆ†è¾¨çŽ‡ã€‚ */ - designResolution: Size; - /** !#en TODO - !#zh: 是å¦ä¼˜å…ˆå°†è®¾è®¡åˆ†è¾¨çŽ‡é«˜åº¦æ’‘æ»¡è§†å›¾é«˜åº¦ã€‚ */ - fitHeight: boolean; - /** !#en TODO - !#zh: 是å¦ä¼˜å…ˆå°†è®¾è®¡åˆ†è¾¨çŽ‡å®½åº¦æ’‘æ»¡è§†å›¾å®½åº¦ã€‚ */ - fitWidth: boolean; - } - /** !#en - Base class for everything attached to Node(Entity).<br/> - <br/> - NOTE: Not allowed to use construction parameters for Component's subclasses, - because Component is created by the engine. - !#zh - æ‰€æœ‰é™„åŠ åˆ°èŠ‚ç‚¹çš„åŸºç±»ã€‚<br/> - <br/> - 注æ„:ä¸å…许使用组件的åç±»æž„é€ å‚æ•°ï¼Œå› 为组件是由引擎创建的。 */ - export class Component extends Object { - /** !#en The node this component is attached to. A component is always attached to a node. - !#zh è¯¥ç»„ä»¶è¢«é™„åŠ åˆ°çš„èŠ‚ç‚¹ã€‚ç»„ä»¶æ€»ä¼šé™„åŠ åˆ°ä¸€ä¸ªèŠ‚ç‚¹ã€‚ */ - node: Node; - /** !#en The uuid for editor. - !#zh 组件的 uuid,用于编辑器。 */ - uuid: string; - /** !#en indicates whether this component is enabled or not. - !#zh 表示该组件自身是å¦å¯ç”¨ã€‚ */ - enabled: boolean; - /** !#en indicates whether this component is enabled and its node is also active in the hierarchy. - !#zh 表示该组件是å¦è¢«å¯ç”¨å¹¶ä¸”所在的节点也处于激活状æ€ã€‚ */ - enabledInHierarchy: boolean; - /** !#en Returns a value which used to indicate the onLoad get called or not. - !#zh 返回一个值用æ¥åˆ¤æ– onLoad 是å¦è¢«è°ƒç”¨è¿‡ï¼Œä¸ç‰äºŽ 0 时调用过,ç‰äºŽ 0 时未调用。 */ - _isOnLoadCalled: number; - /** - !#en Update is called every frame, if the Component is enabled.<br/> - This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. - !#zh 如果该组件å¯ç”¨ï¼Œåˆ™æ¯å¸§è°ƒç”¨ update。<br/> - è¯¥æ–¹æ³•ä¸ºç”Ÿå‘½å‘¨æœŸæ–¹æ³•ï¼Œçˆ¶ç±»æœªå¿…ä¼šæœ‰å®žçŽ°ã€‚å¹¶ä¸”ä½ åªèƒ½åœ¨è¯¥æ–¹æ³•内部调用父类的实现,ä¸å¯åœ¨å…¶å®ƒåœ°æ–¹ç›´æŽ¥è°ƒç”¨è¯¥æ–¹æ³•。 - @param dt the delta time in seconds it took to complete the last frame - */ - protected update(dt: number): void; - /** - !#en LateUpdate is called every frame, if the Component is enabled.<br/> - This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. - !#zh 如果该组件å¯ç”¨ï¼Œåˆ™æ¯å¸§è°ƒç”¨ LateUpdate。<br/> - è¯¥æ–¹æ³•ä¸ºç”Ÿå‘½å‘¨æœŸæ–¹æ³•ï¼Œçˆ¶ç±»æœªå¿…ä¼šæœ‰å®žçŽ°ã€‚å¹¶ä¸”ä½ åªèƒ½åœ¨è¯¥æ–¹æ³•内部调用父类的实现,ä¸å¯åœ¨å…¶å®ƒåœ°æ–¹ç›´æŽ¥è°ƒç”¨è¯¥æ–¹æ³•。 - @param dt the delta time in seconds it took to complete the last frame - */ - protected lateUpdate(dt: number): void; + dispatchEvent(event: Event): void; /** !#en - When attaching to an active node or its node first activated. - onLoad is always called before any start functions, this allows you to order initialization of scripts.<br/> - This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + Destroy all callbackInfos. !#zh - å½“é™„åŠ åˆ°ä¸€ä¸ªæ¿€æ´»çš„èŠ‚ç‚¹ä¸Šæˆ–è€…å…¶èŠ‚ç‚¹ç¬¬ä¸€æ¬¡æ¿€æ´»æ—¶å€™è°ƒç”¨ã€‚onLoad 总是会在任何 start æ–¹æ³•è°ƒç”¨å‰æ‰§è¡Œï¼Œè¿™èƒ½ç”¨äºŽå®‰æŽ’脚本的åˆå§‹åŒ–顺åºã€‚<br/> - è¯¥æ–¹æ³•ä¸ºç”Ÿå‘½å‘¨æœŸæ–¹æ³•ï¼Œçˆ¶ç±»æœªå¿…ä¼šæœ‰å®žçŽ°ã€‚å¹¶ä¸”ä½ åªèƒ½åœ¨è¯¥æ–¹æ³•内部调用父类的实现,ä¸å¯åœ¨å…¶å®ƒåœ°æ–¹ç›´æŽ¥è°ƒç”¨è¯¥æ–¹æ³•。 + 销æ¯è®°å½•的事件 */ - protected onLoad(): void; + clear(): void; + } + /** !#en Base class of all kinds of events. + !#zh 包å«äº‹ä»¶ç›¸å…³ä¿¡æ¯çš„对象。 */ + export class Event { /** - !#en - Called before all scripts' update if the Component is enabled the first time. - Usually used to initialize some logic which need to be called after all components' `onload` methods called.<br/> - This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. - !#zh - 如果该组件第一次å¯ç”¨ï¼Œåˆ™åœ¨æ‰€æœ‰ç»„ä»¶çš„ update 之å‰è°ƒç”¨ã€‚通常用于需è¦åœ¨æ‰€æœ‰ç»„ä»¶çš„ onLoad åˆå§‹åŒ–å®Œæ¯•åŽæ‰§è¡Œçš„逻辑。<br/> - è¯¥æ–¹æ³•ä¸ºç”Ÿå‘½å‘¨æœŸæ–¹æ³•ï¼Œçˆ¶ç±»æœªå¿…ä¼šæœ‰å®žçŽ°ã€‚å¹¶ä¸”ä½ åªèƒ½åœ¨è¯¥æ–¹æ³•内部调用父类的实现,ä¸å¯åœ¨å…¶å®ƒåœ°æ–¹ç›´æŽ¥è°ƒç”¨è¯¥æ–¹æ³•。 + + @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit" + @param bubbles A boolean indicating whether the event bubbles up through the tree or not */ - protected start(): void; + constructor(type: string, bubbles: boolean); + /** !#en The name of the event (case-sensitive), e.g. "click", "fire", or "submit". + !#zh 事件类型。 */ + type: string; + /** !#en Indicate whether the event bubbles up through the tree or not. + !#zh 表示该事件是å¦è¿›è¡Œå†’泡。 */ + bubbles: boolean; + /** !#en A reference to the target to which the event was originally dispatched. + !#zh 最åˆäº‹ä»¶è§¦å‘çš„ç›®æ ‡ */ + target: any; + /** !#en A reference to the currently registered target for the event. + !#zh 当å‰ç›®æ ‡ */ + currentTarget: any; + /** !#en + Indicates which phase of the event flow is currently being evaluated. + Returns an integer value represented by 4 constants: + - Event.NONE = 0 + - Event.CAPTURING_PHASE = 1 + - Event.AT_TARGET = 2 + - Event.BUBBLING_PHASE = 3 + The phases are explained in the [section 3.1, Event dispatch and DOM event flow] + (http://www.w3.org/TR/DOM-Level-3-Events/#event-flow), of the DOM Level 3 Events specification. + !#zh 事件阶段 */ + eventPhase: number; /** - !#en Called when this component becomes enabled and its node is active.<br/> - This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. - !#zh 当该组件被å¯ç”¨ï¼Œå¹¶ä¸”它的节点也激活时。<br/> - è¯¥æ–¹æ³•ä¸ºç”Ÿå‘½å‘¨æœŸæ–¹æ³•ï¼Œçˆ¶ç±»æœªå¿…ä¼šæœ‰å®žçŽ°ã€‚å¹¶ä¸”ä½ åªèƒ½åœ¨è¯¥æ–¹æ³•内部调用父类的实现,ä¸å¯åœ¨å…¶å®ƒåœ°æ–¹ç›´æŽ¥è°ƒç”¨è¯¥æ–¹æ³•。 + !#en Reset the event for being stored in the object pool. + !#zh é‡ç½®å¯¹è±¡æ± ä¸å˜å‚¨çš„事件。 */ - protected onEnable(): void; + unuse(): string; /** - !#en Called when this component becomes disabled or its node becomes inactive.<br/> - This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. - !#zh 当该组件被ç¦ç”¨æˆ–节点å˜ä¸ºæ— 效时调用。<br/> - è¯¥æ–¹æ³•ä¸ºç”Ÿå‘½å‘¨æœŸæ–¹æ³•ï¼Œçˆ¶ç±»æœªå¿…ä¼šæœ‰å®žçŽ°ã€‚å¹¶ä¸”ä½ åªèƒ½åœ¨è¯¥æ–¹æ³•内部调用父类的实现,ä¸å¯åœ¨å…¶å®ƒåœ°æ–¹ç›´æŽ¥è°ƒç”¨è¯¥æ–¹æ³•。 + !#en Reuse the event for being used again by the object pool. + !#zh ç”¨äºŽå¯¹è±¡æ± å†æ¬¡ä½¿ç”¨çš„事件。 */ - protected onDisable(): void; + reuse(): string; /** - !#en Called when this component will be destroyed.<br/> - This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. - !#zh å½“è¯¥ç»„ä»¶è¢«é”€æ¯æ—¶è°ƒç”¨<br/> - è¯¥æ–¹æ³•ä¸ºç”Ÿå‘½å‘¨æœŸæ–¹æ³•ï¼Œçˆ¶ç±»æœªå¿…ä¼šæœ‰å®žçŽ°ã€‚å¹¶ä¸”ä½ åªèƒ½åœ¨è¯¥æ–¹æ³•内部调用父类的实现,ä¸å¯åœ¨å…¶å®ƒåœ°æ–¹ç›´æŽ¥è°ƒç”¨è¯¥æ–¹æ³•。 + !#en Stops propagation for current event. + !#zh åœæ¢ä¼ 递当å‰äº‹ä»¶ã€‚ */ - protected onDestroy(): void; - protected onFocusInEditor(): void; - protected onLostFocusInEditor(): void; + stopPropagation(): void; /** - !#en Called to initialize the component or node’s properties when adding the component the first time or when the Reset command is used. This function is only called in editor. - !#zh 用æ¥åˆå§‹åŒ–ç»„ä»¶æˆ–èŠ‚ç‚¹çš„ä¸€äº›å±žæ€§ï¼Œå½“è¯¥ç»„ä»¶è¢«ç¬¬ä¸€æ¬¡æ·»åŠ åˆ°èŠ‚ç‚¹ä¸Šæˆ–ç”¨æˆ·ç‚¹å‡»äº†å®ƒçš„ Reset èœå•时调用。这个回调åªä¼šåœ¨ç¼–辑器下调用。 + !#en Stops propagation for current event immediately, + the event won't even be dispatched to the listeners attached in the current target. + !#zh ç«‹å³åœæ¢å½“å‰äº‹ä»¶çš„ä¼ é€’ï¼Œäº‹ä»¶ç”šè‡³ä¸ä¼šè¢«åˆ†æ´¾åˆ°æ‰€è¿žæŽ¥çš„当å‰ç›®æ ‡ã€‚ */ - protected resetInEditor(): void; + stopPropagationImmediate(): void; /** - !#en Adds a component class to the node. You can also add component to node by passing in the name of the script. - !#zh å‘èŠ‚ç‚¹æ·»åŠ ä¸€ä¸ªç»„ä»¶ç±»ï¼Œä½ è¿˜å¯ä»¥é€šè¿‡ä¼ 入脚本的åç§°æ¥æ·»åŠ ç»„ä»¶ã€‚ - @param typeOrClassName the constructor or the class name of the component to add - - @example - ```js - var sprite = node.addComponent(cc.Sprite); - var test = node.addComponent("Test"); - ``` + !#en Checks whether the event has been stopped. + !#zh 检查该事件是å¦å·²ç»åœæ¢ä¼ 递. */ - addComponent<T extends Component>(type: {new(): T}): T; - addComponent(className: string): any; + isStopped(): boolean; /** !#en - Returns the component of supplied type if the node has one attached, null if it doesn't.<br/> - You can also get component in the node by passing in the name of the script. - !#zh - 获å–èŠ‚ç‚¹ä¸ŠæŒ‡å®šç±»åž‹çš„ç»„ä»¶ï¼Œå¦‚æžœèŠ‚ç‚¹æœ‰é™„åŠ æŒ‡å®šç±»åž‹çš„ç»„ä»¶ï¼Œåˆ™è¿”å›žï¼Œå¦‚æžœæ²¡æœ‰åˆ™ä¸ºç©ºã€‚<br/> - ä¼ å…¥å‚æ•°ä¹Ÿå¯ä»¥æ˜¯è„šæœ¬çš„å称。 - @param typeOrClassName typeOrClassName - - @example - ```js - // get sprite component. - var sprite = node.getComponent(cc.Sprite); - // get custom test calss. - var test = node.getComponent("Test"); - ``` - */ - getComponent<T extends Component>(type: {prototype: T}): T; - getComponent(className: string): any; - /** - !#en Returns all components of supplied Type in the node. - !#zh 返回节点上指定类型的所有组件。 - @param typeOrClassName typeOrClassName - - @example - ```js - var sprites = node.getComponents(cc.Sprite); - var tests = node.getComponents("Test"); - ``` + <p> + Gets current target of the event <br/> + note: It only be available when the event listener is associated with node. <br/> + It returns 0 when the listener is associated with fixed priority. + </p> + !#zh 获å–当å‰ç›®æ ‡èŠ‚ç‚¹ */ - getComponents<T extends Component>(type: {prototype: T}): T[]; - getComponents(className: string): any[]; + getCurrentTarget(): Node; /** - !#en Returns the component of supplied type in any of its children using depth first search. - !#zh 递归查找所有å节点ä¸ç¬¬ä¸€ä¸ªåŒ¹é…指定类型的组件。 - @param typeOrClassName typeOrClassName - - @example - ```js - var sprite = node.getComponentInChildren(cc.Sprite); - var Test = node.getComponentInChildren("Test"); - ``` + !#en Gets the event type. + !#zh 获å–事件类型 */ - getComponentInChildren<T extends Component>(type: {prototype: T}): T; - getComponentInChildren(className: string): any; + getType(): string; + /** !#en Code for event without type. + !#zh 没有类型的事件 */ + static NO_TYPE: string; + /** !#en The type code of Touch event. + !#zh 触摸事件类型 */ + static TOUCH: string; + /** !#en The type code of Mouse event. + !#zh é¼ æ ‡äº‹ä»¶ç±»åž‹ */ + static MOUSE: string; + /** !#en The type code of Keyboard event. + !#zh 键盘事件类型 */ + static KEYBOARD: string; + /** !#en The type code of Acceleration event. + !#zh åŠ é€Ÿå™¨äº‹ä»¶ç±»åž‹ */ + static ACCELERATION: string; + /** !#en Events not currently dispatched are in this phase + !#zh 尚未派å‘事件阶段 */ + static NONE: number; + /** !#en + The capturing phase comprises the journey from the root to the last node before the event target's node + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh æ•èŽ·é˜¶æ®µï¼ŒåŒ…æ‹¬äº‹ä»¶ç›®æ ‡èŠ‚ç‚¹ä¹‹å‰ä»Žæ ¹èŠ‚ç‚¹åˆ°æœ€åŽä¸€ä¸ªèŠ‚ç‚¹çš„è¿‡ç¨‹ã€‚ */ + static CAPTURING_PHASE: number; + /** !#en + The target phase comprises only the event target node + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh ç›®æ ‡é˜¶æ®µä»…åŒ…æ‹¬äº‹ä»¶ç›®æ ‡èŠ‚ç‚¹ã€‚ */ + static AT_TARGET: number; + /** !#en + The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the hierarchy + see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow + !#zh 冒泡阶段, 包括回程é‡åˆ°åˆ°å±‚æ¬¡æ ¹èŠ‚ç‚¹çš„ä»»ä½•åŽç»èŠ‚ç‚¹ã€‚ */ + static BUBBLING_PHASE: number; + } + /** !#en + The System event, it currently supports keyboard events and accelerometer events.<br> + You can get the SystemEvent instance with cc.systemEvent.<br> + !#zh + ç³»ç»Ÿäº‹ä»¶ï¼Œå®ƒç›®å‰æ”¯æŒæŒ‰é”®äº‹ä»¶å’Œé‡åŠ›æ„Ÿåº”äº‹ä»¶ã€‚<br> + ä½ å¯ä»¥é€šè¿‡ cc.systemEvent 获å–到 SystemEvent 的实例。<br> */ + export class SystemEvent extends EventTarget { /** - !#en Returns the components of supplied type in self or any of its children using depth first search. - !#zh 递归查找自身或所有åèŠ‚ç‚¹ä¸æŒ‡å®šç±»åž‹çš„组件 - @param typeOrClassName typeOrClassName - - @example - ```js - var sprites = node.getComponentsInChildren(cc.Sprite); - var tests = node.getComponentsInChildren("Test"); - ``` + !#en whether enable accelerometer event + !#zh 是å¦å¯ç”¨åŠ é€Ÿåº¦è®¡äº‹ä»¶ + @param isEnable isEnable */ - getComponentsInChildren<T extends Component>(type: {prototype: T}): T[]; - getComponentsInChildren(className: string): any[]; + setAccelerometerEnabled(isEnable: boolean): void; /** - !#en - If the component's bounding box is different from the node's, you can implement this method to supply - a custom axis aligned bounding box (AABB), so the editor's scene view can perform hit test properly. - !#zh - 如果组件的包围盒与节点ä¸åŒï¼Œæ‚¨å¯ä»¥å®žçŽ°è¯¥æ–¹æ³•ä»¥æä¾›è‡ªå®šä¹‰çš„è½´å‘对é½çš„包围盒(AABB), - 以便编辑器的场景视图å¯ä»¥æ£ç¡®åœ°æ‰§è¡Œç‚¹é€‰æµ‹è¯•。 - @param out_rect the Rect to receive the bounding box + !#en set accelerometer interval value + !#zh è®¾ç½®åŠ é€Ÿåº¦è®¡é—´éš”å€¼ + @param interval interval */ - _getLocalBounds(out_rect: Rect): void; + setAccelerometerInterval(interval: number): void; + } + /** !#en The animation component is used to play back animations. + + Animation provide several events to register: + - play : Emit when begin playing animation + - stop : Emit when stop playing animation + - pause : Emit when pause animation + - resume : Emit when resume animation + - lastframe : If animation repeat count is larger than 1, emit when animation play to the last frame + - finished : Emit when finish playing animation + + !#zh Animation ç»„ä»¶ç”¨äºŽæ’æ”¾åŠ¨ç”»ã€‚ + + Animation æä¾›äº†ä¸€ç³»åˆ—坿³¨å†Œçš„事件: + - play : å¼€å§‹æ’æ”¾æ—¶ + - stop : åœæ¢æ’放时 + - pause : æš‚åœæ’放时 + - resume : æ¢å¤æ’放时 + - lastframe : å‡å¦‚动画循环次数大于 1ï¼Œå½“åŠ¨ç”»æ’æ”¾åˆ°æœ€åŽä¸€å¸§æ—¶ + - finished : åŠ¨ç”»æ’æ”¾å®Œæˆæ—¶ */ + export class Animation extends Component implements EventTarget { + /** !#en Animation will play the default clip when start game. + !#zh åœ¨å‹¾é€‰è‡ªåŠ¨æ’æ”¾æˆ–调用 play() æ—¶é»˜è®¤æ’æ”¾çš„动画剪辑。 */ + defaultClip: AnimationClip; + /** !#en Current played clip. + !#zh 当剿’放的动画剪辑。 */ + currentClip: AnimationClip; + /** !#en Whether the animation should auto play the default clip when start game. + !#zh 是å¦åœ¨è¿è¡Œæ¸¸æˆåŽè‡ªåŠ¨æ’æ”¾é»˜è®¤åŠ¨ç”»å‰ªè¾‘ã€‚ */ + playOnLoad: boolean; /** - !#en - onRestore is called after the user clicks the Reset item in the Inspector's context menu or performs - an undo operation on this component.<br/> - <br/> - If the component contains the "internal state", short for "temporary member variables which not included<br/> - in its CCClass properties", then you may need to implement this function.<br/> - <br/> - The editor will call the getset accessors of your component to record/restore the component's state<br/> - for undo/redo operation. However, in extreme cases, it may not works well. Then you should implement<br/> - this function to manually synchronize your component's "internal states" with its public properties.<br/> - Once you implement this function, all the getset accessors of your component will not be called when<br/> - the user performs an undo/redo operation. Which means that only the properties with default value<br/> - will be recorded or restored by editor.<br/> - <br/> - Similarly, the editor may failed to reset your component correctly in extreme cases. Then if you need<br/> - to support the reset menu, you should manually synchronize your component's "internal states" with its<br/> - properties in this function. Once you implement this function, all the getset accessors of your component<br/> - will not be called during reset operation. Which means that only the properties with default value<br/> - will be reset by editor. - - This function is only called in editor mode. - !#zh - onRestore 是用户在检查器èœå•点击 Reset 时,对æ¤ç»„件执行撤消æ“作åŽè°ƒç”¨çš„。<br/> - <br/> - 如果组件包å«äº†â€œå†…部状æ€â€ï¼ˆä¸åœ¨ CCClass 属性ä¸å®šä¹‰çš„临时æˆå‘˜å˜é‡ï¼‰ï¼Œé‚£ä¹ˆä½ å¯èƒ½éœ€è¦å®žçŽ°è¯¥æ–¹æ³•ã€‚<br/> - <br/> - 编辑器执行撤销/é‡åšæ“作时,将调用组件的 get set æ¥å½•制和还原组件的状æ€ã€‚然而,在æžç«¯çš„æƒ…况下,它å¯èƒ½æ— 法良好è¿ä½œã€‚<br/> - é‚£ä¹ˆä½ å°±åº”è¯¥å®žçŽ°è¿™ä¸ªæ–¹æ³•ï¼Œæ‰‹åŠ¨æ ¹æ®ç»„ä»¶çš„å±žæ€§åŒæ¥â€œå†…部状æ€â€ã€‚ä¸€æ—¦ä½ å®žçŽ°è¿™ä¸ªæ–¹æ³•ï¼Œå½“ç”¨æˆ·æ’¤é”€æˆ–é‡åšæ—¶ï¼Œç»„ä»¶çš„æ‰€æœ‰ get set 都ä¸ä¼šå†è¢«è°ƒç”¨ã€‚è¿™æ„味ç€ä»…仅指定了默认值的属性将被编辑器记录和还原。<br/> - <br/> - åŒæ ·çš„,编辑å¯èƒ½æ— 法在æžç«¯æƒ…况下æ£ç¡®åœ°é‡ç½®æ‚¨çš„ç»„ä»¶ã€‚å¦‚æžœä½ éœ€è¦æ”¯æŒç»„ä»¶é‡ç½®èœå•,则需è¦åœ¨è¯¥æ–¹æ³•䏿‰‹å·¥åŒæ¥ç»„件属性到“内部状æ€â€ã€‚ä¸€æ—¦ä½ å®žçŽ°è¿™ä¸ªæ–¹æ³•ï¼Œç»„ä»¶çš„æ‰€æœ‰ get set 都ä¸ä¼šåœ¨é‡ç½®æ“作时被调用。这æ„味ç€ä»…仅指定了默认值的属性将被编辑器é‡ç½®ã€‚ - <br/> - æ¤æ–¹æ³•仅在编辑器下会被调用。 + !#en Get all the clips used in this animation. + !#zh 获å–动画组件上的所有动画剪辑。 */ - onRestore(): void; + getClips(): AnimationClip[]; /** - !#en - Schedules a custom selector.<br/> - If the selector is already scheduled, then the interval parameter will be updated without scheduling it again. - !#zh - 调度一个自定义的回调函数。<br/> - 如果回调函数已调度,那么将ä¸ä¼šé‡å¤è°ƒåº¦å®ƒï¼Œåªä¼šæ›´æ–°æ—¶é—´é—´éš”傿•°ã€‚ - @param callback The callback function - @param interval Tick interval in seconds. 0 means tick every frame. - @param repeat The selector will be executed (repeat + 1) times, you can use cc.macro.REPEAT_FOREVER for tick infinitely. - @param delay The amount of time that the first tick will wait before execution. Unit: s + !#en Plays an animation and stop other animations. + !#zh æ’æ”¾æŒ‡å®šçš„åŠ¨ç”»ï¼Œå¹¶ä¸”åœæ¢å½“剿£åœ¨æ’æ”¾åŠ¨ç”»ã€‚å¦‚æžœæ²¡æœ‰æŒ‡å®šåŠ¨ç”»ï¼Œåˆ™æ’æ”¾é»˜è®¤åŠ¨ç”»ã€‚ + @param name The name of animation to play. If no name is supplied then the default animation will be played. + @param startTime play an animation from startTime @example ```js - var timeCallback = function (dt) { - cc.log("time: " + dt); - } - this.schedule(timeCallback, 1); + var animCtrl = this.node.getComponent(cc.Animation); + animCtrl.play("linear"); ``` */ - schedule(callback: Function, interval?: number, repeat?: number, delay?: number): void; + play(name?: string, startTime?: number): AnimationState; /** - !#en Schedules a callback function that runs only once, with a delay of 0 or larger. - !#zh 调度一个åªè¿è¡Œä¸€æ¬¡çš„回调函数,å¯ä»¥æŒ‡å®š 0 è®©å›žè°ƒå‡½æ•°åœ¨ä¸‹ä¸€å¸§ç«‹å³æ‰§è¡Œæˆ–è€…åœ¨ä¸€å®šçš„å»¶æ—¶ä¹‹åŽæ‰§è¡Œã€‚ - @param callback A function wrapped as a selector - @param delay The amount of time that the first tick will wait before execution. Unit: s + !#en + Plays an additive animation, it will not stop other animations. + If there are other animations playing, then will play several animations at the same time. + !#zh æ’æ”¾æŒ‡å®šçš„动画(将ä¸ä¼šåœæ¢å½“剿’æ”¾çš„åŠ¨ç”»ï¼‰ã€‚å¦‚æžœæ²¡æœ‰æŒ‡å®šåŠ¨ç”»ï¼Œåˆ™æ’æ”¾é»˜è®¤åŠ¨ç”»ã€‚ + @param name The name of animation to play. If no name is supplied then the default animation will be played. + @param startTime play an animation from startTime @example ```js - var timeCallback = function (dt) { - cc.log("time: " + dt); - } - this.scheduleOnce(timeCallback, 2); + // linear_1 and linear_2 at the same time playing. + var animCtrl = this.node.getComponent(cc.Animation); + animCtrl.playAdditive("linear_1"); + animCtrl.playAdditive("linear_2"); ``` */ - scheduleOnce(callback: Function, delay?: number): void; + playAdditive(name?: string, startTime?: number): AnimationState; /** - !#en Unschedules a custom callback function. - !#zh å–æ¶ˆè°ƒåº¦ä¸€ä¸ªè‡ªå®šä¹‰çš„回调函数。 - @param callback_fn A function wrapped as a selector - - @example - ```js - this.unschedule(_callback); - ``` + !#en Stops an animation named name. If no name is supplied then stops all playing animations that were started with this Animation. <br/> + Stopping an animation also Rewinds it to the Start. + !#zh åœæ¢æŒ‡å®šçš„动画。如果没有指定åå—ï¼Œåˆ™åœæ¢å½“剿£åœ¨æ’放的动画。 + @param name The animation to stop, if not supplied then stops all playing animations. */ - unschedule(callback_fn: Function): void; + stop(name?: string): void; + /** + !#en Pauses an animation named name. If no name is supplied then pauses all playing animations that were started with this Animation. + !#zh æš‚åœå½“剿ˆ–者指定的动画。如果没有指定åå—,则暂åœå½“剿£åœ¨æ’放的动画。 + @param name The animation to pauses, if not supplied then pauses all playing animations. + */ + pause(name?: string): void; + /** + !#en Resumes an animation named name. If no name is supplied then resumes all paused animations that were started with this Animation. + !#zh 釿–°æ’放指定的动画,如果没有指定åå—ï¼Œåˆ™é‡æ–°æ’æ”¾å½“å‰æ£åœ¨æ’放的动画。 + @param name The animation to resumes, if not supplied then resumes all paused animations. + */ + resume(name?: string): void; + /** + !#en Make an animation named name go to the specified time. If no name is supplied then make all animations go to the specified time. + !#zh è®¾ç½®æŒ‡å®šåŠ¨ç”»çš„æ’æ”¾æ—¶é—´ã€‚如果没有指定åå—ï¼Œåˆ™è®¾ç½®å½“å‰æ’æ”¾åŠ¨ç”»çš„æ’æ”¾æ—¶é—´ã€‚ + @param time The time to go to + @param name Specified animation name, if not supplied then make all animations go to the time. + */ + setCurrentTime(time?: number, name?: string): void; + /** + !#en Returns the animation state named name. If no animation with the specified name, the function will return null. + !#zh 获å–当剿ˆ–者指定的动画状æ€ï¼Œå¦‚果未找到指定动画剪辑则返回 null。 + @param name name + */ + getAnimationState(name: string): AnimationState; + /** + !#en Adds a clip to the animation with name newName. If a clip with that name already exists it will be replaced with the new clip. + !#zh æ·»åŠ åŠ¨ç”»å‰ªè¾‘ï¼Œå¹¶ä¸”å¯ä»¥é‡æ–°è®¾ç½®è¯¥åŠ¨ç”»å‰ªè¾‘çš„å称。 + @param clip the clip to add + @param newName newName + */ + addClip(clip: AnimationClip, newName?: string): AnimationState; /** !#en - unschedule all scheduled callback functions: custom callback functions, and the 'update' callback function.<br/> - Actions are not affected by this method. - !#zh å–æ¶ˆè°ƒåº¦æ‰€æœ‰å·²è°ƒåº¦çš„å›žè°ƒå‡½æ•°ï¼šå®šåˆ¶çš„å›žè°ƒå‡½æ•°ä»¥åŠ `update` 回调函数。动作ä¸å—æ¤æ–¹æ³•å½±å“。 - - @example - ```js - this.unscheduleAllCallbacks(); - ``` + Remove clip from the animation list. This will remove the clip and any animation states based on it. + If there are animation states depand on the clip are playing or clip is defaultClip, it will not delete the clip. + But if force is true, then will always remove the clip and any animation states based on it. If clip is defaultClip, defaultClip will be reset to null + !#zh + 从动画列表ä¸ç§»é™¤æŒ‡å®šçš„动画剪辑,<br/> + 如果ä¾èµ–于 clip çš„ AnimationState æ£åœ¨æ’放或者 clip 是 defaultClip çš„è¯ï¼Œé»˜è®¤æ˜¯ä¸ä¼šåˆ 除 clip 的。 + 但是如果 force 傿•°ä¸º trueï¼Œåˆ™ä¼šå¼ºåˆ¶åœæ¢è¯¥åŠ¨ç”»ï¼Œç„¶åŽç§»é™¤è¯¥åŠ¨ç”»å‰ªè¾‘å’Œç›¸å…³çš„åŠ¨ç”»ã€‚è¿™æ—¶å€™å¦‚æžœ clip 是 defaultClip,defaultClip 将会被é‡ç½®ä¸º null。 + @param clip clip + @param force If force is true, then will always remove the clip and any animation states based on it. */ - unscheduleAllCallbacks(): void; - } - /** !#en The Label Component. - !#zh æ–‡å—æ ‡ç¾ç»„ä»¶ */ - export class Label extends RenderComponent { - /** !#en Content string of label. - !#zh æ ‡ç¾æ˜¾ç¤ºçš„æ–‡æœ¬å†…容。 */ - string: string; - /** !#en Horizontal Alignment of label. - !#zh æ–‡æœ¬å†…å®¹çš„æ°´å¹³å¯¹é½æ–¹å¼ã€‚ */ - horizontalAlign: Label.HorizontalAlign; - /** !#en Vertical Alignment of label. - !#zh æ–‡æœ¬å†…å®¹çš„åž‚ç›´å¯¹é½æ–¹å¼ã€‚ */ - verticalAlign: Label.VerticalAlign; - /** !#en The actual rendering font size in shrink mode - !#zh SHRINK 模å¼ä¸‹é¢æ–‡æœ¬å®žé™…渲染的å—ä½“å¤§å° */ - actualFontSize: number; - /** !#en Font size of label. - !#zh 文本å—体大å°ã€‚ */ - fontSize: number; - /** !#en Font family of label, only take effect when useSystemFont property is true. - !#zh 文本å—体åç§°, åªåœ¨ useSystemFont 属性为 true 的时候生效。 */ - fontFamily: string; - /** !#en Line Height of label. - !#zh 文本行高。 */ - lineHeight: number; - /** !#en Overflow of label. - !#zh æ–‡å—æ˜¾ç¤ºè¶…å‡ºèŒƒå›´æ—¶çš„å¤„ç†æ–¹å¼ã€‚ */ - overflow: Label.Overflow; - /** !#en Whether auto wrap label when string width is large than label width. - !#zh 是å¦è‡ªåЍæ¢è¡Œã€‚ */ - enableWrapText: boolean; - /** !#en The font of label. - !#zh 文本å—体。 */ - font: Font; - /** !#en Whether use system font name or not. - !#zh 是å¦ä½¿ç”¨ç³»ç»Ÿå—体。 */ - useSystemFont: boolean; - /** !#en The spacing of the x axis between characters, only take Effect when using bitmap fonts. - !#zh æ–‡å—之间 x 轴的间è·ï¼Œä»…在使用ä½å›¾å—体时生效。 */ - spacingX: number; - /** !#en The cache mode of label. This mode only supports system fonts. - !#zh æ–‡æœ¬ç¼“å˜æ¨¡å¼, 该模å¼åªæ”¯æŒç³»ç»Ÿå—体。 */ - cacheMode: Label.CacheMode; - /** !#en Whether enable bold. - !#zh 是å¦å¯ç”¨é»‘体。 */ - enableBold: boolean; - /** !#en Whether enable italic. - !#zh 是å¦å¯ç”¨é»‘体。 */ - enableItalic: boolean; - /** !#en Whether enable underline. - !#zh 是å¦å¯ç”¨ä¸‹åˆ’线。 */ - enableUnderline: boolean; - /** !#en The height of underline. - !#zh 下划线高度。 */ - underlineHeight: number; + removeClip(clip: AnimationClip, force?: boolean): void; /** - !#zh 需è¦ä¿è¯å½“å‰åœºæ™¯ä¸æ²¡æœ‰ä½¿ç”¨CHAR缓å˜çš„Labelæ‰å¯ä»¥æ¸…除,å¦åˆ™å·²æ¸²æŸ“çš„æ–‡å—æ²¡æœ‰é‡æ–°ç»˜åˆ¶ä¼šä¸æ˜¾ç¤º - !#en It can be cleared that need to ensure there is not use the CHAR cache in the current scene. Otherwise, the rendered text will not be displayed without repainting. + !#en + Samples animations at the current state.<br/> + This is useful when you explicitly want to set up some animation state, and sample it once. + !#zh 对指定或当å‰åŠ¨ç”»è¿›è¡Œé‡‡æ ·ã€‚ä½ å¯ä»¥æ‰‹åŠ¨å°†åŠ¨ç”»è®¾ç½®åˆ°æŸä¸€ä¸ªçжæ€ï¼Œç„¶åŽé‡‡æ ·ä¸€æ¬¡ã€‚ + @param name name */ - static clearCharCache(): void; - } - /** !#en Outline effect used to change the display, only for system fonts or TTF fonts - !#zh æè¾¹æ•ˆæžœç»„ä»¶,用于å—体æè¾¹,åªèƒ½ç”¨äºŽç³»ç»Ÿå—体 */ - export class LabelOutline extends Component { - /** !#en outline color - !#zh æ”¹å˜æè¾¹çš„é¢œè‰² */ - color: Color; - /** !#en Change the outline width - !#zh æ”¹å˜æè¾¹çš„å®½åº¦ */ - width: number; - } - /** !#en - The Layout is a container component, use it to arrange child elements easily.<br> - Note:<br> - 1.Scaling and rotation of child nodes are not considered.<br> - 2.After setting the Layout, the results need to be updated until the next frame, - unless you manually call {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 - !#zh - Layout 组件相当于一个容器,能自动对它的所有å节点进行统一排版。<br> - 注æ„:<br> - 1.ä¸ä¼šè€ƒè™‘å节点的缩放和旋转。<br> - 2.对 Layout 设置åŽç»“果需è¦åˆ°ä¸‹ä¸€å¸§æ‰ä¼šæ›´æ–°ï¼Œé™¤éžä½ è®¾ç½®å®Œä»¥åŽæ‰‹åŠ¨è°ƒç”¨ {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 */ - export class Layout extends Component { - /** !#en The layout type. - !#zh 布局类型 */ - type: Layout.Type; - /** !#en - The are three resize modes for Layout. - None, resize Container and resize children. - !#zh ç¼©æ”¾æ¨¡å¼ */ - resizeMode: Layout.ResizeMode; - /** !#en The cell size for grid layout. - !#zh æ¯ä¸ªæ ¼å的大å°ï¼Œåªæœ‰å¸ƒå±€ç±»åž‹ä¸º GRID çš„æ—¶å€™æ‰æœ‰æ•ˆã€‚ */ - cellSize: Size; - /** !#en - The start axis for grid layout. If you choose horizontal, then children will layout horizontally at first, - and then break line on demand. Choose vertical if you want to layout vertically at first . - !#zh èµ·å§‹è½´æ–¹å‘类型,å¯è¿›è¡Œæ°´å¹³å’Œåž‚ç›´å¸ƒå±€æŽ’åˆ—ï¼Œåªæœ‰å¸ƒå±€ç±»åž‹ä¸º GRID çš„æ—¶å€™æ‰æœ‰æ•ˆã€‚ */ - startAxis: Layout.AxisDirection; - /** !#en The left padding of layout, it only effect the layout in one direction. - !#zh 容器内左边è·ï¼Œåªä¼šåœ¨ä¸€ä¸ªå¸ƒå±€æ–¹å‘上生效。 */ - paddingLeft: number; - /** !#en The right padding of layout, it only effect the layout in one direction. - !#zh 容器内å³è¾¹è·ï¼Œåªä¼šåœ¨ä¸€ä¸ªå¸ƒå±€æ–¹å‘上生效。 */ - paddingRight: number; - /** !#en The top padding of layout, it only effect the layout in one direction. - !#zh 容器内上边è·ï¼Œåªä¼šåœ¨ä¸€ä¸ªå¸ƒå±€æ–¹å‘上生效。 */ - paddingTop: number; - /** !#en The bottom padding of layout, it only effect the layout in one direction. - !#zh 容器内下边è·ï¼Œåªä¼šåœ¨ä¸€ä¸ªå¸ƒå±€æ–¹å‘上生效。 */ - paddingBottom: number; - /** !#en The distance in x-axis between each element in layout. - !#zh å节点之间的水平间è·ã€‚ */ - spacingX: number; - /** !#en The distance in y-axis between each element in layout. - !#zh å节点之间的垂直间è·ã€‚ */ - spacingY: number; - /** !#en - Only take effect in Vertical layout mode. - This option changes the start element's positioning. - !#zh 垂直排列å节点的方å‘。 */ - verticalDirection: Layout.VerticalDirection; - /** !#en - Only take effect in Horizontal layout mode. - This option changes the start element's positioning. - !#zh 水平排列å节点的方å‘。 */ - horizontalDirection: Layout.HorizontalDirection; - /** !#en Adjust the layout if the children scaled. - !#zh å节点缩放比例是å¦å½±å“布局。 */ - affectedByScale: boolean; + sample(name: string): void; /** - !#en Perform the layout update - !#zh ç«‹å³æ‰§è¡Œæ›´æ–°å¸ƒå±€ + !#en + Register animation event callback. + The event arguments will provide the AnimationState which emit the event. + When play an animation, will auto register the event callback to the AnimationState, and unregister the event callback from the AnimationState when animation stopped. + !#zh + 注册动画事件回调。 + 回调的事件里将会附上å‘é€äº‹ä»¶çš„ AnimationState。 + å½“æ’æ”¾ä¸€ä¸ªåŠ¨ç”»æ—¶ï¼Œä¼šè‡ªåŠ¨å°†äº‹ä»¶æ³¨å†Œåˆ°å¯¹åº”çš„ AnimationState ä¸Šï¼Œåœæ¢æ’放时会将事件从这个 AnimationState ä¸Šå–æ¶ˆæ³¨å†Œã€‚ + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param state state + @param target The target (this object) to invoke the callback, can be null + @param useCapture When set to true, the capture argument prevents callback + from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. + When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE. + Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. @example ```js - layout.type = cc.Layout.HORIZONTAL; - layout.node.addChild(childNode); - cc.log(childNode.x); // not yet changed - layout.updateLayout(); - cc.log(childNode.x); // changed + onPlay: function (type, state) { + // callback + } + + // register event to all animation + animation.on('play', this.onPlay, this); ``` */ - updateLayout(): void; - } - /** !#en Shadow effect for Label component, only for system fonts or TTF fonts - !#zh 用于给 Label ç»„ä»¶æ·»åŠ é˜´å½±æ•ˆæžœï¼Œåªèƒ½ç”¨äºŽç³»ç»Ÿå—体或 ttf å—体 */ - export class LabelShadow extends Component { - /** !#en The shadow color - !#zh 阴影的颜色 */ - color: Color; - /** !#en Offset between font and shadow - !#zh å—体与阴影的åç§» */ - offset: Vec2; - /** !#en A non-negative float specifying the level of shadow blur - !#zh 阴影的模糊程度 */ - blur: number; - } - /** !#en The Mask Component - !#zh é®ç½©ç»„ä»¶ */ - export class Mask extends RenderComponent { - /** !#en The mask type. - !#zh é®ç½©ç±»åž‹ */ - type: Mask.Type; - /** !#en The mask image - !#zh é®ç½©æ‰€éœ€è¦çš„贴图 */ - spriteFrame: SpriteFrame; - /** !#en - The alpha threshold.(Not supported Canvas Mode) <br/> - The content is drawn only where the stencil have pixel with alpha greater than the alphaThreshold. <br/> - Should be a float between 0 and 1. <br/> - This default to 0.1. - When it's set to 1, the stencil will discard all pixels, nothing will be shown. - !#zh - Alpha é˜ˆå€¼ï¼ˆä¸æ”¯æŒ Canvas 模å¼ï¼‰<br/> - åªæœ‰å½“模æ¿çš„åƒç´ çš„ alpha 大于ç‰äºŽ alphaThreshold 时,æ‰ä¼šç»˜åˆ¶å†…容。<br/> - 该数值 0 ~ 1 之间的浮点数,默认值为 0.1 - 当被设置为 1 时,会丢弃所有蒙版åƒç´ ,所以ä¸ä¼šæ˜¾ç¤ºä»»ä½•内容 */ - alphaThreshold: number; - /** !#en Reverse mask (Not supported Canvas Mode) - !#zh åå‘é®ç½©ï¼ˆä¸æ”¯æŒ Canvas 模å¼ï¼‰ */ - inverted: boolean; - /** TODO: remove segments, not supported by graphics - !#en The segements for ellipse mask. - !#zh æ¤åœ†é®ç½©çš„æ›²çº¿ç»†åˆ†æ•° */ - segements: number; - } - /** !#en - cc.MotionStreak manages a Ribbon based on it's motion in absolute space. <br/> - You construct it with a fadeTime, minimum segment size, texture path, texture <br/> - length and color. The fadeTime controls how long it takes each vertex in <br/> - the streak to fade out, the minimum segment size it how many pixels the <br/> - streak will move before adding a new ribbon segment, and the texture <br/> - length is the how many pixels the texture is stretched across. The texture <br/> - is vertically aligned along the streak segment. - !#zh è¿åŠ¨è½¨è¿¹ï¼Œç”¨äºŽæ¸¸æˆå¯¹è±¡çš„è¿åŠ¨è½¨è¿¹ä¸Šå®žçŽ°æ‹–å°¾æ¸éšæ•ˆæžœã€‚ */ - export class MotionStreak extends Component implements BlendFunc { - /** !#en - !#zh 在编辑器模å¼ä¸‹é¢„览拖尾效果。 */ - preview: boolean; - /** !#en The fade time to fade. - !#zh 拖尾的æ¸éšæ—¶é—´ï¼Œä»¥ç§’ä¸ºå•ä½ã€‚ */ - fadeTime: number; - /** !#en The minimum segment size. - !#zh 拖尾之间最å°è·ç¦»ã€‚ */ - minSeg: number; - /** !#en The stroke's width. - !#zh 拖尾的宽度。 */ - stroke: number; - /** !#en The texture of the MotionStreak. - !#zh 拖尾的贴图。 */ - texture: Texture2D; - /** !#en The color of the MotionStreak. - !#zh 拖尾的颜色 */ - color: Color; - /** !#en The fast Mode. - !#zh 是å¦å¯ç”¨äº†å¿«é€Ÿæ¨¡å¼ã€‚当å¯ç”¨å¿«é€Ÿæ¨¡å¼ï¼Œæ–°çš„ç‚¹ä¼šè¢«æ›´å¿«åœ°æ·»åŠ ï¼Œä½†ç²¾åº¦è¾ƒä½Žã€‚ */ - fastMode: boolean; + on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void; + on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void; + on(type: string, callback: (type: string, state: cc.AnimationState) => void, target?: any, useCapture?: boolean): (type: string, state: cc.AnimationState) => void; /** - !#en Remove all living segments of the ribbon. - !#zh åˆ é™¤å½“å‰æ‰€æœ‰çš„æ‹–尾片段。 + !#en + Unregister animation event callback. + !#zh + å–æ¶ˆæ³¨å†ŒåŠ¨ç”»äº‹ä»¶å›žè°ƒã€‚ + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + @param useCapture Specifies whether the callback being removed was registered as a capturing callback or not. + If not specified, useCapture defaults to false. If a callback was registered twice, + one with capture and one without, each must be removed separately. Removal of a capturing callback + does not affect a non-capturing version of the same listener, and vice versa. @example ```js - // Remove all living segments of the ribbon. - myMotionStreak.reset(); + // unregister event to all animation + animation.off('play', this.onPlay, this); ``` */ - reset(): void; - /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. - !#zh æŒ‡å®šåŽŸå›¾çš„æ··åˆæ¨¡å¼ï¼Œè¿™ä¼šå…‹éš†ä¸€ä¸ªæ–°çš„æè´¨å¯¹è±¡ï¼Œæ³¨æ„这带æ¥çš„开销 */ - srcBlendFactor: macro.BlendFactor; - /** !#en specify the destination Blend Factor. - !#zh æŒ‡å®šç›®æ ‡çš„æ··åˆæ¨¡å¼ */ - dstBlendFactor: macro.BlendFactor; - } - /** !#en The PageView control - !#zh 页é¢è§†å›¾ç»„ä»¶ */ - export class PageView extends ScrollView { - /** !#en Specify the size type of each page in PageView. - !#zh 页é¢è§†å›¾ä¸æ¯ä¸ªé¡µé¢å¤§å°ç±»åž‹ */ - sizeMode: PageView.SizeMode; - /** !#en The page view direction - !#zh 页é¢è§†å›¾æ»šåŠ¨ç±»åž‹ */ - direction: PageView.Direction; - /** !#en - The scroll threshold value, when drag exceeds this value, - release the next page will automatically scroll, less than the restore - !#zh 滚动临界值,默认å•ä½ç™¾åˆ†æ¯”,当拖拽超出该数值时,æ¾å¼€ä¼šè‡ªåŠ¨æ»šåŠ¨ä¸‹ä¸€é¡µï¼Œå°äºŽæ—¶åˆ™è¿˜åŽŸã€‚ */ - scrollThreshold: number; - /** !#en - Auto page turning velocity threshold. When users swipe the PageView quickly, - it will calculate a velocity based on the scroll distance and time, - if the calculated velocity is larger than the threshold, then it will trigger page turning. - !#zh - 快速滑动翻页临界值。 - å½“ç”¨æˆ·å¿«é€Ÿæ»‘åŠ¨æ—¶ï¼Œä¼šæ ¹æ®æ»‘动开始和结æŸçš„è·ç¦»ä¸Žæ—¶é—´è®¡ç®—出一个速度值, - 该值与æ¤ä¸´ç•Œå€¼ç›¸æ¯”较,如果大于临界值,则进行自动翻页。 */ - autoPageTurningThreshold: number; - /** !#en Change the PageTurning event timing of PageView. - !#zh 设置 PageView PageTurning 事件的å‘逿—¶æœºã€‚ */ - pageTurningEventTiming: number; - /** !#en The Page View Indicator - !#zh 页é¢è§†å›¾æŒ‡ç¤ºå™¨ç»„ä»¶ */ - indicator: PageViewIndicator; - /** !#en The time required to turn over a page. unit: second - !#zh æ¯ä¸ªé¡µé¢ç¿»é¡µæ—¶æ‰€éœ€æ—¶é—´ã€‚å•ä½ï¼šç§’ */ - pageTurningSpeed: number; - /** !#en PageView events callback - !#zh 滚动视图的事件回调函数 */ - pageEvents: Component.EventHandler[]; + off(type: string, callback?: Function, target?: any, useCapture?: boolean): void; /** - !#en Returns current page index - !#zh 返回当å‰é¡µé¢ç´¢å¼• + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh æ£€æŸ¥äº‹ä»¶ç›®æ ‡å¯¹è±¡æ˜¯å¦æœ‰ä¸ºç‰¹å®šç±»åž‹çš„事件注册的回调。 + @param type The type of event. */ - getCurrentPageIndex(): number; + hasEventListener(type: string): boolean; /** - !#en Set current page index - !#zh 设置当å‰é¡µé¢ç´¢å¼• - @param index index + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh åœ¨å½“å‰ EventTarget ä¸Šåˆ é™¤æŒ‡å®šç›®æ ‡ï¼ˆtarget 傿•°ï¼‰æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ + è¿™ä¸ªå‡½æ•°æ— æ³•åˆ é™¤å½“å‰ EventTarget 的所有事件监å¬å™¨ï¼Œä¹Ÿæ— æ³•åˆ é™¤ target 傿•°æ‰€æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ + 这个函数åªèƒ½åˆ 除 target 傿•°åœ¨å½“å‰ EventTarget 上注册的所有事件监å¬å™¨ã€‚ + @param target The target to be searched for all related listeners */ - setCurrentPageIndex(index: number): void; + targetOff(target: any): void; /** - !#en Returns all pages of pageview - !#zh 返回视图ä¸çš„æ‰€æœ‰é¡µé¢ + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + æ³¨å†Œäº‹ä»¶ç›®æ ‡çš„ç‰¹å®šäº‹ä»¶ç±»åž‹å›žè°ƒï¼Œå›žè°ƒä¼šåœ¨ç¬¬ä¸€æ—¶é—´è¢«è§¦å‘åŽåˆ 除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` */ - getPages(): Node[]; + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; /** - !#en At the end of the current page view to insert a new view - !#zh 在当å‰é¡µé¢è§†å›¾çš„尾部æ’入一个新视图 - @param page page + !#en + Send an event with the event object. + !#zh + 通过事件对象派å‘事件 + @param event event */ - addPage(page: Node): void; + dispatchEvent(event: Event): void; /** - !#en Inserts a page in the specified location - !#zh 将页颿’入指定ä½ç½®ä¸ - @param page page - @param index index + !#en + Destroy all callbackInfos. + !#zh + 销æ¯è®°å½•的事件 */ - insertPage(page: Node, index: number): void; + clear(): void; + } + /** !#en Audio Source. + !#zh 音频æºç»„件,能对音频剪辑。 */ + export class AudioSource extends Component { + /** !#en + Is the audio source playing (Read Only). <br/> + Note: isPlaying is not supported for Native platforms. + !#zh + è¯¥éŸ³é¢‘å‰ªè¾‘æ˜¯å¦æ£æ’放(åªè¯»ï¼‰ã€‚<br/> + 注æ„:Native å¹³å°æš‚æ—¶ä¸æ”¯æŒ isPlaying。 */ + isPlaying: boolean; + /** !#en The clip of the audio source to play. + !#zh è¦æ’放的音频剪辑。 */ + clip: AudioClip; + /** !#en The volume of the audio source. + !#zh 音频æºçš„音é‡ï¼ˆ0.0 ~ 1.0)。 */ + volume: number; + /** !#en Is the audio source mute? + !#zh 是å¦é™éŸ³éŸ³é¢‘æºã€‚Mute 是设置音é‡ä¸º 0ï¼Œå–æ¶ˆé™éŸ³æ˜¯æ¢å¤åŽŸæ¥çš„音é‡ã€‚ */ + mute: boolean; + /** !#en Is the audio source looping? + !#zh éŸ³é¢‘æºæ˜¯å¦å¾ªçŽ¯æ’æ”¾ï¼Ÿ */ + loop: boolean; + /** !#en If set to true, the audio source will automatically start playing on onEnable. + !#zh 如果设置为 true,音频æºå°†åœ¨ onEnable æ—¶è‡ªåŠ¨æ’æ”¾ã€‚ */ + playOnLoad: boolean; + /** !#en If set to true and AudioClip is a deferred load resource, the component will preload AudioClip in the onLoad phase. + !#zh 如果设置为 true 且 AudioClip ä¸ºå»¶è¿ŸåŠ è½½èµ„æºï¼Œç»„件将在 onLoad é˜¶æ®µé¢„åŠ è½½ AudioClip。 */ + preload: boolean; /** - !#en Removes a page from PageView. - !#zh ç§»é™¤æŒ‡å®šé¡µé¢ - @param page page + !#en Plays the clip. + !#zh æ’æ”¾éŸ³é¢‘剪辑。 + */ + play(): void; + /** + !#en Stops the clip. + !#zh åœæ¢å½“å‰éŸ³é¢‘剪辑。 + */ + stop(): void; + /** + !#en Pause the clip. + !#zh æš‚åœå½“å‰éŸ³é¢‘剪辑。 + */ + pause(): void; + /** + !#en Resume the clip. + !#zh æ¢å¤æ’放。 */ - removePage(page: Node): void; + resume(): void; /** - !#en Removes a page at index of PageView. - !#zh ç§»é™¤æŒ‡å®šä¸‹æ ‡çš„é¡µé¢ - @param index index + !#en Rewind playing music. + !#zh ä»Žå¤´å¼€å§‹æ’æ”¾ã€‚ */ - removePageAtIndex(index: number): void; + rewind(): void; /** - !#en Removes all pages from PageView - !#zh ç§»é™¤æ‰€æœ‰é¡µé¢ + !#en Get current time + !#zh 获å–当å‰çš„æ’æ”¾æ—¶é—´ */ - removeAllPages(): void; + getCurrentTime(): number; /** - !#en Scroll PageView to index. - !#zh æ»šåŠ¨åˆ°æŒ‡å®šé¡µé¢ - @param idx index of page. - @param timeInSecond scrolling time + !#en Set current time + !#zh 设置当å‰çš„æ’æ”¾æ—¶é—´ + @param time time */ - scrollToPage(idx: number, timeInSecond: number): void; - } - /** !#en The Page View Indicator Component - !#zh 页é¢è§†å›¾æ¯é¡µæ ‡è®°ç»„ä»¶ */ - export class PageViewIndicator extends Component { - /** !#en The spriteFrame for each element. - !#zh æ¯ä¸ªé¡µé¢æ ‡è®°æ˜¾ç¤ºçš„图片 */ - spriteFrame: SpriteFrame; - /** !#en The location direction of PageViewIndicator. - !#zh 页颿 ‡è®°æ‘†æ”¾æ–¹å‘ */ - direction: PageViewIndicator.Direction; - /** !#en The cellSize for each element. - !#zh æ¯ä¸ªé¡µé¢æ ‡è®°çš„å¤§å° */ - cellSize: Size; - /** !#en The distance between each element. - !#zh æ¯ä¸ªé¡µé¢æ ‡è®°ä¹‹é—´çš„è¾¹è· */ - spacing: number; + setCurrentTime(time: number): number; /** - !#en Set Page View - !#zh 设置页é¢è§†å›¾ - @param target target + !#en Get audio duration + !#zh 获å–当å‰éŸ³é¢‘的长度 */ - setPageView(target: PageView): void; + getDuration(): number; } /** !#en - Visual indicator of progress in some operation. - Displays a bar to the user representing how far the operation has progressed. + This component will block all input events (mouse and touch) within the bounding box of the node, preventing the input from penetrating into the underlying node, typically for the background of the top UI.<br> + This component does not have any API interface and can be added directly to the scene to take effect. !#zh - 进度æ¡ç»„件,å¯ç”¨äºŽæ˜¾ç¤ºåŠ è½½èµ„æºæ—¶çš„进度。 */ - export class ProgressBar extends Component { - /** !#en The targeted Sprite which will be changed progressively. - !#zh ç”¨æ¥æ˜¾ç¤ºè¿›åº¦æ¡æ¯”例的 Sprite 对象。 */ - barSprite: Sprite; - /** !#en The progress mode, there are two modes supported now: horizontal and vertical. - !#zh 进度æ¡çš„æ¨¡å¼ */ - mode: ProgressBar.Mode; - /** !#en The total width or height of the bar sprite. - !#zh 进度æ¡å®žé™…的总长度 */ - totalLength: number; - /** !#en The current progress of the bar sprite. The valid value is between 0-1. - !#zh 当å‰è¿›åº¦å€¼ï¼Œè¯¥æ•°å€¼çš„区间是 0-1 之间。 */ - progress: number; - /** !#en Whether reverse the progress direction of the bar sprite. - !#zh è¿›åº¦æ¡æ˜¯å¦è¿›è¡Œåæ–¹å‘å˜åŒ–。 */ - reverse: boolean; + 该组件将拦截所属节点 bounding box å†…çš„æ‰€æœ‰è¾“å…¥äº‹ä»¶ï¼ˆé¼ æ ‡å’Œè§¦æ‘¸ï¼‰ï¼Œé˜²æ¢è¾“入穿é€åˆ°ä¸‹å±‚节点,一般用于上层 UI 的背景。<br> + 该组件没有任何 API 接å£ï¼Œç›´æŽ¥æ·»åŠ åˆ°åœºæ™¯å³å¯ç”Ÿæ•ˆã€‚ */ + export class BlockInputEvents extends Component { } /** !#en - Base class for components which supports rendering features. + Button component. Can be pressed or clicked. Button has 4 Transition types: + + - Button.Transition.NONE // Button will do nothing + - Button.Transition.COLOR // Button will change target's color + - Button.Transition.SPRITE // Button will change target Sprite's sprite + - Button.Transition.SCALE // Button will change target node's scale + + The button can bind events (but you must be on the button's node to bind events).<br/> + The following events can be triggered on all platforms. + + - cc.Node.EventType.TOUCH_START // Press + - cc.Node.EventType.TOUCH_MOVE // After pressing and moving + - cc.Node.EventType.TOUCH_END // After pressing and releasing + - cc.Node.EventType.TOUCH_CANCEL // Press to cancel + + The following events are only triggered on the PC platform: + + - cc.Node.EventType.MOUSE_DOWN + - cc.Node.EventType.MOUSE_MOVE + - cc.Node.EventType.MOUSE_ENTER + - cc.Node.EventType.MOUSE_LEAVE + - cc.Node.EventType.MOUSE_UP + - cc.Node.EventType.MOUSE_WHEEL + + User can get the current clicked node with 'event.target' from event object which is passed as parameter in the callback function of click event. + !#zh - æ‰€æœ‰æ”¯æŒæ¸²æŸ“的组件的基类 */ - export class RenderComponent extends Component { - /** !#en The materials used by this render component. - !#zh 渲染组件使用的æè´¨ã€‚ */ - sharedMaterials: Material[]; + 按钮组件。å¯ä»¥è¢«æŒ‰ä¸‹ï¼Œæˆ–者点击。 + + 按钮å¯ä»¥é€šè¿‡ä¿®æ”¹ Transition æ¥è®¾ç½®æŒ‰é’®çжæ€è¿‡æ¸¡çš„æ–¹å¼ï¼š + + - Button.Transition.NONE // ä¸åšä»»ä½•过渡 + - Button.Transition.COLOR // 进行颜色之间过渡 + - Button.Transition.SPRITE // 进行精çµä¹‹é—´è¿‡æ¸¡ + - Button.Transition.SCALE // 进行缩放过渡 + + 按钮å¯ä»¥ç»‘定事件(但是必须è¦åœ¨æŒ‰é’®çš„ Node 上æ‰èƒ½ç»‘定事件):<br/> + 以下事件å¯ä»¥åœ¨å…¨å¹³å°ä¸Šéƒ½è§¦å‘: + + - cc.Node.EventType.TOUCH_START // 按下时事件 + - cc.Node.EventType.TOUCH_MOVE // 按ä½ç§»åЍåŽäº‹ä»¶ + - cc.Node.EventType.TOUCH_END // æŒ‰ä¸‹åŽæ¾å¼€åŽäº‹ä»¶ + - cc.Node.EventType.TOUCH_CANCEL // æŒ‰ä¸‹å–æ¶ˆäº‹ä»¶ + + 以下事件åªåœ¨ PC å¹³å°ä¸Šè§¦å‘: + + - cc.Node.EventType.MOUSE_DOWN // é¼ æ ‡æŒ‰ä¸‹æ—¶äº‹ä»¶ + - cc.Node.EventType.MOUSE_MOVE // é¼ æ ‡æŒ‰ä½ç§»åЍåŽäº‹ä»¶ + - cc.Node.EventType.MOUSE_ENTER // é¼ æ ‡è¿›å…¥ç›®æ ‡äº‹ä»¶ + - cc.Node.EventType.MOUSE_LEAVE // é¼ æ ‡ç¦»å¼€ç›®æ ‡äº‹ä»¶ + - cc.Node.EventType.MOUSE_UP // é¼ æ ‡æ¾å¼€äº‹ä»¶ + - cc.Node.EventType.MOUSE_WHEEL // é¼ æ ‡æ»šè½®äº‹ä»¶ + + 用户å¯ä»¥é€šè¿‡èŽ·å– __点击事件__ å›žè°ƒå‡½æ•°çš„å‚æ•° event çš„ target 属性获å–当å‰ç‚¹å‡»å¯¹è±¡ã€‚ */ + export class Button extends Component implements GraySpriteState { + /** !#en + Whether the Button is disabled. + If true, the Button will trigger event and do transition. + !#zh + 按钮事件是å¦è¢«å“应,如果为 false,则按钮将被ç¦ç”¨ã€‚ */ + interactable: boolean; + /** !#en When this flag is true, Button target sprite will turn gray when interactable is false. + !#zh å¦‚æžœè¿™ä¸ªæ ‡è®°ä¸º true,当 button çš„ interactable 属性为 false 的时候,会使用内置 shader 让 button çš„ target 节点的 sprite 组件å˜ç° */ + enableAutoGrayEffect: boolean; + /** !#en Transition type + !#zh æŒ‰é’®çŠ¶æ€æ”¹å˜æ—¶è¿‡æ¸¡æ–¹å¼ã€‚ */ + transition: Button.Transition; + /** !#en Normal state color. + !#zh 普通状æ€ä¸‹æŒ‰é’®æ‰€æ˜¾ç¤ºçš„颜色。 */ + normalColor: Color; + /** !#en Pressed state color + !#zh æŒ‰ä¸‹çŠ¶æ€æ—¶æŒ‰é’®æ‰€æ˜¾ç¤ºçš„颜色。 */ + pressedColor: Color; + /** !#en Hover state color + !#zh 悬åœçжæ€ä¸‹æŒ‰é’®æ‰€æ˜¾ç¤ºçš„颜色。 */ + hoverColor: Color; + /** !#en Disabled state color + !#zh ç¦ç”¨çжæ€ä¸‹æŒ‰é’®æ‰€æ˜¾ç¤ºçš„颜色。 */ + disabledColor: Color; + /** !#en Color and Scale transition duration + !#zh 颜色过渡和缩放过渡时所需时间 */ + duration: number; + /** !#en When user press the button, the button will zoom to a scale. + The final scale of the button equals (button original scale * zoomScale) + !#zh 当用户点击按钮åŽï¼ŒæŒ‰é’®ä¼šç¼©æ”¾åˆ°ä¸€ä¸ªå€¼ï¼Œè¿™ä¸ªå€¼ç‰äºŽ Button 原始 scale * zoomScale */ + zoomScale: number; + /** !#en Normal state sprite + !#zh 普通状æ€ä¸‹æŒ‰é’®æ‰€æ˜¾ç¤ºçš„ Sprite 。 */ + normalSprite: SpriteFrame; + /** !#en Pressed state sprite + !#zh æŒ‰ä¸‹çŠ¶æ€æ—¶æŒ‰é’®æ‰€æ˜¾ç¤ºçš„ Sprite 。 */ + pressedSprite: SpriteFrame; + /** !#en Hover state sprite + !#zh 悬åœçжæ€ä¸‹æŒ‰é’®æ‰€æ˜¾ç¤ºçš„ Sprite 。 */ + hoverSprite: SpriteFrame; + /** !#en Disabled state sprite + !#zh ç¦ç”¨çжæ€ä¸‹æŒ‰é’®æ‰€æ˜¾ç¤ºçš„ Sprite 。 */ + disabledSprite: SpriteFrame; + /** !#en + Transition target. + When Button state changed: + If Transition type is Button.Transition.NONE, Button will do nothing + If Transition type is Button.Transition.COLOR, Button will change target's color + If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite + !#zh + 需è¦è¿‡æ¸¡çš„ç›®æ ‡ã€‚ + 当剿Œ‰é’®çŠ¶æ€æ”¹å˜è§„则: + -如果 Transition type 选择 Button.Transition.NONE,按钮ä¸åšä»»ä½•过渡。 + -如果 Transition type 选择 Button.Transition.COLORï¼ŒæŒ‰é’®ä¼šå¯¹ç›®æ ‡é¢œè‰²è¿›è¡Œé¢œè‰²ä¹‹é—´çš„è¿‡æ¸¡ã€‚ + -如果 Transition type 选择 Button.Transition.Spriteï¼ŒæŒ‰é’®ä¼šå¯¹ç›®æ ‡ Sprite 进行 Sprite 之间的过渡。 */ + target: Node; + /** !#en If Button is clicked, it will trigger event's handler + !#zh 按钮的点击事件列表。 */ + clickEvents: Component.EventHandler[]; + /** !#en The normal material. + !#zh æ£å¸¸çжæ€çš„æè´¨ã€‚ */ + normalMaterial: Material; + /** !#en The gray material. + !#zh ç½®ç°çжæ€çš„æè´¨ã€‚ */ + grayMaterial: Material; + } + /** !#zh 作为 UI æ ¹èŠ‚ç‚¹ï¼Œä¸ºæ‰€æœ‰å节点æä¾›è§†çª—四边的ä½ç½®ä¿¡æ¯ä»¥ä¾›å¯¹é½ï¼Œå¦å¤–æä¾›å±å¹•适é…ç–略接å£ï¼Œæ–¹ä¾¿ä»Žç¼–辑器设置。<br> + 注:由于本节点的尺寸会跟éšå±å¹•拉伸,所以 anchorPoint åªæ”¯æŒ (0.5, 0.5),å¦åˆ™é€‚é…ä¸åŒå±å¹•æ—¶åæ ‡ä¼šæœ‰å差。 */ + export class Canvas extends Component { + /** !#en Current active canvas, the scene should only have one active canvas at the same time. + !#zh 当剿¿€æ´»çš„画布组件,场景åŒä¸€æ—¶é—´åªèƒ½æœ‰ä¸€ä¸ªæ¿€æ´»çš„画布。 */ + static instance: Canvas; + /** !#en The desigin resolution for current scene. + !#zh 当å‰åœºæ™¯è®¾è®¡åˆ†è¾¨çŽ‡ã€‚ */ + designResolution: Size; + /** !#en TODO + !#zh: 是å¦ä¼˜å…ˆå°†è®¾è®¡åˆ†è¾¨çŽ‡é«˜åº¦æ’‘æ»¡è§†å›¾é«˜åº¦ã€‚ */ + fitHeight: boolean; + /** !#en TODO + !#zh: 是å¦ä¼˜å…ˆå°†è®¾è®¡åˆ†è¾¨çŽ‡å®½åº¦æ’‘æ»¡è§†å›¾å®½åº¦ã€‚ */ + fitWidth: boolean; + } + /** !#en + Base class for everything attached to Node(Entity).<br/> + <br/> + NOTE: Not allowed to use construction parameters for Component's subclasses, + because Component is created by the engine. + !#zh + æ‰€æœ‰é™„åŠ åˆ°èŠ‚ç‚¹çš„åŸºç±»ã€‚<br/> + <br/> + 注æ„:ä¸å…许使用组件的åç±»æž„é€ å‚æ•°ï¼Œå› 为组件是由引擎创建的。 */ + export class Component extends Object { + /** !#en The node this component is attached to. A component is always attached to a node. + !#zh è¯¥ç»„ä»¶è¢«é™„åŠ åˆ°çš„èŠ‚ç‚¹ã€‚ç»„ä»¶æ€»ä¼šé™„åŠ åˆ°ä¸€ä¸ªèŠ‚ç‚¹ã€‚ */ + node: Node; + /** !#en The uuid for editor. + !#zh 组件的 uuid,用于编辑器。 */ + uuid: string; + /** !#en indicates whether this component is enabled or not. + !#zh 表示该组件自身是å¦å¯ç”¨ã€‚ */ + enabled: boolean; + /** !#en indicates whether this component is enabled and its node is also active in the hierarchy. + !#zh 表示该组件是å¦è¢«å¯ç”¨å¹¶ä¸”所在的节点也处于激活状æ€ã€‚ */ + enabledInHierarchy: boolean; + /** !#en Returns a value which used to indicate the onLoad get called or not. + !#zh 返回一个值用æ¥åˆ¤æ– onLoad 是å¦è¢«è°ƒç”¨è¿‡ï¼Œä¸ç‰äºŽ 0 时调用过,ç‰äºŽ 0 时未调用。 */ + _isOnLoadCalled: number; + /** + !#en Update is called every frame, if the Component is enabled.<br/> + This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 如果该组件å¯ç”¨ï¼Œåˆ™æ¯å¸§è°ƒç”¨ update。<br/> + è¯¥æ–¹æ³•ä¸ºç”Ÿå‘½å‘¨æœŸæ–¹æ³•ï¼Œçˆ¶ç±»æœªå¿…ä¼šæœ‰å®žçŽ°ã€‚å¹¶ä¸”ä½ åªèƒ½åœ¨è¯¥æ–¹æ³•内部调用父类的实现,ä¸å¯åœ¨å…¶å®ƒåœ°æ–¹ç›´æŽ¥è°ƒç”¨è¯¥æ–¹æ³•。 + @param dt the delta time in seconds it took to complete the last frame + */ + protected update(dt: number): void; + /** + !#en LateUpdate is called every frame, if the Component is enabled.<br/> + This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 如果该组件å¯ç”¨ï¼Œåˆ™æ¯å¸§è°ƒç”¨ LateUpdate。<br/> + è¯¥æ–¹æ³•ä¸ºç”Ÿå‘½å‘¨æœŸæ–¹æ³•ï¼Œçˆ¶ç±»æœªå¿…ä¼šæœ‰å®žçŽ°ã€‚å¹¶ä¸”ä½ åªèƒ½åœ¨è¯¥æ–¹æ³•内部调用父类的实现,ä¸å¯åœ¨å…¶å®ƒåœ°æ–¹ç›´æŽ¥è°ƒç”¨è¯¥æ–¹æ³•。 + @param dt the delta time in seconds it took to complete the last frame + */ + protected lateUpdate(dt: number): void; + /** + !#en + When attaching to an active node or its node first activated. + onLoad is always called before any start functions, this allows you to order initialization of scripts.<br/> + This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh + å½“é™„åŠ åˆ°ä¸€ä¸ªæ¿€æ´»çš„èŠ‚ç‚¹ä¸Šæˆ–è€…å…¶èŠ‚ç‚¹ç¬¬ä¸€æ¬¡æ¿€æ´»æ—¶å€™è°ƒç”¨ã€‚onLoad 总是会在任何 start æ–¹æ³•è°ƒç”¨å‰æ‰§è¡Œï¼Œè¿™èƒ½ç”¨äºŽå®‰æŽ’脚本的åˆå§‹åŒ–顺åºã€‚<br/> + è¯¥æ–¹æ³•ä¸ºç”Ÿå‘½å‘¨æœŸæ–¹æ³•ï¼Œçˆ¶ç±»æœªå¿…ä¼šæœ‰å®žçŽ°ã€‚å¹¶ä¸”ä½ åªèƒ½åœ¨è¯¥æ–¹æ³•内部调用父类的实现,ä¸å¯åœ¨å…¶å®ƒåœ°æ–¹ç›´æŽ¥è°ƒç”¨è¯¥æ–¹æ³•。 + */ + protected onLoad(): void; + /** + !#en + Called before all scripts' update if the Component is enabled the first time. + Usually used to initialize some logic which need to be called after all components' `onload` methods called.<br/> + This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh + 如果该组件第一次å¯ç”¨ï¼Œåˆ™åœ¨æ‰€æœ‰ç»„ä»¶çš„ update 之å‰è°ƒç”¨ã€‚通常用于需è¦åœ¨æ‰€æœ‰ç»„ä»¶çš„ onLoad åˆå§‹åŒ–å®Œæ¯•åŽæ‰§è¡Œçš„逻辑。<br/> + è¯¥æ–¹æ³•ä¸ºç”Ÿå‘½å‘¨æœŸæ–¹æ³•ï¼Œçˆ¶ç±»æœªå¿…ä¼šæœ‰å®žçŽ°ã€‚å¹¶ä¸”ä½ åªèƒ½åœ¨è¯¥æ–¹æ³•内部调用父类的实现,ä¸å¯åœ¨å…¶å®ƒåœ°æ–¹ç›´æŽ¥è°ƒç”¨è¯¥æ–¹æ³•。 + */ + protected start(): void; /** - !#en Get the material by index. - !#zh æ ¹æ®æŒ‡å®šç´¢å¼•èŽ·å–æè´¨ - @param index index + !#en Called when this component becomes enabled and its node is active.<br/> + This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 当该组件被å¯ç”¨ï¼Œå¹¶ä¸”它的节点也激活时。<br/> + è¯¥æ–¹æ³•ä¸ºç”Ÿå‘½å‘¨æœŸæ–¹æ³•ï¼Œçˆ¶ç±»æœªå¿…ä¼šæœ‰å®žçŽ°ã€‚å¹¶ä¸”ä½ åªèƒ½åœ¨è¯¥æ–¹æ³•内部调用父类的实现,ä¸å¯åœ¨å…¶å®ƒåœ°æ–¹ç›´æŽ¥è°ƒç”¨è¯¥æ–¹æ³•。 */ - getMaterial(index: number): MaterialVariant; + protected onEnable(): void; /** - !#en Gets all the materials. - !#zh èŽ·å–æ‰€æœ‰æè´¨ã€‚ + !#en Called when this component becomes disabled or its node becomes inactive.<br/> + This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh 当该组件被ç¦ç”¨æˆ–节点å˜ä¸ºæ— 效时调用。<br/> + è¯¥æ–¹æ³•ä¸ºç”Ÿå‘½å‘¨æœŸæ–¹æ³•ï¼Œçˆ¶ç±»æœªå¿…ä¼šæœ‰å®žçŽ°ã€‚å¹¶ä¸”ä½ åªèƒ½åœ¨è¯¥æ–¹æ³•内部调用父类的实现,ä¸å¯åœ¨å…¶å®ƒåœ°æ–¹ç›´æŽ¥è°ƒç”¨è¯¥æ–¹æ³•。 */ - getMaterials(): MaterialVariant[]; + protected onDisable(): void; /** - !#en Set the material by index. - !#zh æ ¹æ®æŒ‡å®šç´¢å¼•设置æè´¨ - @param index index - @param material material + !#en Called when this component will be destroyed.<br/> + This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere. + !#zh å½“è¯¥ç»„ä»¶è¢«é”€æ¯æ—¶è°ƒç”¨<br/> + è¯¥æ–¹æ³•ä¸ºç”Ÿå‘½å‘¨æœŸæ–¹æ³•ï¼Œçˆ¶ç±»æœªå¿…ä¼šæœ‰å®žçŽ°ã€‚å¹¶ä¸”ä½ åªèƒ½åœ¨è¯¥æ–¹æ³•内部调用父类的实现,ä¸å¯åœ¨å…¶å®ƒåœ°æ–¹ç›´æŽ¥è°ƒç”¨è¯¥æ–¹æ³•。 */ - setMaterial(index: number, material: Material): Material; - } - /** !#en The RichText Component. - !#zh 富文本组件 */ - export class RichText extends Component { - /** !#en Content string of RichText. - !#zh 富文本显示的文本内容。 */ - string: string; - /** !#en Horizontal Alignment of each line in RichText. - !#zh æ–‡æœ¬å†…å®¹çš„æ°´å¹³å¯¹é½æ–¹å¼ã€‚ */ - horizontalAlign: macro.TextAlignment; - /** !#en Font size of RichText. - !#zh 富文本å—体大å°ã€‚ */ - fontSize: number; - /** !#en Custom System font of RichText - !#zh 富文本定制系统å—体 */ - fontFamily: string; - /** !#en Custom TTF font of RichText - !#zh 富文本定制å—体 */ - font: TTFFont; - /** !#en Whether use system font name or not. - !#zh 是å¦ä½¿ç”¨ç³»ç»Ÿå—体。 */ - useSystemFont: boolean; - /** !#en The cache mode of label. This mode only supports system fonts. - !#zh æ–‡æœ¬ç¼“å˜æ¨¡å¼, 该模å¼åªæ”¯æŒç³»ç»Ÿå—体。 */ - cacheMode: Label.CacheMode; - /** !#en The maximize width of the RichText - !#zh 富文本的最大宽度 */ - maxWidth: number; - /** !#en Line Height of RichText. - !#zh 富文本行高。 */ - lineHeight: number; - /** !#en The image atlas for the img tag. For each src value in the img tag, there should be a valid spriteFrame in the image atlas. - !#zh 对于 img æ ‡ç¾é‡Œé¢çš„ src 属性å称,都需è¦åœ¨ imageAtlas é‡Œé¢æ‰¾åˆ°ä¸€ä¸ªæœ‰æ•ˆçš„ spriteFrame,å¦åˆ™ img tag ä¼šåˆ¤å®šä¸ºæ— æ•ˆã€‚ */ - imageAtlas: SpriteAtlas; - /** !#en - Once checked, the RichText will block all input events (mouse and touch) within - the bounding box of the node, preventing the input from penetrating into the underlying node. - !#zh - 选䏿¤é€‰é¡¹åŽï¼ŒRichText 将阻æ¢èŠ‚ç‚¹è¾¹ç•Œæ¡†ä¸çš„æ‰€æœ‰è¾“å…¥äº‹ä»¶ï¼ˆé¼ æ ‡å’Œè§¦æ‘¸ï¼‰ï¼Œä»Žè€Œé˜²æ¢è¾“入事件穿é€åˆ°åº•层节点。 */ - handleTouchEvent: boolean; - } - /** !#en - This component is used to adjust the layout of current node to respect the safe area of a notched mobile device such as the iPhone X. - It is typically used for the top node of the UI interaction area. For specific usage, refer to the official [example-cases/02_ui/16_safeArea/SafeArea.fire](https://github.com/cocos-creator/example-cases). - - The concept of safe area is to give you a fixed inner rectangle in which you can safely display content that will be drawn on screen. - You are strongly discouraged from providing controls outside of this area. But your screen background could embellish edges. - - This component internally uses the API `cc.sys.getSafeAreaRect();` to obtain the safe area of the current iOS or Android device, - and implements the adaptation by using the Widget component and set anchor. - - !#zh - 该组件会将所在节点的布局适é…到 iPhone X ç‰å¼‚形屿‰‹æœºçš„安全区域内,通常用于 UI 交互区域的顶层节点,具体用法å¯å‚考官方范例 [example-cases/02_ui/16_safeArea/SafeArea.fire](https://github.com/cocos-creator/example-cases)。 - - 该组件内部通过 API `cc.sys.getSafeAreaRect();` 获å–åˆ°å½“å‰ iOS 或 Android 设备的安全区域,并通过 Widget 组件实现适é…。 */ - export class SafeArea extends Component { + protected onDestroy(): void; + protected onFocusInEditor(): void; + protected onLostFocusInEditor(): void; /** - !#en Adapt to safe area - !#zh ç«‹å³é€‚é…安全区域 + !#en Called to initialize the component or node’s properties when adding the component the first time or when the Reset command is used. This function is only called in editor. + !#zh 用æ¥åˆå§‹åŒ–ç»„ä»¶æˆ–èŠ‚ç‚¹çš„ä¸€äº›å±žæ€§ï¼Œå½“è¯¥ç»„ä»¶è¢«ç¬¬ä¸€æ¬¡æ·»åŠ åˆ°èŠ‚ç‚¹ä¸Šæˆ–ç”¨æˆ·ç‚¹å‡»äº†å®ƒçš„ Reset èœå•时调用。这个回调åªä¼šåœ¨ç¼–辑器下调用。 + */ + protected resetInEditor(): void; + /** + !#en Adds a component class to the node. You can also add component to node by passing in the name of the script. + !#zh å‘èŠ‚ç‚¹æ·»åŠ ä¸€ä¸ªç»„ä»¶ç±»ï¼Œä½ è¿˜å¯ä»¥é€šè¿‡ä¼ 入脚本的åç§°æ¥æ·»åŠ ç»„ä»¶ã€‚ + @param typeOrClassName the constructor or the class name of the component to add @example ```js - let safeArea = this.node.addComponent(cc.SafeArea); - safeArea.updateArea(); + var sprite = node.addComponent(cc.Sprite); + var test = node.addComponent("Test"); ``` */ - updateArea(): void; - } - /** !#en - The Scrollbar control allows the user to scroll an image or other view that is too large to see completely - !#zh 滚动æ¡ç»„ä»¶ */ - export class Scrollbar extends Component { - /** !#en The "handle" part of the scrollbar. - !#zh ä½œä¸ºå½“å‰æ»šåŠ¨åŒºåŸŸä½ç½®æ˜¾ç¤ºçš„æ»‘å— Sprite。 */ - handle: Sprite; - /** !#en The direction of scrollbar. - !#zh ScrollBar 的滚动方å‘。 */ - direction: Scrollbar.Direction; - /** !#en Whether enable auto hide or not. - !#zh 是å¦åœ¨æ²¡æœ‰æ»šåŠ¨åŠ¨ä½œæ—¶è‡ªåŠ¨éšè— ScrollBar。 */ - enableAutoHide: boolean; - /** !#en - The time to hide scrollbar when scroll finished. - Note: This value is only useful when enableAutoHide is true. - !#zh - 没有滚动动作åŽç»è¿‡å¤šä¹…会自动éšè—。 - 注æ„:åªè¦å½“ “enableAutoHide†为 true æ—¶ï¼Œæ‰æœ‰æ•ˆã€‚ */ - autoHideTime: number; - } - /** !#en - Layout container for a view hierarchy that can be scrolled by the user, - allowing it to be larger than the physical display. - - !#zh - 滚动视图组件 */ - export class ScrollView extends Component { - /** !#en This is a reference to the UI element to be scrolled. - !#zh 坿»šåŠ¨å±•ç¤ºå†…å®¹çš„èŠ‚ç‚¹ã€‚ */ - content: Node; - /** !#en Enable horizontal scroll. - !#zh 是å¦å¼€å¯æ°´å¹³æ»šåŠ¨ã€‚ */ - horizontal: boolean; - /** !#en Enable vertical scroll. - !#zh 是å¦å¼€å¯åž‚直滚动。 */ - vertical: boolean; - /** !#en When inertia is set, the content will continue to move when touch ended. - !#zh 是å¦å¼€å¯æ»šåŠ¨æƒ¯æ€§ã€‚ */ - inertia: boolean; - /** !#en - It determines how quickly the content stop moving. A value of 1 will stop the movement immediately. - A value of 0 will never stop the movement until it reaches to the boundary of scrollview. - !#zh - 开坿ƒ¯æ€§åŽï¼Œåœ¨ç”¨æˆ·åœæ¢è§¦æ‘¸åŽæ»šåŠ¨å¤šå¿«åœæ¢ï¼Œ0表示永ä¸åœæ¢ï¼Œ1è¡¨ç¤ºç«‹åˆ»åœæ¢ã€‚ */ - brake: number; - /** !#en When elastic is set, the content will be bounce back when move out of boundary. - !#zh 是å¦å…è®¸æ»šåŠ¨å†…å®¹è¶…è¿‡è¾¹ç•Œï¼Œå¹¶åœ¨åœæ¢è§¦æ‘¸åŽå›žå¼¹ã€‚ */ - elastic: boolean; - /** !#en The elapse time of bouncing back. A value of 0 will bounce back immediately. - !#zh 回弹æŒç»çš„æ—¶é—´ï¼Œ0 表示将立å³å弹。 */ - bounceDuration: number; - /** !#en The horizontal scrollbar reference. - !#zh 水平滚动的 ScrollBar。 */ - horizontalScrollBar: Scrollbar; - /** !#en The vertical scrollbar reference. - !#zh 垂直滚动的 ScrollBar。 */ - verticalScrollBar: Scrollbar; - /** !#en Scrollview events callback - !#zh 滚动视图的事件回调函数 */ - scrollEvents: Component.EventHandler[]; - /** !#en If cancelInnerEvents is set to true, the scroll behavior will cancel touch events on inner content nodes - It's set to true by default. - !#zh 如果这个属性被设置为 trueï¼Œé‚£ä¹ˆæ»šåŠ¨è¡Œä¸ºä¼šå–æ¶ˆå节点上注册的触摸事件,默认被设置为 true。 - 注æ„,å节点上的 touchstart 事件ä»ç„¶ä¼šè§¦å‘,触点移动è·ç¦»éžå¸¸çŸçš„æƒ…况下 touchmove å’Œ touchend 也ä¸ä¼šå—å½±å“。 */ - cancelInnerEvents: boolean; + addComponent<T extends Component>(type: {new(): T}): T; + addComponent(className: string): any; /** - !#en Scroll the content to the bottom boundary of ScrollView. - !#zh 视图内容将在规定时间内滚动到视图底部。 - @param timeInSecond Scroll time in second, if you don't pass timeInSecond, - the content will jump to the bottom boundary immediately. - @param attenuated Whether the scroll acceleration attenuated, default is true. + !#en + Returns the component of supplied type if the node has one attached, null if it doesn't.<br/> + You can also get component in the node by passing in the name of the script. + !#zh + 获å–èŠ‚ç‚¹ä¸ŠæŒ‡å®šç±»åž‹çš„ç»„ä»¶ï¼Œå¦‚æžœèŠ‚ç‚¹æœ‰é™„åŠ æŒ‡å®šç±»åž‹çš„ç»„ä»¶ï¼Œåˆ™è¿”å›žï¼Œå¦‚æžœæ²¡æœ‰åˆ™ä¸ºç©ºã€‚<br/> + ä¼ å…¥å‚æ•°ä¹Ÿå¯ä»¥æ˜¯è„šæœ¬çš„å称。 + @param typeOrClassName typeOrClassName @example ```js - // Scroll to the bottom of the view. - scrollView.scrollToBottom(0.1); + // get sprite component. + var sprite = node.getComponent(cc.Sprite); + // get custom test calss. + var test = node.getComponent("Test"); ``` */ - scrollToBottom(timeInSecond?: number, attenuated?: boolean): void; + getComponent<T extends Component>(type: {prototype: T}): T; + getComponent(className: string): any; /** - !#en Scroll the content to the top boundary of ScrollView. - !#zh 视图内容将在规定时间内滚动到视图顶部。 - @param timeInSecond Scroll time in second, if you don't pass timeInSecond, - the content will jump to the top boundary immediately. - @param attenuated Whether the scroll acceleration attenuated, default is true. + !#en Returns all components of supplied Type in the node. + !#zh 返回节点上指定类型的所有组件。 + @param typeOrClassName typeOrClassName @example ```js - // Scroll to the top of the view. - scrollView.scrollToTop(0.1); + var sprites = node.getComponents(cc.Sprite); + var tests = node.getComponents("Test"); ``` */ - scrollToTop(timeInSecond?: number, attenuated?: boolean): void; + getComponents<T extends Component>(type: {prototype: T}): T[]; + getComponents(className: string): any[]; /** - !#en Scroll the content to the left boundary of ScrollView. - !#zh 视图内容将在规定时间内滚动到视图左边。 - @param timeInSecond Scroll time in second, if you don't pass timeInSecond, - the content will jump to the left boundary immediately. - @param attenuated Whether the scroll acceleration attenuated, default is true. + !#en Returns the component of supplied type in any of its children using depth first search. + !#zh 递归查找所有å节点ä¸ç¬¬ä¸€ä¸ªåŒ¹é…指定类型的组件。 + @param typeOrClassName typeOrClassName @example ```js - // Scroll to the left of the view. - scrollView.scrollToLeft(0.1); + var sprite = node.getComponentInChildren(cc.Sprite); + var Test = node.getComponentInChildren("Test"); ``` */ - scrollToLeft(timeInSecond?: number, attenuated?: boolean): void; + getComponentInChildren<T extends Component>(type: {prototype: T}): T; + getComponentInChildren(className: string): any; /** - !#en Scroll the content to the right boundary of ScrollView. - !#zh 视图内容将在规定时间内滚动到视图å³è¾¹ã€‚ - @param timeInSecond Scroll time in second, if you don't pass timeInSecond, - the content will jump to the right boundary immediately. - @param attenuated Whether the scroll acceleration attenuated, default is true. + !#en Returns the components of supplied type in self or any of its children using depth first search. + !#zh 递归查找自身或所有åèŠ‚ç‚¹ä¸æŒ‡å®šç±»åž‹çš„组件 + @param typeOrClassName typeOrClassName @example ```js - // Scroll to the right of the view. - scrollView.scrollToRight(0.1); + var sprites = node.getComponentsInChildren(cc.Sprite); + var tests = node.getComponentsInChildren("Test"); ``` */ - scrollToRight(timeInSecond?: number, attenuated?: boolean): void; + getComponentsInChildren<T extends Component>(type: {prototype: T}): T[]; + getComponentsInChildren(className: string): any[]; /** - !#en Scroll the content to the top left boundary of ScrollView. - !#zh 视图内容将在规定时间内滚动到视图左上角。 - @param timeInSecond Scroll time in second, if you don't pass timeInSecond, - the content will jump to the top left boundary immediately. - @param attenuated Whether the scroll acceleration attenuated, default is true. + !#en + If the component's bounding box is different from the node's, you can implement this method to supply + a custom axis aligned bounding box (AABB), so the editor's scene view can perform hit test properly. + !#zh + 如果组件的包围盒与节点ä¸åŒï¼Œæ‚¨å¯ä»¥å®žçŽ°è¯¥æ–¹æ³•ä»¥æä¾›è‡ªå®šä¹‰çš„è½´å‘对é½çš„包围盒(AABB), + 以便编辑器的场景视图å¯ä»¥æ£ç¡®åœ°æ‰§è¡Œç‚¹é€‰æµ‹è¯•。 + @param out_rect the Rect to receive the bounding box + */ + _getLocalBounds(out_rect: Rect): void; + /** + !#en + onRestore is called after the user clicks the Reset item in the Inspector's context menu or performs + an undo operation on this component.<br/> + <br/> + If the component contains the "internal state", short for "temporary member variables which not included<br/> + in its CCClass properties", then you may need to implement this function.<br/> + <br/> + The editor will call the getset accessors of your component to record/restore the component's state<br/> + for undo/redo operation. However, in extreme cases, it may not works well. Then you should implement<br/> + this function to manually synchronize your component's "internal states" with its public properties.<br/> + Once you implement this function, all the getset accessors of your component will not be called when<br/> + the user performs an undo/redo operation. Which means that only the properties with default value<br/> + will be recorded or restored by editor.<br/> + <br/> + Similarly, the editor may failed to reset your component correctly in extreme cases. Then if you need<br/> + to support the reset menu, you should manually synchronize your component's "internal states" with its<br/> + properties in this function. Once you implement this function, all the getset accessors of your component<br/> + will not be called during reset operation. Which means that only the properties with default value<br/> + will be reset by editor. - @example - ```js - // Scroll to the upper left corner of the view. - scrollView.scrollToTopLeft(0.1); - ``` + This function is only called in editor mode. + !#zh + onRestore 是用户在检查器èœå•点击 Reset 时,对æ¤ç»„件执行撤消æ“作åŽè°ƒç”¨çš„。<br/> + <br/> + 如果组件包å«äº†â€œå†…部状æ€â€ï¼ˆä¸åœ¨ CCClass 属性ä¸å®šä¹‰çš„临时æˆå‘˜å˜é‡ï¼‰ï¼Œé‚£ä¹ˆä½ å¯èƒ½éœ€è¦å®žçŽ°è¯¥æ–¹æ³•ã€‚<br/> + <br/> + 编辑器执行撤销/é‡åšæ“作时,将调用组件的 get set æ¥å½•制和还原组件的状æ€ã€‚然而,在æžç«¯çš„æƒ…况下,它å¯èƒ½æ— 法良好è¿ä½œã€‚<br/> + é‚£ä¹ˆä½ å°±åº”è¯¥å®žçŽ°è¿™ä¸ªæ–¹æ³•ï¼Œæ‰‹åŠ¨æ ¹æ®ç»„ä»¶çš„å±žæ€§åŒæ¥â€œå†…部状æ€â€ã€‚ä¸€æ—¦ä½ å®žçŽ°è¿™ä¸ªæ–¹æ³•ï¼Œå½“ç”¨æˆ·æ’¤é”€æˆ–é‡åšæ—¶ï¼Œç»„ä»¶çš„æ‰€æœ‰ get set 都ä¸ä¼šå†è¢«è°ƒç”¨ã€‚è¿™æ„味ç€ä»…仅指定了默认值的属性将被编辑器记录和还原。<br/> + <br/> + åŒæ ·çš„,编辑å¯èƒ½æ— 法在æžç«¯æƒ…况下æ£ç¡®åœ°é‡ç½®æ‚¨çš„ç»„ä»¶ã€‚å¦‚æžœä½ éœ€è¦æ”¯æŒç»„ä»¶é‡ç½®èœå•,则需è¦åœ¨è¯¥æ–¹æ³•䏿‰‹å·¥åŒæ¥ç»„件属性到“内部状æ€â€ã€‚ä¸€æ—¦ä½ å®žçŽ°è¿™ä¸ªæ–¹æ³•ï¼Œç»„ä»¶çš„æ‰€æœ‰ get set 都ä¸ä¼šåœ¨é‡ç½®æ“作时被调用。这æ„味ç€ä»…仅指定了默认值的属性将被编辑器é‡ç½®ã€‚ + <br/> + æ¤æ–¹æ³•仅在编辑器下会被调用。 */ - scrollToTopLeft(timeInSecond?: number, attenuated?: boolean): void; + onRestore(): void; /** - !#en Scroll the content to the top right boundary of ScrollView. - !#zh 视图内容将在规定时间内滚动到视图å³ä¸Šè§’。 - @param timeInSecond Scroll time in second, if you don't pass timeInSecond, - the content will jump to the top right boundary immediately. - @param attenuated Whether the scroll acceleration attenuated, default is true. + !#en + Schedules a custom selector.<br/> + If the selector is already scheduled, then the interval parameter will be updated without scheduling it again. + !#zh + 调度一个自定义的回调函数。<br/> + 如果回调函数已调度,那么将ä¸ä¼šé‡å¤è°ƒåº¦å®ƒï¼Œåªä¼šæ›´æ–°æ—¶é—´é—´éš”傿•°ã€‚ + @param callback The callback function + @param interval Tick interval in seconds. 0 means tick every frame. + @param repeat The selector will be executed (repeat + 1) times, you can use cc.macro.REPEAT_FOREVER for tick infinitely. + @param delay The amount of time that the first tick will wait before execution. Unit: s @example ```js - // Scroll to the top right corner of the view. - scrollView.scrollToTopRight(0.1); + var timeCallback = function (dt) { + cc.log("time: " + dt); + } + this.schedule(timeCallback, 1); ``` */ - scrollToTopRight(timeInSecond?: number, attenuated?: boolean): void; + schedule(callback: Function, interval?: number, repeat?: number, delay?: number): void; /** - !#en Scroll the content to the bottom left boundary of ScrollView. - !#zh 视图内容将在规定时间内滚动到视图左下角。 - @param timeInSecond Scroll time in second, if you don't pass timeInSecond, - the content will jump to the bottom left boundary immediately. - @param attenuated Whether the scroll acceleration attenuated, default is true. + !#en Schedules a callback function that runs only once, with a delay of 0 or larger. + !#zh 调度一个åªè¿è¡Œä¸€æ¬¡çš„回调函数,å¯ä»¥æŒ‡å®š 0 è®©å›žè°ƒå‡½æ•°åœ¨ä¸‹ä¸€å¸§ç«‹å³æ‰§è¡Œæˆ–è€…åœ¨ä¸€å®šçš„å»¶æ—¶ä¹‹åŽæ‰§è¡Œã€‚ + @param callback A function wrapped as a selector + @param delay The amount of time that the first tick will wait before execution. Unit: s @example ```js - // Scroll to the lower left corner of the view. - scrollView.scrollToBottomLeft(0.1); + var timeCallback = function (dt) { + cc.log("time: " + dt); + } + this.scheduleOnce(timeCallback, 2); ``` */ - scrollToBottomLeft(timeInSecond?: number, attenuated?: boolean): void; + scheduleOnce(callback: Function, delay?: number): void; /** - !#en Scroll the content to the bottom right boundary of ScrollView. - !#zh 视图内容将在规定时间内滚动到视图å³ä¸‹è§’。 - @param timeInSecond Scroll time in second, if you don't pass timeInSecond, - the content will jump to the bottom right boundary immediately. - @param attenuated Whether the scroll acceleration attenuated, default is true. + !#en Unschedules a custom callback function. + !#zh å–æ¶ˆè°ƒåº¦ä¸€ä¸ªè‡ªå®šä¹‰çš„回调函数。 + @param callback_fn A function wrapped as a selector @example ```js - // Scroll to the lower right corner of the view. - scrollView.scrollToBottomRight(0.1); + this.unschedule(_callback); ``` */ - scrollToBottomRight(timeInSecond?: number, attenuated?: boolean): void; + unschedule(callback_fn: Function): void; /** - !#en Scroll with an offset related to the ScrollView's top left origin, if timeInSecond is omitted, then it will jump to the - specific offset immediately. - !#zh 视图内容在规定时间内将滚动到 ScrollView 相对左上角原点的åç§»ä½ç½®, 如果 timeInSecond傿•°ä¸ä¼ ï¼Œåˆ™ç«‹å³æ»šåŠ¨åˆ°æŒ‡å®šåç§»ä½ç½®ã€‚ - @param offset A Vec2, the value of which each axis between 0 and maxScrollOffset - @param timeInSecond Scroll time in second, if you don't pass timeInSecond, - the content will jump to the specific offset of ScrollView immediately. - @param attenuated Whether the scroll acceleration attenuated, default is true. + !#en + unschedule all scheduled callback functions: custom callback functions, and the 'update' callback function.<br/> + Actions are not affected by this method. + !#zh å–æ¶ˆè°ƒåº¦æ‰€æœ‰å·²è°ƒåº¦çš„å›žè°ƒå‡½æ•°ï¼šå®šåˆ¶çš„å›žè°ƒå‡½æ•°ä»¥åŠ `update` 回调函数。动作ä¸å—æ¤æ–¹æ³•å½±å“。 @example ```js - // Scroll to middle position in 0.1 second in x-axis - let maxScrollOffset = this.getMaxScrollOffset(); - scrollView.scrollToOffset(cc.v2(maxScrollOffset.x / 2, 0), 0.1); + this.unscheduleAllCallbacks(); ``` */ - scrollToOffset(offset: Vec2, timeInSecond?: number, attenuated?: boolean): void; - /** - !#en Get the positive offset value corresponds to the content's top left boundary. - !#zh èŽ·å–æ»šåŠ¨è§†å›¾ç›¸å¯¹äºŽå·¦ä¸Šè§’åŽŸç‚¹çš„å½“å‰æ»šåЍåç§» - */ - getScrollOffset(): Vec2; - /** - !#en Get the maximize available scroll offset - !#zh èŽ·å–æ»šåŠ¨è§†å›¾æœ€å¤§å¯ä»¥æ»šåŠ¨çš„åç§»é‡ - */ - getMaxScrollOffset(): Vec2; + unscheduleAllCallbacks(): void; + } + /** !#en The Label Component. + !#zh æ–‡å—æ ‡ç¾ç»„ä»¶ */ + export class Label extends RenderComponent { + /** !#en Content string of label. + !#zh æ ‡ç¾æ˜¾ç¤ºçš„æ–‡æœ¬å†…容。 */ + string: string; + /** !#en Horizontal Alignment of label. + !#zh æ–‡æœ¬å†…å®¹çš„æ°´å¹³å¯¹é½æ–¹å¼ã€‚ */ + horizontalAlign: Label.HorizontalAlign; + /** !#en Vertical Alignment of label. + !#zh æ–‡æœ¬å†…å®¹çš„åž‚ç›´å¯¹é½æ–¹å¼ã€‚ */ + verticalAlign: Label.VerticalAlign; + /** !#en The actual rendering font size in shrink mode + !#zh SHRINK 模å¼ä¸‹é¢æ–‡æœ¬å®žé™…渲染的å—ä½“å¤§å° */ + actualFontSize: number; + /** !#en Font size of label. + !#zh 文本å—体大å°ã€‚ */ + fontSize: number; + /** !#en Font family of label, only take effect when useSystemFont property is true. + !#zh 文本å—体åç§°, åªåœ¨ useSystemFont 属性为 true 的时候生效。 */ + fontFamily: string; + /** !#en Line Height of label. + !#zh 文本行高。 */ + lineHeight: number; + /** !#en Overflow of label. + !#zh æ–‡å—æ˜¾ç¤ºè¶…å‡ºèŒƒå›´æ—¶çš„å¤„ç†æ–¹å¼ã€‚ */ + overflow: Label.Overflow; + /** !#en Whether auto wrap label when string width is large than label width. + !#zh 是å¦è‡ªåЍæ¢è¡Œã€‚ */ + enableWrapText: boolean; + /** !#en The font of label. + !#zh 文本å—体。 */ + font: Font; + /** !#en Whether use system font name or not. + !#zh 是å¦ä½¿ç”¨ç³»ç»Ÿå—体。 */ + useSystemFont: boolean; + /** !#en The spacing of the x axis between characters, only take Effect when using bitmap fonts. + !#zh æ–‡å—之间 x 轴的间è·ï¼Œä»…在使用ä½å›¾å—体时生效。 */ + spacingX: number; + /** !#en The cache mode of label. This mode only supports system fonts. + !#zh æ–‡æœ¬ç¼“å˜æ¨¡å¼, 该模å¼åªæ”¯æŒç³»ç»Ÿå—体。 */ + cacheMode: Label.CacheMode; + /** !#en Whether enable bold. + !#zh 是å¦å¯ç”¨é»‘体。 */ + enableBold: boolean; + /** !#en Whether enable italic. + !#zh 是å¦å¯ç”¨æ–œä½“。 */ + enableItalic: boolean; + /** !#en Whether enable underline. + !#zh 是å¦å¯ç”¨ä¸‹åˆ’线。 */ + enableUnderline: boolean; + /** !#en The height of underline. + !#zh 下划线高度。 */ + underlineHeight: number; /** - !#en Scroll the content to the horizontal percent position of ScrollView. - !#zh 视图内容在规定时间内将滚动到 ScrollView 水平方å‘的百分比ä½ç½®ä¸Šã€‚ - @param percent A value between 0 and 1. - @param timeInSecond Scroll time in second, if you don't pass timeInSecond, - the content will jump to the horizontal percent position of ScrollView immediately. - @param attenuated Whether the scroll acceleration attenuated, default is true. - - @example - ```js - // Scroll to middle position. - scrollView.scrollToBottomRight(0.5, 0.1); - ``` + !#zh 需è¦ä¿è¯å½“å‰åœºæ™¯ä¸æ²¡æœ‰ä½¿ç”¨CHAR缓å˜çš„Labelæ‰å¯ä»¥æ¸…除,å¦åˆ™å·²æ¸²æŸ“çš„æ–‡å—æ²¡æœ‰é‡æ–°ç»˜åˆ¶ä¼šä¸æ˜¾ç¤º + !#en It can be cleared that need to ensure there is not use the CHAR cache in the current scene. Otherwise, the rendered text will not be displayed without repainting. */ - scrollToPercentHorizontal(percent: number, timeInSecond?: number, attenuated?: boolean): void; + static clearCharCache(): void; + } + /** !#en Outline effect used to change the display, only for system fonts or TTF fonts + !#zh æè¾¹æ•ˆæžœç»„ä»¶,用于å—体æè¾¹,åªèƒ½ç”¨äºŽç³»ç»Ÿå—体 */ + export class LabelOutline extends Component { + /** !#en outline color + !#zh æ”¹å˜æè¾¹çš„é¢œè‰² */ + color: Color; + /** !#en Change the outline width + !#zh æ”¹å˜æè¾¹çš„å®½åº¦ */ + width: number; + } + /** !#en Shadow effect for Label component, only for system fonts or TTF fonts + !#zh 用于给 Label ç»„ä»¶æ·»åŠ é˜´å½±æ•ˆæžœï¼Œåªèƒ½ç”¨äºŽç³»ç»Ÿå—体或 ttf å—体 */ + export class LabelShadow extends Component { + /** !#en The shadow color + !#zh 阴影的颜色 */ + color: Color; + /** !#en Offset between font and shadow + !#zh å—体与阴影的åç§» */ + offset: Vec2; + /** !#en A non-negative float specifying the level of shadow blur + !#zh 阴影的模糊程度 */ + blur: number; + } + /** !#en + The Layout is a container component, use it to arrange child elements easily.<br> + Note:<br> + 1.Scaling and rotation of child nodes are not considered.<br> + 2.After setting the Layout, the results need to be updated until the next frame, + unless you manually call {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 + !#zh + Layout 组件相当于一个容器,能自动对它的所有å节点进行统一排版。<br> + 注æ„:<br> + 1.ä¸ä¼šè€ƒè™‘å节点的缩放和旋转。<br> + 2.对 Layout 设置åŽç»“果需è¦åˆ°ä¸‹ä¸€å¸§æ‰ä¼šæ›´æ–°ï¼Œé™¤éžä½ è®¾ç½®å®Œä»¥åŽæ‰‹åŠ¨è°ƒç”¨ {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 */ + export class Layout extends Component { + /** !#en The layout type. + !#zh 布局类型 */ + type: Layout.Type; + /** !#en + The are three resize modes for Layout. + None, resize Container and resize children. + !#zh ç¼©æ”¾æ¨¡å¼ */ + resizeMode: Layout.ResizeMode; + /** !#en The cell size for grid layout. + !#zh æ¯ä¸ªæ ¼å的大å°ï¼Œåªæœ‰å¸ƒå±€ç±»åž‹ä¸º GRID çš„æ—¶å€™æ‰æœ‰æ•ˆã€‚ */ + cellSize: Size; + /** !#en + The start axis for grid layout. If you choose horizontal, then children will layout horizontally at first, + and then break line on demand. Choose vertical if you want to layout vertically at first . + !#zh èµ·å§‹è½´æ–¹å‘类型,å¯è¿›è¡Œæ°´å¹³å’Œåž‚ç›´å¸ƒå±€æŽ’åˆ—ï¼Œåªæœ‰å¸ƒå±€ç±»åž‹ä¸º GRID çš„æ—¶å€™æ‰æœ‰æ•ˆã€‚ */ + startAxis: Layout.AxisDirection; + /** !#en The left padding of layout, it only effect the layout in one direction. + !#zh 容器内左边è·ï¼Œåªä¼šåœ¨ä¸€ä¸ªå¸ƒå±€æ–¹å‘上生效。 */ + paddingLeft: number; + /** !#en The right padding of layout, it only effect the layout in one direction. + !#zh 容器内å³è¾¹è·ï¼Œåªä¼šåœ¨ä¸€ä¸ªå¸ƒå±€æ–¹å‘上生效。 */ + paddingRight: number; + /** !#en The top padding of layout, it only effect the layout in one direction. + !#zh 容器内上边è·ï¼Œåªä¼šåœ¨ä¸€ä¸ªå¸ƒå±€æ–¹å‘上生效。 */ + paddingTop: number; + /** !#en The bottom padding of layout, it only effect the layout in one direction. + !#zh 容器内下边è·ï¼Œåªä¼šåœ¨ä¸€ä¸ªå¸ƒå±€æ–¹å‘上生效。 */ + paddingBottom: number; + /** !#en The distance in x-axis between each element in layout. + !#zh å节点之间的水平间è·ã€‚ */ + spacingX: number; + /** !#en The distance in y-axis between each element in layout. + !#zh å节点之间的垂直间è·ã€‚ */ + spacingY: number; + /** !#en + Only take effect in Vertical layout mode. + This option changes the start element's positioning. + !#zh 垂直排列å节点的方å‘。 */ + verticalDirection: Layout.VerticalDirection; + /** !#en + Only take effect in Horizontal layout mode. + This option changes the start element's positioning. + !#zh 水平排列å节点的方å‘。 */ + horizontalDirection: Layout.HorizontalDirection; + /** !#en Adjust the layout if the children scaled. + !#zh å节点缩放比例是å¦å½±å“布局。 */ + affectedByScale: boolean; /** - !#en Scroll the content to the percent position of ScrollView in any direction. - !#zh 视图内容在规定时间内进行垂直方å‘和水平方å‘的滚动,并且滚动到指定百分比ä½ç½®ä¸Šã€‚ - @param anchor A point which will be clamp between cc.v2(0,0) and cc.v2(1,1). - @param timeInSecond Scroll time in second, if you don't pass timeInSecond, - the content will jump to the percent position of ScrollView immediately. - @param attenuated Whether the scroll acceleration attenuated, default is true. + !#en Perform the layout update + !#zh ç«‹å³æ‰§è¡Œæ›´æ–°å¸ƒå±€ @example ```js - // Vertical scroll to the bottom of the view. - scrollView.scrollTo(cc.v2(0, 1), 0.1); - - // Horizontal scroll to view right. - scrollView.scrollTo(cc.v2(1, 0), 0.1); + layout.type = cc.Layout.HORIZONTAL; + layout.node.addChild(childNode); + cc.log(childNode.x); // not yet changed + layout.updateLayout(); + cc.log(childNode.x); // changed ``` */ - scrollTo(anchor: Vec2, timeInSecond?: number, attenuated?: boolean): void; - /** - !#en Scroll the content to the vertical percent position of ScrollView. - !#zh 视图内容在规定时间内滚动到 ScrollView 垂直方å‘的百分比ä½ç½®ä¸Šã€‚ - @param percent A value between 0 and 1. - @param timeInSecond Scroll time in second, if you don't pass timeInSecond, - the content will jump to the vertical percent position of ScrollView immediately. - @param attenuated Whether the scroll acceleration attenuated, default is true. - // Scroll to middle position. - scrollView.scrollToPercentVertical(0.5, 0.1); - */ - scrollToPercentVertical(percent: number, timeInSecond?: number, attenuated?: boolean): void; - /** - !#en Stop auto scroll immediately - !#zh åœæ¢è‡ªåŠ¨æ»šåŠ¨, è°ƒç”¨æ¤ API å¯ä»¥è®© Scrollview ç«‹å³åœæ¢æ»šåЍ - */ - stopAutoScroll(): void; - /** - !#en Modify the content position. - !#zh 设置当å‰è§†å›¾å†…å®¹çš„åæ ‡ç‚¹ã€‚ - @param position The position in content's parent space. - */ - setContentPosition(position: Vec2): void; - /** - !#en Query the content's position in its parent space. - !#zh 获å–当å‰è§†å›¾å†…å®¹çš„åæ ‡ç‚¹ã€‚ - */ - getContentPosition(): Vec2; - /** - !#en Query whether the user is currently dragging the ScrollView to scroll it - !#zh 用户是å¦åœ¨æ‹–æ‹½å½“å‰æ»šåŠ¨è§†å›¾ - */ - isScrolling(): boolean; - /** - !#en Query whether the ScrollView is currently scrolling because of a bounceback or inertia slowdown. - !#zh 当剿»šåŠ¨è§†å›¾æ˜¯å¦åœ¨æƒ¯æ€§æ»šåЍ - */ - isAutoScrolling(): boolean; - } - /** !#en The Slider Control - !#zh 滑动器组件 */ - export class Slider extends Component { - /** !#en The "handle" part of the slider - !#zh æ»‘åŠ¨å™¨æ»‘å—æŒ‰é’®éƒ¨ä»¶ */ - handle: Button; - /** !#en The slider direction - !#zh æ»‘åŠ¨å™¨æ–¹å‘ */ - direction: Slider.Direction; - /** !#en The current progress of the slider. The valid value is between 0-1 - !#zh 当å‰è¿›åº¦å€¼ï¼Œè¯¥æ•°å€¼çš„区间是 0-1 之间 */ - progress: number; - /** !#en The slider slide events' callback array - !#zh 滑动器组件滑动事件回调函数数组 */ - slideEvents: Component.EventHandler[]; + updateLayout(): void; } - /** !#en Renders a sprite in the scene. - !#zh è¯¥ç»„ä»¶ç”¨äºŽåœ¨åœºæ™¯ä¸æ¸²æŸ“ç²¾çµã€‚ */ - export class Sprite extends RenderComponent implements BlendFunc { - /** !#en The sprite frame of the sprite. - !#zh ç²¾çµçš„ç²¾çµå¸§ */ + /** !#en The Mask Component + !#zh é®ç½©ç»„ä»¶ */ + export class Mask extends RenderComponent { + /** !#en The mask type. + !#zh é®ç½©ç±»åž‹ */ + type: Mask.Type; + /** !#en The mask image + !#zh é®ç½©æ‰€éœ€è¦çš„贴图 */ spriteFrame: SpriteFrame; - /** !#en The sprite render type. - !#zh ç²¾çµæ¸²æŸ“类型 */ - type: Sprite.Type; - /** !#en - The fill type, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLEDâ€. - !#zh - ç²¾çµå¡«å……类型,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ - fillType: Sprite.FillType; - /** !#en - The fill Center, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLEDâ€. - !#zh - å¡«å……ä¸å¿ƒç‚¹ï¼Œä»…渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ - fillCenter: Vec2; /** !#en - The fill Start, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLEDâ€. + The alpha threshold.(Not supported Canvas Mode) <br/> + The content is drawn only where the stencil have pixel with alpha greater than the alphaThreshold. <br/> + Should be a float between 0 and 1. <br/> + This default to 0.1. + When it's set to 1, the stencil will discard all pixels, nothing will be shown. !#zh - 填充起始点,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ - fillStart: number; + Alpha é˜ˆå€¼ï¼ˆä¸æ”¯æŒ Canvas 模å¼ï¼‰<br/> + åªæœ‰å½“模æ¿çš„åƒç´ çš„ alpha 大于ç‰äºŽ alphaThreshold 时,æ‰ä¼šç»˜åˆ¶å†…容。<br/> + 该数值 0 ~ 1 之间的浮点数,默认值为 0.1 + 当被设置为 1 时,会丢弃所有蒙版åƒç´ ,所以ä¸ä¼šæ˜¾ç¤ºä»»ä½•内容 */ + alphaThreshold: number; + /** !#en Reverse mask (Not supported Canvas Mode) + !#zh åå‘é®ç½©ï¼ˆä¸æ”¯æŒ Canvas 模å¼ï¼‰ */ + inverted: boolean; + /** TODO: remove segments, not supported by graphics + !#en The segements for ellipse mask. + !#zh æ¤åœ†é®ç½©çš„æ›²çº¿ç»†åˆ†æ•° */ + segements: number; + } + /** !#en + cc.MotionStreak manages a Ribbon based on it's motion in absolute space. <br/> + You construct it with a fadeTime, minimum segment size, texture path, texture <br/> + length and color. The fadeTime controls how long it takes each vertex in <br/> + the streak to fade out, the minimum segment size it how many pixels the <br/> + streak will move before adding a new ribbon segment, and the texture <br/> + length is the how many pixels the texture is stretched across. The texture <br/> + is vertically aligned along the streak segment. + !#zh è¿åŠ¨è½¨è¿¹ï¼Œç”¨äºŽæ¸¸æˆå¯¹è±¡çš„è¿åŠ¨è½¨è¿¹ä¸Šå®žçŽ°æ‹–å°¾æ¸éšæ•ˆæžœã€‚ */ + export class MotionStreak extends Component implements BlendFunc { /** !#en - The fill Range, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLEDâ€. - !#zh - 填充范围,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ - fillRange: number; - /** !#en specify the frame is trimmed or not. - !#zh 是å¦ä½¿ç”¨è£å‰ªæ¨¡å¼ */ - trim: boolean; - /** !#en specify the size tracing mode. - !#zh ç²¾çµå°ºå¯¸è°ƒæ•´æ¨¡å¼ */ - sizeMode: Sprite.SizeMode; - /** - Change the state of sprite. - @param state NORMAL or GRAY State. - */ - setState(state: Sprite.State): void; + !#zh 在编辑器模å¼ä¸‹é¢„览拖尾效果。 */ + preview: boolean; + /** !#en The fade time to fade. + !#zh 拖尾的æ¸éšæ—¶é—´ï¼Œä»¥ç§’ä¸ºå•ä½ã€‚ */ + fadeTime: number; + /** !#en The minimum segment size. + !#zh 拖尾之间最å°è·ç¦»ã€‚ */ + minSeg: number; + /** !#en The stroke's width. + !#zh 拖尾的宽度。 */ + stroke: number; + /** !#en The texture of the MotionStreak. + !#zh 拖尾的贴图。 */ + texture: Texture2D; + /** !#en The color of the MotionStreak. + !#zh 拖尾的颜色 */ + color: Color; + /** !#en The fast Mode. + !#zh 是å¦å¯ç”¨äº†å¿«é€Ÿæ¨¡å¼ã€‚当å¯ç”¨å¿«é€Ÿæ¨¡å¼ï¼Œæ–°çš„ç‚¹ä¼šè¢«æ›´å¿«åœ°æ·»åŠ ï¼Œä½†ç²¾åº¦è¾ƒä½Žã€‚ */ + fastMode: boolean; /** - Gets the current state. + !#en Remove all living segments of the ribbon. + !#zh åˆ é™¤å½“å‰æ‰€æœ‰çš„æ‹–尾片段。 + + @example + ```js + // Remove all living segments of the ribbon. + myMotionStreak.reset(); + ``` */ - getState(): Sprite.State; + reset(): void; /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. !#zh æŒ‡å®šåŽŸå›¾çš„æ··åˆæ¨¡å¼ï¼Œè¿™ä¼šå…‹éš†ä¸€ä¸ªæ–°çš„æè´¨å¯¹è±¡ï¼Œæ³¨æ„这带æ¥çš„开销 */ srcBlendFactor: macro.BlendFactor; @@ -9248,1427 +8770,1900 @@ declare namespace cc { !#zh æŒ‡å®šç›®æ ‡çš„æ··åˆæ¨¡å¼ */ dstBlendFactor: macro.BlendFactor; } - /** !#en The toggle component is a CheckBox, when it used together with a ToggleGroup, it - could be treated as a RadioButton. - !#zh Toggle 是一个 CheckBox,当它和 ToggleGroup 一起使用的时候,å¯ä»¥å˜æˆ RadioButton。 */ - export class Toggle extends Button implements GraySpriteState { - /** !#en When this value is true, the check mark component will be enabled, otherwise - the check mark component will be disabled. - !#zh 如果这个设置为 true,则 check mark 组件会处于 enabled 状æ€ï¼Œå¦åˆ™å¤„于 disabled 状æ€ã€‚ */ - isChecked: boolean; - /** !#en The toggle group which the toggle belongs to, when it is null, the toggle is a CheckBox. - Otherwise, the toggle is a RadioButton. - !#zh Toggle 所属的 ToggleGroup,这个属性是å¯é€‰çš„。如果这个属性为 null,则 Toggle 是一个 CheckBox, - å¦åˆ™ï¼ŒToggle 是一个 RadioButton。 */ - toggleGroup: ToggleGroup; - /** !#en The image used for the checkmark. - !#zh Toggle 处于选ä¸çŠ¶æ€æ—¶æ˜¾ç¤ºçš„图片 */ - checkMark: Sprite; - /** !#en If Toggle is clicked, it will trigger event's handler - !#zh Toggle 按钮的点击事件列表。 */ - checkEvents: Component.EventHandler[]; + /** !#en The PageView control + !#zh 页é¢è§†å›¾ç»„ä»¶ */ + export class PageView extends ScrollView { + /** !#en Specify the size type of each page in PageView. + !#zh 页é¢è§†å›¾ä¸æ¯ä¸ªé¡µé¢å¤§å°ç±»åž‹ */ + sizeMode: PageView.SizeMode; + /** !#en The page view direction + !#zh 页é¢è§†å›¾æ»šåŠ¨ç±»åž‹ */ + direction: PageView.Direction; + /** !#en + The scroll threshold value, when drag exceeds this value, + release the next page will automatically scroll, less than the restore + !#zh 滚动临界值,默认å•ä½ç™¾åˆ†æ¯”,当拖拽超出该数值时,æ¾å¼€ä¼šè‡ªåŠ¨æ»šåŠ¨ä¸‹ä¸€é¡µï¼Œå°äºŽæ—¶åˆ™è¿˜åŽŸã€‚ */ + scrollThreshold: number; + /** !#en + Auto page turning velocity threshold. When users swipe the PageView quickly, + it will calculate a velocity based on the scroll distance and time, + if the calculated velocity is larger than the threshold, then it will trigger page turning. + !#zh + 快速滑动翻页临界值。 + å½“ç”¨æˆ·å¿«é€Ÿæ»‘åŠ¨æ—¶ï¼Œä¼šæ ¹æ®æ»‘动开始和结æŸçš„è·ç¦»ä¸Žæ—¶é—´è®¡ç®—出一个速度值, + 该值与æ¤ä¸´ç•Œå€¼ç›¸æ¯”较,如果大于临界值,则进行自动翻页。 */ + autoPageTurningThreshold: number; + /** !#en Change the PageTurning event timing of PageView. + !#zh 设置 PageView PageTurning 事件的å‘逿—¶æœºã€‚ */ + pageTurningEventTiming: number; + /** !#en The Page View Indicator + !#zh 页é¢è§†å›¾æŒ‡ç¤ºå™¨ç»„ä»¶ */ + indicator: PageViewIndicator; + /** !#en The time required to turn over a page. unit: second + !#zh æ¯ä¸ªé¡µé¢ç¿»é¡µæ—¶æ‰€éœ€æ—¶é—´ã€‚å•ä½ï¼šç§’ */ + pageTurningSpeed: number; + /** !#en PageView events callback + !#zh 滚动视图的事件回调函数 */ + pageEvents: Component.EventHandler[]; + /** + !#en Returns current page index + !#zh 返回当å‰é¡µé¢ç´¢å¼• + */ + getCurrentPageIndex(): number; + /** + !#en Set current page index + !#zh 设置当å‰é¡µé¢ç´¢å¼• + @param index index + */ + setCurrentPageIndex(index: number): void; + /** + !#en Returns all pages of pageview + !#zh 返回视图ä¸çš„æ‰€æœ‰é¡µé¢ + */ + getPages(): Node[]; + /** + !#en At the end of the current page view to insert a new view + !#zh 在当å‰é¡µé¢è§†å›¾çš„尾部æ’入一个新视图 + @param page page + */ + addPage(page: Node): void; /** - !#en Make the toggle button checked. - !#zh 使 toggle 按钮处于选ä¸çŠ¶æ€ + !#en Inserts a page in the specified location + !#zh 将页颿’入指定ä½ç½®ä¸ + @param page page + @param index index */ - check(): void; + insertPage(page: Node, index: number): void; /** - !#en Make the toggle button unchecked. - !#zh 使 toggle 按钮处于未选ä¸çŠ¶æ€ + !#en Removes a page from PageView. + !#zh ç§»é™¤æŒ‡å®šé¡µé¢ + @param page page */ - uncheck(): void; - /** !#en The normal material. - !#zh æ£å¸¸çжæ€çš„æè´¨ã€‚ */ - normalMaterial: Material; - /** !#en The gray material. - !#zh ç½®ç°çжæ€çš„æè´¨ã€‚ */ - grayMaterial: Material; - } - /** !#en ToggleContainer is not a visiable UI component but a way to modify the behavior of a set of Toggles. <br/> - Toggles that belong to the same group could only have one of them to be switched on at a time.<br/> - Note: All the first layer child node containing the toggle component will auto be added to the container - !#zh ToggleContainer 䏿˜¯ä¸€ä¸ªå¯è§çš„ UI 组件,它å¯ä»¥ç”¨æ¥ä¿®æ”¹ä¸€ç»„ Toggle 组件的行为。<br/> - 当一组 Toggle 属于åŒä¸€ä¸ª ToggleContainer 的时候,任何时候åªèƒ½æœ‰ä¸€ä¸ª Toggle 处于选ä¸çжæ€ã€‚<br/> - 注æ„ï¼šæ‰€æœ‰åŒ…å« Toggle 组件的一级åèŠ‚ç‚¹éƒ½ä¼šè‡ªåŠ¨è¢«æ·»åŠ åˆ°è¯¥å®¹å™¨ä¸ */ - export class ToggleContainer extends Component { - /** !#en If this setting is true, a toggle could be switched off and on when pressed. - If it is false, it will make sure there is always only one toggle could be switched on - and the already switched on toggle can't be switched off. - !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候å¯ä»¥åå¤åœ°è¢«é€‰ä¸å’Œæœªé€‰ä¸ã€‚ */ - allowSwitchOff: boolean; - /** !#en If Toggle is clicked, it will trigger event's handler - !#zh Toggle 按钮的点击事件列表。 */ - checkEvents: Component.EventHandler[]; - /** !#en Read only property, return the toggle items array reference managed by ToggleContainer. - !#zh åªè¯»å±žæ€§ï¼Œè¿”回 ToggleContainer 管ç†çš„ toggle 数组引用 */ - toggleItems: Toggle[]; + removePage(page: Node): void; + /** + !#en Removes a page at index of PageView. + !#zh ç§»é™¤æŒ‡å®šä¸‹æ ‡çš„é¡µé¢ + @param index index + */ + removePageAtIndex(index: number): void; + /** + !#en Removes all pages from PageView + !#zh ç§»é™¤æ‰€æœ‰é¡µé¢ + */ + removeAllPages(): void; + /** + !#en Scroll PageView to index. + !#zh æ»šåŠ¨åˆ°æŒ‡å®šé¡µé¢ + @param idx index of page. + @param timeInSecond scrolling time + */ + scrollToPage(idx: number, timeInSecond: number): void; } - /** !#en ToggleGroup is not a visiable UI component but a way to modify the behavior of a set of Toggles. - Toggles that belong to the same group could only have one of them to be switched on at a time. - !#zh ToggleGroup 䏿˜¯ä¸€ä¸ªå¯è§çš„ UI 组件,它å¯ä»¥ç”¨æ¥ä¿®æ”¹ä¸€ç»„ Toggle 组件的行为。当一组 Toggle 属于åŒä¸€ä¸ª ToggleGroup 的时候, - 任何时候åªèƒ½æœ‰ä¸€ä¸ª Toggle 处于选ä¸çжæ€ã€‚ */ - export class ToggleGroup extends Component { - /** !#en If this setting is true, a toggle could be switched off and on when pressed. - If it is false, it will make sure there is always only one toggle could be switched on - and the already switched on toggle can't be switched off. - !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候å¯ä»¥åå¤åœ°è¢«é€‰ä¸å’Œæœªé€‰ä¸ã€‚ */ - allowSwitchOff: boolean; - /** !#en Read only property, return the toggle items array reference managed by toggleGroup. - !#zh åªè¯»å±žæ€§ï¼Œè¿”回 toggleGroup 管ç†çš„ toggle 数组引用 */ - toggleItems: any[]; + /** !#en The Page View Indicator Component + !#zh 页é¢è§†å›¾æ¯é¡µæ ‡è®°ç»„ä»¶ */ + export class PageViewIndicator extends Component { + /** !#en The spriteFrame for each element. + !#zh æ¯ä¸ªé¡µé¢æ ‡è®°æ˜¾ç¤ºçš„图片 */ + spriteFrame: SpriteFrame; + /** !#en The location direction of PageViewIndicator. + !#zh 页颿 ‡è®°æ‘†æ”¾æ–¹å‘ */ + direction: PageViewIndicator.Direction; + /** !#en The cellSize for each element. + !#zh æ¯ä¸ªé¡µé¢æ ‡è®°çš„å¤§å° */ + cellSize: Size; + /** !#en The distance between each element. + !#zh æ¯ä¸ªé¡µé¢æ ‡è®°ä¹‹é—´çš„è¾¹è· */ + spacing: number; + /** + !#en Set Page View + !#zh 设置页é¢è§†å›¾ + @param target target + */ + setPageView(target: PageView): void; } /** !#en - Handling touch events in a ViewGroup takes special care, - because it's common for a ViewGroup to have children that are targets for different touch events than the ViewGroup itself. - To make sure that each view correctly receives the touch events intended for it, - ViewGroup should register capture phase event and handle the event propagation properly. - Please refer to Scrollview for more information. - + Visual indicator of progress in some operation. + Displays a bar to the user representing how far the operation has progressed. !#zh - ViewGroupçš„äº‹ä»¶å¤„ç†æ¯”è¾ƒç‰¹æ®Šï¼Œå› ä¸º ViewGroup 里é¢çš„å节点关心的事件跟 ViewGroup 本身å¯èƒ½ä¸ä¸€æ ·ã€‚ - 为了让å节点能够æ£ç¡®åœ°å¤„ç†äº‹ä»¶ï¼ŒViewGroup éœ€è¦æ³¨å†Œ capture 阶段的事件,并且åˆç†åœ°å¤„ç† ViewGroup ä¹‹é—´çš„äº‹ä»¶ä¼ é€’ã€‚ - 请å‚考 ScrollView 的实现æ¥èŽ·å–æ›´å¤šä¿¡æ¯ã€‚ */ - export class ViewGroup extends Component { + 进度æ¡ç»„件,å¯ç”¨äºŽæ˜¾ç¤ºåŠ è½½èµ„æºæ—¶çš„进度。 */ + export class ProgressBar extends Component { + /** !#en The targeted Sprite which will be changed progressively. + !#zh ç”¨æ¥æ˜¾ç¤ºè¿›åº¦æ¡æ¯”例的 Sprite 对象。 */ + barSprite: Sprite; + /** !#en The progress mode, there are two modes supported now: horizontal and vertical. + !#zh 进度æ¡çš„æ¨¡å¼ */ + mode: ProgressBar.Mode; + /** !#en The total width or height of the bar sprite. + !#zh 进度æ¡å®žé™…的总长度 */ + totalLength: number; + /** !#en The current progress of the bar sprite. The valid value is between 0-1. + !#zh 当å‰è¿›åº¦å€¼ï¼Œè¯¥æ•°å€¼çš„区间是 0-1 之间。 */ + progress: number; + /** !#en Whether reverse the progress direction of the bar sprite. + !#zh è¿›åº¦æ¡æ˜¯å¦è¿›è¡Œåæ–¹å‘å˜åŒ–。 */ + reverse: boolean; } /** !#en - Stores and manipulate the anchoring based on its parent. - Widget are used for GUI but can also be used for other things. - Widget will adjust current node's position and size automatically, but the results after adjustment can not be obtained until the next frame unless you call {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}} manually. + Base class for components which supports rendering features. !#zh - Widget 组件,用于设置和适é…其相对于父节点的边è·ï¼ŒWidget 通常被用于 UI 界é¢ï¼Œä¹Ÿå¯ä»¥ç”¨äºŽå…¶ä»–地方。 - Widget 会自动调整当å‰èŠ‚ç‚¹çš„åæ ‡å’Œå®½é«˜ï¼Œä¸è¿‡ç›®å‰è°ƒæ•´åŽçš„结果è¦åˆ°ä¸‹ä¸€å¸§æ‰èƒ½åœ¨è„šæœ¬é‡ŒèŽ·å–到,除éžä½ 先手动调用 {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}}。 */ - export class Widget extends Component { - /** !#en Specifies an alignment target that can only be one of the parent nodes of the current node. - The default value is null, and when null, indicates the current parent. - !#zh 指定一个对é½ç›®æ ‡ï¼Œåªèƒ½æ˜¯å½“å‰èŠ‚ç‚¹çš„å…¶ä¸ä¸€ä¸ªçˆ¶èŠ‚ç‚¹ï¼Œé»˜è®¤ä¸ºç©ºï¼Œä¸ºç©ºæ—¶è¡¨ç¤ºå½“å‰çˆ¶èŠ‚ç‚¹ã€‚ */ - target: Node; - /** !#en Whether to align the top. - !#zh 是å¦å¯¹é½ä¸Šè¾¹ã€‚ */ - isAlignTop: boolean; - /** !#en - Vertically aligns the midpoint, This will open the other vertical alignment options cancel. - !#zh - 是å¦åž‚ç›´æ–¹å‘对é½ä¸ç‚¹ï¼Œå¼€å¯æ¤é¡¹ä¼šå°†åž‚ç›´æ–¹å‘其他对é½é€‰é¡¹å–消。 */ - isAlignVerticalCenter: boolean; - /** !#en Whether to align the bottom. - !#zh 是å¦å¯¹é½ä¸‹è¾¹ã€‚ */ - isAlignBottom: boolean; - /** !#en Whether to align the left. - !#zh 是å¦å¯¹é½å·¦è¾¹ */ - isAlignLeft: boolean; - /** !#en - Horizontal aligns the midpoint. This will open the other horizontal alignment options canceled. - !#zh - æ˜¯å¦æ°´å¹³æ–¹å‘对é½ä¸ç‚¹ï¼Œå¼€å¯æ¤é€‰é¡¹ä¼šå°†æ°´å¹³æ–¹å‘其他对é½é€‰é¡¹å–消。 */ - isAlignHorizontalCenter: boolean; - /** !#en Whether to align the right. - !#zh 是å¦å¯¹é½å³è¾¹ã€‚ */ - isAlignRight: boolean; - /** !#en - Whether the stretched horizontally, when enable the left and right alignment will be stretched horizontally, - the width setting is invalid (read only). - !#zh - 当剿˜¯å¦æ°´å¹³æ‹‰ä¼¸ã€‚å½“åŒæ—¶å¯ç”¨å·¦å³å¯¹é½æ—¶ï¼ŒèŠ‚ç‚¹å°†ä¼šè¢«æ°´å¹³æ‹‰ä¼¸ï¼Œæ¤æ—¶èŠ‚ç‚¹çš„å®½åº¦åªè¯»ã€‚ */ - isStretchWidth: boolean; - /** !#en - Whether the stretched vertically, when enable the left and right alignment will be stretched vertically, - then height setting is invalid (read only) - !#zh - 当剿˜¯å¦åž‚ç›´æ‹‰ä¼¸ã€‚å½“åŒæ—¶å¯ç”¨ä¸Šä¸‹å¯¹é½æ—¶ï¼ŒèŠ‚ç‚¹å°†ä¼šè¢«åž‚ç›´æ‹‰ä¼¸ï¼Œæ¤æ—¶èŠ‚ç‚¹çš„é«˜åº¦åªè¯»ã€‚ */ - isStretchHeight: boolean; - /** !#en - The margins between the top of this node and the top of parent node, - the value can be negative, Only available in 'isAlignTop' open. - !#zh - 本节点顶边和父节点顶边的è·ç¦»ï¼Œå¯å¡«å†™è´Ÿå€¼ï¼Œåªæœ‰åœ¨ isAlignTop 开坿—¶æ‰æœ‰ä½œç”¨ã€‚ */ - top: number; - /** !#en - The margins between the bottom of this node and the bottom of parent node, - the value can be negative, Only available in 'isAlignBottom' open. - !#zh - 本节点底边和父节点底边的è·ç¦»ï¼Œå¯å¡«å†™è´Ÿå€¼ï¼Œåªæœ‰åœ¨ isAlignBottom 开坿—¶æ‰æœ‰ä½œç”¨ã€‚ */ - bottom: number; - /** !#en - The margins between the left of this node and the left of parent node, - the value can be negative, Only available in 'isAlignLeft' open. - !#zh - 本节点左边和父节点左边的è·ç¦»ï¼Œå¯å¡«å†™è´Ÿå€¼ï¼Œåªæœ‰åœ¨ isAlignLeft 开坿—¶æ‰æœ‰ä½œç”¨ã€‚ */ - left: number; - /** !#en - The margins between the right of this node and the right of parent node, - the value can be negative, Only available in 'isAlignRight' open. - !#zh - 本节点å³è¾¹å’Œçˆ¶èŠ‚ç‚¹å³è¾¹çš„è·ç¦»ï¼Œå¯å¡«å†™è´Ÿå€¼ï¼Œåªæœ‰åœ¨ isAlignRight 开坿—¶æ‰æœ‰ä½œç”¨ã€‚ */ - right: number; - /** !#en - Horizontal aligns the midpoint offset value, - the value can be negative, Only available in 'isAlignHorizontalCenter' open. - !#zh 水平居ä¸çš„å移值,å¯å¡«å†™è´Ÿå€¼ï¼Œåªæœ‰åœ¨ isAlignHorizontalCenter 开坿—¶æ‰æœ‰ä½œç”¨ã€‚ */ - horizontalCenter: number; - /** !#en - Vertical aligns the midpoint offset value, - the value can be negative, Only available in 'isAlignVerticalCenter' open. - !#zh 垂直居ä¸çš„å移值,å¯å¡«å†™è´Ÿå€¼ï¼Œåªæœ‰åœ¨ isAlignVerticalCenter 开坿—¶æ‰æœ‰ä½œç”¨ã€‚ */ - verticalCenter: number; - /** !#en If true, horizontalCenter is pixel margin, otherwise is percentage (0 - 1) margin. - !#zh 如果为 true,"horizontalCenter" 将会以åƒç´ 作为å移值,å之为百分比(0 到 1)。 */ - isAbsoluteHorizontalCenter: boolean; - /** !#en If true, verticalCenter is pixel margin, otherwise is percentage (0 - 1) margin. - !#zh 如果为 true,"verticalCenter" 将会以åƒç´ 作为å移值,å之为百分比(0 到 1)。 */ - isAbsoluteVerticalCenter: boolean; - /** !#en - If true, top is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height. - !#zh - 如果为 true,"top" 将会以åƒç´ 作为边è·ï¼Œå¦åˆ™å°†ä¼šä»¥ç›¸å¯¹çˆ¶ç‰©ä½“高度的百分比(0 到 1)作为边è·ã€‚ */ - isAbsoluteTop: boolean; - /** !#en - If true, bottom is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height. - !#zh - 如果为 true,"bottom" 将会以åƒç´ 作为边è·ï¼Œå¦åˆ™å°†ä¼šä»¥ç›¸å¯¹çˆ¶ç‰©ä½“高度的百分比(0 到 1)作为边è·ã€‚ */ - isAbsoluteBottom: boolean; - /** !#en - If true, left is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width. - !#zh - 如果为 true,"left" 将会以åƒç´ 作为边è·ï¼Œå¦åˆ™å°†ä¼šä»¥ç›¸å¯¹çˆ¶ç‰©ä½“宽度的百分比(0 到 1)作为边è·ã€‚ */ - isAbsoluteLeft: boolean; + æ‰€æœ‰æ”¯æŒæ¸²æŸ“的组件的基类 */ + export class RenderComponent extends Component { + /** !#en The materials used by this render component. + !#zh 渲染组件使用的æè´¨ã€‚ */ + sharedMaterials: Material[]; + /** + !#en Get the material by index. + !#zh æ ¹æ®æŒ‡å®šç´¢å¼•èŽ·å–æè´¨ + @param index index + */ + getMaterial(index: number): MaterialVariant; + /** + !#en Gets all the materials. + !#zh èŽ·å–æ‰€æœ‰æè´¨ã€‚ + */ + getMaterials(): MaterialVariant[]; + /** + !#en Set the material by index. + !#zh æ ¹æ®æŒ‡å®šç´¢å¼•设置æè´¨ + @param index index + @param material material + */ + setMaterial(index: number, material: Material): Material; + } + /** !#en The RichText Component. + !#zh 富文本组件 */ + export class RichText extends Component { + /** !#en Content string of RichText. + !#zh 富文本显示的文本内容。 */ + string: string; + /** !#en Horizontal Alignment of each line in RichText. + !#zh æ–‡æœ¬å†…å®¹çš„æ°´å¹³å¯¹é½æ–¹å¼ã€‚ */ + horizontalAlign: macro.TextAlignment; + /** !#en Font size of RichText. + !#zh 富文本å—体大å°ã€‚ */ + fontSize: number; + /** !#en Custom System font of RichText + !#zh 富文本定制系统å—体 */ + fontFamily: string; + /** !#en Custom TTF font of RichText + !#zh 富文本定制å—体 */ + font: TTFFont; + /** !#en Whether use system font name or not. + !#zh 是å¦ä½¿ç”¨ç³»ç»Ÿå—体。 */ + useSystemFont: boolean; + /** !#en The cache mode of label. This mode only supports system fonts. + !#zh æ–‡æœ¬ç¼“å˜æ¨¡å¼, 该模å¼åªæ”¯æŒç³»ç»Ÿå—体。 */ + cacheMode: Label.CacheMode; + /** !#en The maximize width of the RichText + !#zh 富文本的最大宽度 */ + maxWidth: number; + /** !#en Line Height of RichText. + !#zh 富文本行高。 */ + lineHeight: number; + /** !#en The image atlas for the img tag. For each src value in the img tag, there should be a valid spriteFrame in the image atlas. + !#zh 对于 img æ ‡ç¾é‡Œé¢çš„ src 属性å称,都需è¦åœ¨ imageAtlas é‡Œé¢æ‰¾åˆ°ä¸€ä¸ªæœ‰æ•ˆçš„ spriteFrame,å¦åˆ™ img tag ä¼šåˆ¤å®šä¸ºæ— æ•ˆã€‚ */ + imageAtlas: SpriteAtlas; /** !#en - If true, right is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width. + Once checked, the RichText will block all input events (mouse and touch) within + the bounding box of the node, preventing the input from penetrating into the underlying node. !#zh - 如果为 true,"right" 将会以åƒç´ 作为边è·ï¼Œå¦åˆ™å°†ä¼šä»¥ç›¸å¯¹çˆ¶ç‰©ä½“宽度的百分比(0 到 1)作为边è·ã€‚ */ - isAbsoluteRight: boolean; - /** !#en Specifies the alignment mode of the Widget, which determines when the widget should refresh. - !#zh 指定 Widget çš„å¯¹é½æ¨¡å¼ï¼Œç”¨äºŽå†³å®š Widget 应该何时刷新。 */ - alignMode: Widget.AlignMode; + 选䏿¤é€‰é¡¹åŽï¼ŒRichText 将阻æ¢èŠ‚ç‚¹è¾¹ç•Œæ¡†ä¸çš„æ‰€æœ‰è¾“å…¥äº‹ä»¶ï¼ˆé¼ æ ‡å’Œè§¦æ‘¸ï¼‰ï¼Œä»Žè€Œé˜²æ¢è¾“入事件穿é€åˆ°åº•层节点。 */ + handleTouchEvent: boolean; + } + /** !#en + This component is used to adjust the layout of current node to respect the safe area of a notched mobile device such as the iPhone X. + It is typically used for the top node of the UI interaction area. For specific usage, refer to the official [example-cases/02_ui/16_safeArea/SafeArea.fire](https://github.com/cocos-creator/example-cases). + + The concept of safe area is to give you a fixed inner rectangle in which you can safely display content that will be drawn on screen. + You are strongly discouraged from providing controls outside of this area. But your screen background could embellish edges. + + This component internally uses the API `cc.sys.getSafeAreaRect();` to obtain the safe area of the current iOS or Android device, + and implements the adaptation by using the Widget component and set anchor. + + !#zh + 该组件会将所在节点的布局适é…到 iPhone X ç‰å¼‚形屿‰‹æœºçš„安全区域内,通常用于 UI 交互区域的顶层节点,具体用法å¯å‚考官方范例 [example-cases/02_ui/16_safeArea/SafeArea.fire](https://github.com/cocos-creator/example-cases)。 + + 该组件内部通过 API `cc.sys.getSafeAreaRect();` 获å–åˆ°å½“å‰ iOS 或 Android 设备的安全区域,并通过 Widget 组件实现适é…。 */ + export class SafeArea extends Component { /** - !#en - Immediately perform the widget alignment. You need to manually call this method only if - you need to get the latest results after the alignment before the end of current frame. - !#zh - 立刻执行 widget 坹齿“作。这个接å£ä¸€èˆ¬ä¸éœ€è¦æ‰‹å·¥è°ƒç”¨ã€‚ - åªæœ‰å½“ä½ éœ€è¦åœ¨å½“å‰å¸§ç»“æŸå‰èŽ·å¾— widget 对é½åŽçš„æœ€æ–°ç»“果时æ‰éœ€è¦æ‰‹åŠ¨è°ƒç”¨è¿™ä¸ªæ–¹æ³•ã€‚ + !#en Adapt to safe area + !#zh ç«‹å³é€‚é…安全区域 @example ```js - widget.top = 10; // change top margin - cc.log(widget.node.y); // not yet changed - widget.updateAlignment(); - cc.log(widget.node.y); // changed + let safeArea = this.node.addComponent(cc.SafeArea); + safeArea.updateArea(); ``` */ - updateAlignment(): void; + updateArea(): void; + } + /** !#en + The Scrollbar control allows the user to scroll an image or other view that is too large to see completely + !#zh 滚动æ¡ç»„ä»¶ */ + export class Scrollbar extends Component { + /** !#en The "handle" part of the scrollbar. + !#zh ä½œä¸ºå½“å‰æ»šåŠ¨åŒºåŸŸä½ç½®æ˜¾ç¤ºçš„æ»‘å— Sprite。 */ + handle: Sprite; + /** !#en The direction of scrollbar. + !#zh ScrollBar 的滚动方å‘。 */ + direction: Scrollbar.Direction; + /** !#en Whether enable auto hide or not. + !#zh 是å¦åœ¨æ²¡æœ‰æ»šåŠ¨åŠ¨ä½œæ—¶è‡ªåŠ¨éšè— ScrollBar。 */ + enableAutoHide: boolean; /** !#en - When turned on, it will only be aligned once at the end of the onEnable frame, - then immediately disables the current component. - This will allow the script or animation to continue controlling the current node. - Note: It will still be aligned at the frame when onEnable is called. + The time to hide scrollbar when scroll finished. + Note: This value is only useful when enableAutoHide is true. !#zh - å¼€å¯åŽä»…会在 onEnable çš„å½“å¸§ç»“æŸæ—¶å¯¹é½ä¸€æ¬¡ï¼Œç„¶åŽç«‹åˆ»ç¦ç”¨å½“å‰ç»„件。 - è¿™æ ·ä¾¿äºŽè„šæœ¬æˆ–åŠ¨ç”»ç»§ç»æŽ§åˆ¶å½“å‰èŠ‚ç‚¹ã€‚ - 注æ„:onEnable 时所在的那一帧ä»ç„¶ä¼šè¿›è¡Œå¯¹é½ã€‚ */ - isAlignOnce: boolean; + 没有滚动动作åŽç»è¿‡å¤šä¹…会自动éšè—。 + 注æ„:åªè¦å½“ “enableAutoHide†为 true æ—¶ï¼Œæ‰æœ‰æ•ˆã€‚ */ + autoHideTime: number; } - /** !#en SwanSubContextView is a view component which controls open data context viewport in WeChat game platform.<br/> - The component's node size decide the viewport of the sub context content in main context, - the entire sub context texture will be scaled to the node's bounding box area.<br/> - This component provides multiple important features:<br/> - 1. Sub context could use its own resolution size and policy.<br/> - 2. Sub context could be minized to smallest size it needed.<br/> - 3. Resolution of sub context content could be increased.<br/> - 4. User touch input is transformed to the correct viewport.<br/> - 5. Texture update is handled by this component. User don't need to worry.<br/> - One important thing to be noted, whenever the node's bounding box change, - you need to manually reset the viewport of sub context using updateSubContextViewport. - !#zh SwanSubContextView å¯ä»¥ç”¨æ¥æŽ§åˆ¶ç™¾åº¦å°æ¸¸æˆå¹³å°å¼€æ”¾æ•°æ®åŸŸåœ¨ä¸»åŸŸä¸çš„视窗的ä½ç½®ã€‚<br/> - 这个组件的节点尺寸决定了开放数æ®åŸŸå†…容在主域ä¸çš„尺寸,整个开放数æ®åŸŸä¼šè¢«ç¼©æ”¾åˆ°èŠ‚ç‚¹çš„åŒ…å›´ç›’èŒƒå›´å†…ã€‚<br/> - 在这个组件的控制下,用户å¯ä»¥æ›´è‡ªç”±å¾—控制开放数æ®åŸŸï¼š<br/> - 1. å域ä¸å¯ä»¥ä½¿ç”¨ç‹¬ç«‹çš„è®¾è®¡åˆ†è¾¨çŽ‡å’Œé€‚é…æ¨¡å¼<br/> - 2. å域区域尺寸å¯ä»¥ç¼©å°åˆ°åªå®¹çº³å†…容å³å¯<br/> - 3. å域的分辨率也å¯ä»¥è¢«æ”¾å¤§ï¼Œä»¥ä¾¿èŽ·å¾—æ›´æ¸…æ™°çš„æ˜¾ç¤ºæ•ˆæžœ<br/> - 4. ç”¨æˆ·è¾“å…¥åæ ‡ä¼šè¢«è‡ªåŠ¨è½¬æ¢åˆ°æ£ç¡®çš„å域视窗ä¸<br/> - 5. å域内容贴图的更新由组件负责,用户ä¸éœ€è¦å¤„ç†<br/> - å”¯ä¸€éœ€è¦æ³¨æ„的是,当å域节点的包围盒å‘ç”Ÿæ”¹å˜æ—¶ï¼Œå¼€å‘者需è¦ä½¿ç”¨ `updateSubContextViewport` æ¥æ‰‹åŠ¨æ›´æ–°å域视窗。 */ - export class SwanSubContextView extends Component { + /** !#en + Layout container for a view hierarchy that can be scrolled by the user, + allowing it to be larger than the physical display. + + !#zh + 滚动视图组件 */ + export class ScrollView extends Component { + /** !#en This is a reference to the UI element to be scrolled. + !#zh 坿»šåŠ¨å±•ç¤ºå†…å®¹çš„èŠ‚ç‚¹ã€‚ */ + content: Node; + /** !#en Enable horizontal scroll. + !#zh 是å¦å¼€å¯æ°´å¹³æ»šåŠ¨ã€‚ */ + horizontal: boolean; + /** !#en Enable vertical scroll. + !#zh 是å¦å¼€å¯åž‚直滚动。 */ + vertical: boolean; + /** !#en When inertia is set, the content will continue to move when touch ended. + !#zh 是å¦å¼€å¯æ»šåŠ¨æƒ¯æ€§ã€‚ */ + inertia: boolean; + /** !#en + It determines how quickly the content stop moving. A value of 1 will stop the movement immediately. + A value of 0 will never stop the movement until it reaches to the boundary of scrollview. + !#zh + 开坿ƒ¯æ€§åŽï¼Œåœ¨ç”¨æˆ·åœæ¢è§¦æ‘¸åŽæ»šåŠ¨å¤šå¿«åœæ¢ï¼Œ0表示永ä¸åœæ¢ï¼Œ1è¡¨ç¤ºç«‹åˆ»åœæ¢ã€‚ */ + brake: number; + /** !#en When elastic is set, the content will be bounce back when move out of boundary. + !#zh 是å¦å…è®¸æ»šåŠ¨å†…å®¹è¶…è¿‡è¾¹ç•Œï¼Œå¹¶åœ¨åœæ¢è§¦æ‘¸åŽå›žå¼¹ã€‚ */ + elastic: boolean; + /** !#en The elapse time of bouncing back. A value of 0 will bounce back immediately. + !#zh 回弹æŒç»çš„æ—¶é—´ï¼Œ0 表示将立å³å弹。 */ + bounceDuration: number; + /** !#en The horizontal scrollbar reference. + !#zh 水平滚动的 ScrollBar。 */ + horizontalScrollBar: Scrollbar; + /** !#en The vertical scrollbar reference. + !#zh 垂直滚动的 ScrollBar。 */ + verticalScrollBar: Scrollbar; + /** !#en Scrollview events callback + !#zh 滚动视图的事件回调函数 */ + scrollEvents: Component.EventHandler[]; + /** !#en If cancelInnerEvents is set to true, the scroll behavior will cancel touch events on inner content nodes + It's set to true by default. + !#zh 如果这个属性被设置为 trueï¼Œé‚£ä¹ˆæ»šåŠ¨è¡Œä¸ºä¼šå–æ¶ˆå节点上注册的触摸事件,默认被设置为 true。 + 注æ„,å节点上的 touchstart 事件ä»ç„¶ä¼šè§¦å‘,触点移动è·ç¦»éžå¸¸çŸçš„æƒ…况下 touchmove å’Œ touchend 也ä¸ä¼šå—å½±å“。 */ + cancelInnerEvents: boolean; /** - !#en Update the sub context viewport manually, it should be called whenever the node's bounding box changes. - !#zh 更新开放数æ®åŸŸç›¸å¯¹äºŽä¸»åŸŸçš„ viewportï¼Œè¿™ä¸ªå‡½æ•°åº”è¯¥åœ¨èŠ‚ç‚¹åŒ…å›´ç›’æ”¹å˜æ—¶æ‰‹åŠ¨è°ƒç”¨ã€‚ + !#en Scroll the content to the bottom boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图底部。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the bottom of the view. + scrollView.scrollToBottom(0.1); + ``` */ - updateSubContextViewport(): void; - } - /** !#en WXSubContextView is a view component which controls open data context viewport in WeChat game platform.<br/> - The component's node size decide the viewport of the sub context content in main context, - the entire sub context texture will be scaled to the node's bounding box area.<br/> - This component provides multiple important features:<br/> - 1. Sub context could use its own resolution size and policy.<br/> - 2. Sub context could be minized to smallest size it needed.<br/> - 3. Resolution of sub context content could be increased.<br/> - 4. User touch input is transformed to the correct viewport.<br/> - 5. Texture update is handled by this component. User don't need to worry.<br/> - One important thing to be noted, whenever the node's bounding box change, - you need to manually reset the viewport of sub context using updateSubContextViewport. - !#zh WXSubContextView å¯ä»¥ç”¨æ¥æŽ§åˆ¶å¾®ä¿¡å°æ¸¸æˆå¹³å°å¼€æ”¾æ•°æ®åŸŸåœ¨ä¸»åŸŸä¸çš„视窗的ä½ç½®ã€‚<br/> - 这个组件的节点尺寸决定了开放数æ®åŸŸå†…容在主域ä¸çš„尺寸,整个开放数æ®åŸŸä¼šè¢«ç¼©æ”¾åˆ°èŠ‚ç‚¹çš„åŒ…å›´ç›’èŒƒå›´å†…ã€‚<br/> - 在这个组件的控制下,用户å¯ä»¥æ›´è‡ªç”±å¾—控制开放数æ®åŸŸï¼š<br/> - 1. å域ä¸å¯ä»¥ä½¿ç”¨ç‹¬ç«‹çš„è®¾è®¡åˆ†è¾¨çŽ‡å’Œé€‚é…æ¨¡å¼<br/> - 2. å域区域尺寸å¯ä»¥ç¼©å°åˆ°åªå®¹çº³å†…容å³å¯<br/> - 3. å域的分辨率也å¯ä»¥è¢«æ”¾å¤§ï¼Œä»¥ä¾¿èŽ·å¾—æ›´æ¸…æ™°çš„æ˜¾ç¤ºæ•ˆæžœ<br/> - 4. ç”¨æˆ·è¾“å…¥åæ ‡ä¼šè¢«è‡ªåŠ¨è½¬æ¢åˆ°æ£ç¡®çš„å域视窗ä¸<br/> - 5. å域内容贴图的更新由组件负责,用户ä¸éœ€è¦å¤„ç†<br/> - å”¯ä¸€éœ€è¦æ³¨æ„的是,当å域节点的包围盒å‘ç”Ÿæ”¹å˜æ—¶ï¼Œå¼€å‘者需è¦ä½¿ç”¨ `updateSubContextViewport` æ¥æ‰‹åŠ¨æ›´æ–°å域视窗。 */ - export class WXSubContextView extends Component { + scrollToBottom(timeInSecond?: number, attenuated?: boolean): void; /** - !#en Reset open data context size and viewport - !#zh é‡ç½®å¼€æ”¾æ•°æ®åŸŸçš„尺寸和视窗 + !#en Scroll the content to the top boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图顶部。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the top of the view. + scrollView.scrollToTop(0.1); + ``` */ - reset(): void; + scrollToTop(timeInSecond?: number, attenuated?: boolean): void; /** - !#en Update the sub context viewport manually, it should be called whenever the node's bounding box changes. - !#zh 更新开放数æ®åŸŸç›¸å¯¹äºŽä¸»åŸŸçš„ viewportï¼Œè¿™ä¸ªå‡½æ•°åº”è¯¥åœ¨èŠ‚ç‚¹åŒ…å›´ç›’æ”¹å˜æ—¶æ‰‹åŠ¨è°ƒç”¨ã€‚ + !#en Scroll the content to the left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左边。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the left of the view. + scrollView.scrollToLeft(0.1); + ``` */ - updateSubContextViewport(): void; - } - /** !#en The renderer object which provide access to render system APIs, - detailed APIs will be available progressively. - !#zh æä¾›åŸºç¡€æ¸²æŸ“接å£çš„æ¸²æŸ“器对象,渲染层的基础接å£å°†é€æ¥å¼€æ”¾ç»™ç”¨æˆ· */ - export class renderer { - /** !#en The render engine is available only after cc.game.EVENT_ENGINE_INITED event.<br/> - Normally it will be inited as the webgl render engine, but in wechat open context domain, - it will be inited as the canvas render engine. Canvas render engine is no longer available for other use case since v2.0. - !#zh 基础渲染引擎对象åªåœ¨ cc.game.EVENT_ENGINE_INITED 事件触å‘åŽæ‰å¯èŽ·å–。<br/> - 大多数情况下,它都会是 WebGL 渲染引擎实例,但是在微信开放数æ®åŸŸå½“ä¸ï¼Œå®ƒä¼šæ˜¯ Canvas 渲染引擎实例。请注æ„,从 2.0 开始,我们在其他平å°å’ŒçŽ¯å¢ƒä¸‹éƒ½åºŸå¼ƒäº† Canvas 渲染器。 */ - static renderEngine: any; - /** !#en The total draw call count in last rendered frame. - !#zh 上一次渲染帧所æäº¤çš„æ¸²æŸ“批次总数。 */ - static drawCalls: number; - } - /** !#en - EventTarget is an object to which an event is dispatched when something has occurred. - Entity are the most common event targets, but other objects can be event targets too. - - Event targets are an important part of the Fireball event model. - The event target serves as the focal point for how events flow through the scene graph. - When an event such as a mouse click or a keypress occurs, Fireball dispatches an event object - into the event flow from the root of the hierarchy. The event object then makes its way through - the scene graph until it reaches the event target, at which point it begins its return trip through - the scene graph. This round-trip journey to the event target is conceptually divided into three phases: - - The capture phase comprises the journey from the root to the last node before the event target's node - - The target phase comprises only the event target node - - The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the tree - See also: http://www.w3.org/TR/DOM-Level-3-Events/#event-flow - - Event targets can implement the following methods: - - _getCapturingTargets - - _getBubblingTargets - - !#zh - äº‹ä»¶ç›®æ ‡æ˜¯äº‹ä»¶è§¦å‘æ—¶ï¼Œåˆ†æ´¾çš„事件对象,Node 是最常è§çš„äº‹ä»¶ç›®æ ‡ï¼Œ - 但是其他对象也å¯ä»¥æ˜¯äº‹ä»¶ç›®æ ‡ã€‚<br/> */ - export class EventTarget extends CallbacksInvoker { + scrollToLeft(timeInSecond?: number, attenuated?: boolean): void; + /** + !#en Scroll the content to the right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图å³è¾¹ã€‚ + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the right of the view. + scrollView.scrollToRight(0.1); + ``` + */ + scrollToRight(timeInSecond?: number, attenuated?: boolean): void; /** - !#en Checks whether the EventTarget object has any callback registered for a specific type of event. - !#zh æ£€æŸ¥äº‹ä»¶ç›®æ ‡å¯¹è±¡æ˜¯å¦æœ‰ä¸ºç‰¹å®šç±»åž‹çš„事件注册的回调。 - @param type The type of event. + !#en Scroll the content to the top left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左上角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the upper left corner of the view. + scrollView.scrollToTopLeft(0.1); + ``` */ - hasEventListener(type: string): boolean; + scrollToTopLeft(timeInSecond?: number, attenuated?: boolean): void; /** - !#en - Register an callback of a specific event type on the EventTarget. - This type of event should be triggered via `emit`. - !#zh - æ³¨å†Œäº‹ä»¶ç›®æ ‡çš„ç‰¹å®šäº‹ä»¶ç±»åž‹å›žè°ƒã€‚è¿™ç§ç±»åž‹çš„事件应该被 `emit` 触å‘。 - @param type A string representing the event type to listen for. - @param callback The callback that will be invoked when the event is dispatched. - The callback is ignored if it is a duplicate (the callbacks are unique). - @param target The target (this object) to invoke the callback, can be null + !#en Scroll the content to the top right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图å³ä¸Šè§’。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the top right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. @example ```js - eventTarget.on('fire', function () { - cc.log("fire in the hole"); - }, node); + // Scroll to the top right corner of the view. + scrollView.scrollToTopRight(0.1); ``` */ - on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T; + scrollToTopRight(timeInSecond?: number, attenuated?: boolean): void; /** - !#en - Removes the listeners previously registered with the same type, callback, target and or useCapture, - if only type is passed as parameter, all listeners registered with that type will be removed. - !#zh - åˆ é™¤ä¹‹å‰ç”¨åŒç±»åž‹ï¼Œå›žè°ƒï¼Œç›®æ ‡æˆ– useCapture 注册的事件监å¬å™¨ï¼Œå¦‚æžœåªä¼ 递 typeï¼Œå°†ä¼šåˆ é™¤ type 类型的所有事件监å¬å™¨ã€‚ - @param type A string representing the event type being removed. - @param callback The callback to remove. - @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + !#en Scroll the content to the bottom left boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图左下角。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom left boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. @example ```js - // 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'); + // Scroll to the lower left corner of the view. + scrollView.scrollToBottomLeft(0.1); ``` */ - off(type: string, callback?: Function, target?: any): void; + scrollToBottomLeft(timeInSecond?: number, attenuated?: boolean): void; /** - !#en Removes all callbacks previously registered with the same target (passed as parameter). - This is not for removing all listeners in the current event target, - and this is not for removing all listeners the target parameter have registered. - It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. - !#zh åœ¨å½“å‰ EventTarget ä¸Šåˆ é™¤æŒ‡å®šç›®æ ‡ï¼ˆtarget 傿•°ï¼‰æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ - è¿™ä¸ªå‡½æ•°æ— æ³•åˆ é™¤å½“å‰ EventTarget 的所有事件监å¬å™¨ï¼Œä¹Ÿæ— æ³•åˆ é™¤ target 傿•°æ‰€æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ - 这个函数åªèƒ½åˆ 除 target 傿•°åœ¨å½“å‰ EventTarget 上注册的所有事件监å¬å™¨ã€‚ - @param target The target to be searched for all related listeners + !#en Scroll the content to the bottom right boundary of ScrollView. + !#zh 视图内容将在规定时间内滚动到视图å³ä¸‹è§’。 + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the bottom right boundary immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Scroll to the lower right corner of the view. + scrollView.scrollToBottomRight(0.1); + ``` */ - targetOff(target: any): void; + scrollToBottomRight(timeInSecond?: number, attenuated?: boolean): void; /** - !#en - Register an callback of a specific event type on the EventTarget, - the callback will remove itself after the first time it is triggered. - !#zh - æ³¨å†Œäº‹ä»¶ç›®æ ‡çš„ç‰¹å®šäº‹ä»¶ç±»åž‹å›žè°ƒï¼Œå›žè°ƒä¼šåœ¨ç¬¬ä¸€æ—¶é—´è¢«è§¦å‘åŽåˆ 除自身。 - @param type A string representing the event type to listen for. - @param callback The callback that will be invoked when the event is dispatched. - The callback is ignored if it is a duplicate (the callbacks are unique). - @param target The target (this object) to invoke the callback, can be null + !#en Scroll with an offset related to the ScrollView's top left origin, if timeInSecond is omitted, then it will jump to the + specific offset immediately. + !#zh 视图内容在规定时间内将滚动到 ScrollView 相对左上角原点的åç§»ä½ç½®, 如果 timeInSecond傿•°ä¸ä¼ ï¼Œåˆ™ç«‹å³æ»šåŠ¨åˆ°æŒ‡å®šåç§»ä½ç½®ã€‚ + @param offset A Vec2, the value of which each axis between 0 and maxScrollOffset + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the specific offset of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. @example ```js - eventTarget.once('fire', function () { - cc.log("this is the callback and will be invoked only once"); - }, node); + // Scroll to middle position in 0.1 second in x-axis + let maxScrollOffset = this.getMaxScrollOffset(); + scrollView.scrollToOffset(cc.v2(maxScrollOffset.x / 2, 0), 0.1); ``` */ - once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + scrollToOffset(offset: Vec2, timeInSecond?: number, attenuated?: boolean): void; /** - !#en - Send an event with the event object. - !#zh - 通过事件对象派å‘事件 - @param event event + !#en Get the positive offset value corresponds to the content's top left boundary. + !#zh èŽ·å–æ»šåŠ¨è§†å›¾ç›¸å¯¹äºŽå·¦ä¸Šè§’åŽŸç‚¹çš„å½“å‰æ»šåЍåç§» */ - dispatchEvent(event: Event): void; - } - /** !#en Base class of all kinds of events. - !#zh 包å«äº‹ä»¶ç›¸å…³ä¿¡æ¯çš„对象。 */ - export class Event { + getScrollOffset(): Vec2; + /** + !#en Get the maximize available scroll offset + !#zh èŽ·å–æ»šåŠ¨è§†å›¾æœ€å¤§å¯ä»¥æ»šåŠ¨çš„åç§»é‡ + */ + getMaxScrollOffset(): Vec2; /** + !#en Scroll the content to the horizontal percent position of ScrollView. + !#zh 视图内容在规定时间内将滚动到 ScrollView 水平方å‘的百分比ä½ç½®ä¸Šã€‚ + @param percent A value between 0 and 1. + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the horizontal percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. - @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit" - @param bubbles A boolean indicating whether the event bubbles up through the tree or not + @example + ```js + // Scroll to middle position. + scrollView.scrollToBottomRight(0.5, 0.1); + ``` */ - constructor(type: string, bubbles: boolean); - /** !#en The name of the event (case-sensitive), e.g. "click", "fire", or "submit". - !#zh 事件类型。 */ - type: string; - /** !#en Indicate whether the event bubbles up through the tree or not. - !#zh 表示该事件是å¦è¿›è¡Œå†’泡。 */ - bubbles: boolean; - /** !#en A reference to the target to which the event was originally dispatched. - !#zh 最åˆäº‹ä»¶è§¦å‘çš„ç›®æ ‡ */ - target: any; - /** !#en A reference to the currently registered target for the event. - !#zh 当å‰ç›®æ ‡ */ - currentTarget: any; - /** !#en - Indicates which phase of the event flow is currently being evaluated. - Returns an integer value represented by 4 constants: - - Event.NONE = 0 - - Event.CAPTURING_PHASE = 1 - - Event.AT_TARGET = 2 - - Event.BUBBLING_PHASE = 3 - The phases are explained in the [section 3.1, Event dispatch and DOM event flow] - (http://www.w3.org/TR/DOM-Level-3-Events/#event-flow), of the DOM Level 3 Events specification. - !#zh 事件阶段 */ - eventPhase: number; + scrollToPercentHorizontal(percent: number, timeInSecond?: number, attenuated?: boolean): void; /** - !#en Reset the event for being stored in the object pool. - !#zh é‡ç½®å¯¹è±¡æ± ä¸å˜å‚¨çš„事件。 + !#en Scroll the content to the percent position of ScrollView in any direction. + !#zh 视图内容在规定时间内进行垂直方å‘和水平方å‘的滚动,并且滚动到指定百分比ä½ç½®ä¸Šã€‚ + @param anchor A point which will be clamp between cc.v2(0,0) and cc.v2(1,1). + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + + @example + ```js + // Vertical scroll to the bottom of the view. + scrollView.scrollTo(cc.v2(0, 1), 0.1); + + // Horizontal scroll to view right. + scrollView.scrollTo(cc.v2(1, 0), 0.1); + ``` */ - unuse(): string; + scrollTo(anchor: Vec2, timeInSecond?: number, attenuated?: boolean): void; /** - !#en Reuse the event for being used again by the object pool. - !#zh ç”¨äºŽå¯¹è±¡æ± å†æ¬¡ä½¿ç”¨çš„事件。 + !#en Scroll the content to the vertical percent position of ScrollView. + !#zh 视图内容在规定时间内滚动到 ScrollView 垂直方å‘的百分比ä½ç½®ä¸Šã€‚ + @param percent A value between 0 and 1. + @param timeInSecond Scroll time in second, if you don't pass timeInSecond, + the content will jump to the vertical percent position of ScrollView immediately. + @param attenuated Whether the scroll acceleration attenuated, default is true. + // Scroll to middle position. + scrollView.scrollToPercentVertical(0.5, 0.1); */ - reuse(): string; + scrollToPercentVertical(percent: number, timeInSecond?: number, attenuated?: boolean): void; /** - !#en Stops propagation for current event. - !#zh åœæ¢ä¼ 递当å‰äº‹ä»¶ã€‚ + !#en Stop auto scroll immediately + !#zh åœæ¢è‡ªåŠ¨æ»šåŠ¨, è°ƒç”¨æ¤ API å¯ä»¥è®© Scrollview ç«‹å³åœæ¢æ»šåЍ */ - stopPropagation(): void; + stopAutoScroll(): void; + /** + !#en Modify the content position. + !#zh 设置当å‰è§†å›¾å†…å®¹çš„åæ ‡ç‚¹ã€‚ + @param position The position in content's parent space. + */ + setContentPosition(position: Vec2): void; + /** + !#en Query the content's position in its parent space. + !#zh 获å–当å‰è§†å›¾å†…å®¹çš„åæ ‡ç‚¹ã€‚ + */ + getContentPosition(): Vec2; + /** + !#en Query whether the user is currently dragging the ScrollView to scroll it + !#zh 用户是å¦åœ¨æ‹–æ‹½å½“å‰æ»šåŠ¨è§†å›¾ + */ + isScrolling(): boolean; + /** + !#en Query whether the ScrollView is currently scrolling because of a bounceback or inertia slowdown. + !#zh 当剿»šåŠ¨è§†å›¾æ˜¯å¦åœ¨æƒ¯æ€§æ»šåЍ + */ + isAutoScrolling(): boolean; + } + /** !#en The Slider Control + !#zh 滑动器组件 */ + export class Slider extends Component { + /** !#en The "handle" part of the slider + !#zh æ»‘åŠ¨å™¨æ»‘å—æŒ‰é’®éƒ¨ä»¶ */ + handle: Button; + /** !#en The slider direction + !#zh æ»‘åŠ¨å™¨æ–¹å‘ */ + direction: Slider.Direction; + /** !#en The current progress of the slider. The valid value is between 0-1 + !#zh 当å‰è¿›åº¦å€¼ï¼Œè¯¥æ•°å€¼çš„区间是 0-1 之间 */ + progress: number; + /** !#en The slider slide events' callback array + !#zh 滑动器组件滑动事件回调函数数组 */ + slideEvents: Component.EventHandler[]; + } + /** !#en Renders a sprite in the scene. + !#zh è¯¥ç»„ä»¶ç”¨äºŽåœ¨åœºæ™¯ä¸æ¸²æŸ“ç²¾çµã€‚ */ + export class Sprite extends RenderComponent implements BlendFunc { + /** !#en The sprite frame of the sprite. + !#zh ç²¾çµçš„ç²¾çµå¸§ */ + spriteFrame: SpriteFrame; + /** !#en The sprite render type. + !#zh ç²¾çµæ¸²æŸ“类型 */ + type: Sprite.Type; + /** !#en + The fill type, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLEDâ€. + !#zh + ç²¾çµå¡«å……类型,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillType: Sprite.FillType; + /** !#en + The fill Center, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLEDâ€. + !#zh + å¡«å……ä¸å¿ƒç‚¹ï¼Œä»…渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillCenter: Vec2; + /** !#en + The fill Start, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLEDâ€. + !#zh + 填充起始点,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillStart: number; + /** !#en + The fill Range, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLEDâ€. + !#zh + 填充范围,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */ + fillRange: number; + /** !#en specify the frame is trimmed or not. + !#zh 是å¦ä½¿ç”¨è£å‰ªæ¨¡å¼ */ + trim: boolean; + /** !#en specify the size tracing mode. + !#zh ç²¾çµå°ºå¯¸è°ƒæ•´æ¨¡å¼ */ + sizeMode: Sprite.SizeMode; /** - !#en Stops propagation for current event immediately, - the event won't even be dispatched to the listeners attached in the current target. - !#zh ç«‹å³åœæ¢å½“å‰äº‹ä»¶çš„ä¼ é€’ï¼Œäº‹ä»¶ç”šè‡³ä¸ä¼šè¢«åˆ†æ´¾åˆ°æ‰€è¿žæŽ¥çš„当å‰ç›®æ ‡ã€‚ + Change the state of sprite. + @param state NORMAL or GRAY State. */ - stopPropagationImmediate(): void; + setState(state: Sprite.State): void; /** - !#en Checks whether the event has been stopped. - !#zh 检查该事件是å¦å·²ç»åœæ¢ä¼ 递. + Gets the current state. */ - isStopped(): boolean; + getState(): Sprite.State; + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh æŒ‡å®šåŽŸå›¾çš„æ··åˆæ¨¡å¼ï¼Œè¿™ä¼šå…‹éš†ä¸€ä¸ªæ–°çš„æè´¨å¯¹è±¡ï¼Œæ³¨æ„这带æ¥çš„开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh æŒ‡å®šç›®æ ‡çš„æ··åˆæ¨¡å¼ */ + dstBlendFactor: macro.BlendFactor; + } + /** !#en The toggle component is a CheckBox, when it used together with a ToggleGroup, it + could be treated as a RadioButton. + !#zh Toggle 是一个 CheckBox,当它和 ToggleGroup 一起使用的时候,å¯ä»¥å˜æˆ RadioButton。 */ + export class Toggle extends Button implements GraySpriteState { + /** !#en When this value is true, the check mark component will be enabled, otherwise + the check mark component will be disabled. + !#zh 如果这个设置为 true,则 check mark 组件会处于 enabled 状æ€ï¼Œå¦åˆ™å¤„于 disabled 状æ€ã€‚ */ + isChecked: boolean; + /** !#en The toggle group which the toggle belongs to, when it is null, the toggle is a CheckBox. + Otherwise, the toggle is a RadioButton. + !#zh Toggle 所属的 ToggleGroup,这个属性是å¯é€‰çš„。如果这个属性为 null,则 Toggle 是一个 CheckBox, + å¦åˆ™ï¼ŒToggle 是一个 RadioButton。 */ + toggleGroup: ToggleGroup; + /** !#en The image used for the checkmark. + !#zh Toggle 处于选ä¸çŠ¶æ€æ—¶æ˜¾ç¤ºçš„图片 */ + checkMark: Sprite; + /** !#en If Toggle is clicked, it will trigger event's handler + !#zh Toggle 按钮的点击事件列表。 */ + checkEvents: Component.EventHandler[]; /** - !#en - <p> - Gets current target of the event <br/> - note: It only be available when the event listener is associated with node. <br/> - It returns 0 when the listener is associated with fixed priority. - </p> - !#zh 获å–当å‰ç›®æ ‡èŠ‚ç‚¹ + !#en Make the toggle button checked. + !#zh 使 toggle 按钮处于选ä¸çŠ¶æ€ */ - getCurrentTarget(): Node; + check(): void; /** - !#en Gets the event type. - !#zh 获å–事件类型 + !#en Make the toggle button unchecked. + !#zh 使 toggle 按钮处于未选ä¸çŠ¶æ€ */ - getType(): string; - /** !#en Code for event without type. - !#zh 没有类型的事件 */ - static NO_TYPE: string; - /** !#en The type code of Touch event. - !#zh 触摸事件类型 */ - static TOUCH: string; - /** !#en The type code of Mouse event. - !#zh é¼ æ ‡äº‹ä»¶ç±»åž‹ */ - static MOUSE: string; - /** !#en The type code of Keyboard event. - !#zh 键盘事件类型 */ - static KEYBOARD: string; - /** !#en The type code of Acceleration event. - !#zh åŠ é€Ÿå™¨äº‹ä»¶ç±»åž‹ */ - static ACCELERATION: string; - /** !#en Events not currently dispatched are in this phase - !#zh 尚未派å‘事件阶段 */ - static NONE: number; - /** !#en - The capturing phase comprises the journey from the root to the last node before the event target's node - see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow - !#zh æ•èŽ·é˜¶æ®µï¼ŒåŒ…æ‹¬äº‹ä»¶ç›®æ ‡èŠ‚ç‚¹ä¹‹å‰ä»Žæ ¹èŠ‚ç‚¹åˆ°æœ€åŽä¸€ä¸ªèŠ‚ç‚¹çš„è¿‡ç¨‹ã€‚ */ - static CAPTURING_PHASE: number; - /** !#en - The target phase comprises only the event target node - see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow - !#zh ç›®æ ‡é˜¶æ®µä»…åŒ…æ‹¬äº‹ä»¶ç›®æ ‡èŠ‚ç‚¹ã€‚ */ - static AT_TARGET: number; - /** !#en - The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the hierarchy - see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow - !#zh 冒泡阶段, 包括回程é‡åˆ°åˆ°å±‚æ¬¡æ ¹èŠ‚ç‚¹çš„ä»»ä½•åŽç»èŠ‚ç‚¹ã€‚ */ - static BUBBLING_PHASE: number; + uncheck(): void; + /** !#en The normal material. + !#zh æ£å¸¸çжæ€çš„æè´¨ã€‚ */ + normalMaterial: Material; + /** !#en The gray material. + !#zh ç½®ç°çжæ€çš„æè´¨ã€‚ */ + grayMaterial: Material; + } + /** !#en ToggleContainer is not a visiable UI component but a way to modify the behavior of a set of Toggles. <br/> + Toggles that belong to the same group could only have one of them to be switched on at a time.<br/> + Note: All the first layer child node containing the toggle component will auto be added to the container + !#zh ToggleContainer 䏿˜¯ä¸€ä¸ªå¯è§çš„ UI 组件,它å¯ä»¥ç”¨æ¥ä¿®æ”¹ä¸€ç»„ Toggle 组件的行为。<br/> + 当一组 Toggle 属于åŒä¸€ä¸ª ToggleContainer 的时候,任何时候åªèƒ½æœ‰ä¸€ä¸ª Toggle 处于选ä¸çжæ€ã€‚<br/> + 注æ„ï¼šæ‰€æœ‰åŒ…å« Toggle 组件的一级åèŠ‚ç‚¹éƒ½ä¼šè‡ªåŠ¨è¢«æ·»åŠ åˆ°è¯¥å®¹å™¨ä¸ */ + export class ToggleContainer extends Component { + /** !#en If this setting is true, a toggle could be switched off and on when pressed. + If it is false, it will make sure there is always only one toggle could be switched on + and the already switched on toggle can't be switched off. + !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候å¯ä»¥åå¤åœ°è¢«é€‰ä¸å’Œæœªé€‰ä¸ã€‚ */ + allowSwitchOff: boolean; + /** !#en If Toggle is clicked, it will trigger event's handler + !#zh Toggle 按钮的点击事件列表。 */ + checkEvents: Component.EventHandler[]; + /** !#en Read only property, return the toggle items array reference managed by ToggleContainer. + !#zh åªè¯»å±žæ€§ï¼Œè¿”回 ToggleContainer 管ç†çš„ toggle 数组引用 */ + toggleItems: Toggle[]; + } + /** !#en ToggleGroup is not a visiable UI component but a way to modify the behavior of a set of Toggles. + Toggles that belong to the same group could only have one of them to be switched on at a time. + !#zh ToggleGroup 䏿˜¯ä¸€ä¸ªå¯è§çš„ UI 组件,它å¯ä»¥ç”¨æ¥ä¿®æ”¹ä¸€ç»„ Toggle 组件的行为。当一组 Toggle 属于åŒä¸€ä¸ª ToggleGroup 的时候, + 任何时候åªèƒ½æœ‰ä¸€ä¸ª Toggle 处于选ä¸çжæ€ã€‚ */ + export class ToggleGroup extends Component { + /** !#en If this setting is true, a toggle could be switched off and on when pressed. + If it is false, it will make sure there is always only one toggle could be switched on + and the already switched on toggle can't be switched off. + !#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候å¯ä»¥åå¤åœ°è¢«é€‰ä¸å’Œæœªé€‰ä¸ã€‚ */ + allowSwitchOff: boolean; + /** !#en Read only property, return the toggle items array reference managed by toggleGroup. + !#zh åªè¯»å±žæ€§ï¼Œè¿”回 toggleGroup 管ç†çš„ toggle 数组引用 */ + toggleItems: any[]; } /** !#en - The System event, it currently supports keyboard events and accelerometer events.<br> - You can get the SystemEvent instance with cc.systemEvent.<br> + Handling touch events in a ViewGroup takes special care, + because it's common for a ViewGroup to have children that are targets for different touch events than the ViewGroup itself. + To make sure that each view correctly receives the touch events intended for it, + ViewGroup should register capture phase event and handle the event propagation properly. + Please refer to Scrollview for more information. + !#zh - ç³»ç»Ÿäº‹ä»¶ï¼Œå®ƒç›®å‰æ”¯æŒæŒ‰é”®äº‹ä»¶å’Œé‡åŠ›æ„Ÿåº”äº‹ä»¶ã€‚<br> - ä½ å¯ä»¥é€šè¿‡ cc.systemEvent 获å–到 SystemEvent 的实例。<br> */ - export class SystemEvent extends EventTarget { - /** - !#en whether enable accelerometer event - !#zh 是å¦å¯ç”¨åŠ é€Ÿåº¦è®¡äº‹ä»¶ - @param isEnable isEnable - */ - setAccelerometerEnabled(isEnable: boolean): void; - /** - !#en set accelerometer interval value - !#zh è®¾ç½®åŠ é€Ÿåº¦è®¡é—´éš”å€¼ - @param interval interval - */ - setAccelerometerInterval(interval: number): void; + ViewGroupçš„äº‹ä»¶å¤„ç†æ¯”è¾ƒç‰¹æ®Šï¼Œå› ä¸º ViewGroup 里é¢çš„å节点关心的事件跟 ViewGroup 本身å¯èƒ½ä¸ä¸€æ ·ã€‚ + 为了让å节点能够æ£ç¡®åœ°å¤„ç†äº‹ä»¶ï¼ŒViewGroup éœ€è¦æ³¨å†Œ capture 阶段的事件,并且åˆç†åœ°å¤„ç† ViewGroup ä¹‹é—´çš„äº‹ä»¶ä¼ é€’ã€‚ + 请å‚考 ScrollView 的实现æ¥èŽ·å–æ›´å¤šä¿¡æ¯ã€‚ */ + export class ViewGroup extends Component { } - /** undefined */ - export class WorldManifold { + /** !#en + Stores and manipulate the anchoring based on its parent. + Widget are used for GUI but can also be used for other things. + Widget will adjust current node's position and size automatically, but the results after adjustment can not be obtained until the next frame unless you call {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}} manually. + !#zh + Widget 组件,用于设置和适é…其相对于父节点的边è·ï¼ŒWidget 通常被用于 UI 界é¢ï¼Œä¹Ÿå¯ä»¥ç”¨äºŽå…¶ä»–地方。 + Widget 会自动调整当å‰èŠ‚ç‚¹çš„åæ ‡å’Œå®½é«˜ï¼Œä¸è¿‡ç›®å‰è°ƒæ•´åŽçš„结果è¦åˆ°ä¸‹ä¸€å¸§æ‰èƒ½åœ¨è„šæœ¬é‡ŒèŽ·å–到,除éžä½ 先手动调用 {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}}。 */ + export class Widget extends Component { + /** !#en Specifies an alignment target that can only be one of the parent nodes of the current node. + The default value is null, and when null, indicates the current parent. + !#zh 指定一个对é½ç›®æ ‡ï¼Œåªèƒ½æ˜¯å½“å‰èŠ‚ç‚¹çš„å…¶ä¸ä¸€ä¸ªçˆ¶èŠ‚ç‚¹ï¼Œé»˜è®¤ä¸ºç©ºï¼Œä¸ºç©ºæ—¶è¡¨ç¤ºå½“å‰çˆ¶èŠ‚ç‚¹ã€‚ */ + target: Node; + /** !#en Whether to align the top. + !#zh 是å¦å¯¹é½ä¸Šè¾¹ã€‚ */ + isAlignTop: boolean; /** !#en - world contact point (point of intersection) + Vertically aligns the midpoint, This will open the other vertical alignment options cancel. !#zh - ç¢°æ’žç‚¹é›†åˆ */ - points: Vec2[]; + 是å¦åž‚ç›´æ–¹å‘对é½ä¸ç‚¹ï¼Œå¼€å¯æ¤é¡¹ä¼šå°†åž‚ç›´æ–¹å‘其他对é½é€‰é¡¹å–消。 */ + isAlignVerticalCenter: boolean; + /** !#en Whether to align the bottom. + !#zh 是å¦å¯¹é½ä¸‹è¾¹ã€‚ */ + isAlignBottom: boolean; + /** !#en Whether to align the left. + !#zh 是å¦å¯¹é½å·¦è¾¹ */ + isAlignLeft: boolean; /** !#en - world vector pointing from A to B + Horizontal aligns the midpoint. This will open the other horizontal alignment options canceled. !#zh - ä¸–ç•Œåæ ‡ç³»ä¸‹ç”± A æŒ‡å‘ B çš„å‘é‡ */ - normal: Vec2; - } - /** !#en - A manifold point is a contact point belonging to a contact manifold. - It holds details related to the geometry and dynamics of the contact points. - Note: the impulses are used for internal caching and may not - provide reliable contact forces, especially for high speed collisions. - !#zh - ManifoldPoint 是接触信æ¯ä¸çš„æŽ¥è§¦ç‚¹ä¿¡æ¯ã€‚å®ƒæ‹¥æœ‰å…³äºŽå‡ ä½•å’ŒæŽ¥è§¦ç‚¹çš„è¯¦ç»†ä¿¡æ¯ã€‚ - 注æ„:信æ¯ä¸çš„冲é‡ç”¨äºŽç³»ç»Ÿå†…部缓å˜ï¼Œæä¾›çš„æŽ¥è§¦åŠ›å¯èƒ½ä¸æ˜¯å¾ˆå‡†ç¡®ï¼Œç‰¹åˆ«æ˜¯é«˜é€Ÿç§»åЍä¸çš„碰撞信æ¯ã€‚ */ - export class ManifoldPoint { + æ˜¯å¦æ°´å¹³æ–¹å‘对é½ä¸ç‚¹ï¼Œå¼€å¯æ¤é€‰é¡¹ä¼šå°†æ°´å¹³æ–¹å‘其他对é½é€‰é¡¹å–消。 */ + isAlignHorizontalCenter: boolean; + /** !#en Whether to align the right. + !#zh 是å¦å¯¹é½å³è¾¹ã€‚ */ + isAlignRight: boolean; /** !#en - The local point usage depends on the manifold type: - -e_circles: the local center of circleB - -e_faceA: the local center of circleB or the clip point of polygonB - -e_faceB: the clip point of polygonA + Whether the stretched horizontally, when enable the left and right alignment will be stretched horizontally, + the width setting is invalid (read only). !#zh - æœ¬åœ°åæ ‡ç‚¹çš„用途å–决于 manifold 的类型 - - e_circles: circleB 的本地ä¸å¿ƒç‚¹ - - e_faceA: circleB 的本地ä¸å¿ƒç‚¹ 或者是 polygonB 的截å–点 - - e_faceB: polygonB 的截å–点 */ - localPoint: Vec2; + 当剿˜¯å¦æ°´å¹³æ‹‰ä¼¸ã€‚å½“åŒæ—¶å¯ç”¨å·¦å³å¯¹é½æ—¶ï¼ŒèŠ‚ç‚¹å°†ä¼šè¢«æ°´å¹³æ‹‰ä¼¸ï¼Œæ¤æ—¶èŠ‚ç‚¹çš„å®½åº¦åªè¯»ã€‚ */ + isStretchWidth: boolean; /** !#en - Normal impulse. + Whether the stretched vertically, when enable the left and right alignment will be stretched vertically, + then height setting is invalid (read only) !#zh - 法线冲é‡ã€‚ */ - normalImpulse: number; + 当剿˜¯å¦åž‚ç›´æ‹‰ä¼¸ã€‚å½“åŒæ—¶å¯ç”¨ä¸Šä¸‹å¯¹é½æ—¶ï¼ŒèŠ‚ç‚¹å°†ä¼šè¢«åž‚ç›´æ‹‰ä¼¸ï¼Œæ¤æ—¶èŠ‚ç‚¹çš„é«˜åº¦åªè¯»ã€‚ */ + isStretchHeight: boolean; + /** !#en + The margins between the top of this node and the top of parent node, + the value can be negative, Only available in 'isAlignTop' open. + !#zh + 本节点顶边和父节点顶边的è·ç¦»ï¼Œå¯å¡«å†™è´Ÿå€¼ï¼Œåªæœ‰åœ¨ isAlignTop 开坿—¶æ‰æœ‰ä½œç”¨ã€‚ */ + top: number; /** !#en - Tangent impulse. + The margins between the bottom of this node and the bottom of parent node, + the value can be negative, Only available in 'isAlignBottom' open. !#zh - 切线冲é‡ã€‚ */ - tangentImpulse: number; - } - /** undefined */ - export class Manifold { + 本节点底边和父节点底边的è·ç¦»ï¼Œå¯å¡«å†™è´Ÿå€¼ï¼Œåªæœ‰åœ¨ isAlignBottom 开坿—¶æ‰æœ‰ä½œç”¨ã€‚ */ + bottom: number; /** !#en - Manifold type : 0: e_circles, 1: e_faceA, 2: e_faceB + The margins between the left of this node and the left of parent node, + the value can be negative, Only available in 'isAlignLeft' open. !#zh - Manifold 类型 : 0: e_circles, 1: e_faceA, 2: e_faceB */ - type: number; + 本节点左边和父节点左边的è·ç¦»ï¼Œå¯å¡«å†™è´Ÿå€¼ï¼Œåªæœ‰åœ¨ isAlignLeft 开坿—¶æ‰æœ‰ä½œç”¨ã€‚ */ + left: number; /** !#en - The local point usage depends on the manifold type: - -e_circles: the local center of circleA - -e_faceA: the center of faceA - -e_faceB: the center of faceB + The margins between the right of this node and the right of parent node, + the value can be negative, Only available in 'isAlignRight' open. !#zh - 用途å–决于 manifold 类型 - -e_circles: circleA 的本地ä¸å¿ƒç‚¹ - -e_faceA: faceA 的本地ä¸å¿ƒç‚¹ - -e_faceB: faceB 的本地ä¸å¿ƒç‚¹ */ - localPoint: Vec2; + 本节点å³è¾¹å’Œçˆ¶èŠ‚ç‚¹å³è¾¹çš„è·ç¦»ï¼Œå¯å¡«å†™è´Ÿå€¼ï¼Œåªæœ‰åœ¨ isAlignRight 开坿—¶æ‰æœ‰ä½œç”¨ã€‚ */ + right: number; /** !#en - -e_circles: not used - -e_faceA: the normal on polygonA - -e_faceB: the normal on polygonB + Horizontal aligns the midpoint offset value, + the value can be negative, Only available in 'isAlignHorizontalCenter' open. + !#zh 水平居ä¸çš„å移值,å¯å¡«å†™è´Ÿå€¼ï¼Œåªæœ‰åœ¨ isAlignHorizontalCenter 开坿—¶æ‰æœ‰ä½œç”¨ã€‚ */ + horizontalCenter: number; + /** !#en + Vertical aligns the midpoint offset value, + the value can be negative, Only available in 'isAlignVerticalCenter' open. + !#zh 垂直居ä¸çš„å移值,å¯å¡«å†™è´Ÿå€¼ï¼Œåªæœ‰åœ¨ isAlignVerticalCenter 开坿—¶æ‰æœ‰ä½œç”¨ã€‚ */ + verticalCenter: number; + /** !#en If true, horizontalCenter is pixel margin, otherwise is percentage (0 - 1) margin. + !#zh 如果为 true,"horizontalCenter" 将会以åƒç´ 作为å移值,å之为百分比(0 到 1)。 */ + isAbsoluteHorizontalCenter: boolean; + /** !#en If true, verticalCenter is pixel margin, otherwise is percentage (0 - 1) margin. + !#zh 如果为 true,"verticalCenter" 将会以åƒç´ 作为å移值,å之为百分比(0 到 1)。 */ + isAbsoluteVerticalCenter: boolean; + /** !#en + If true, top is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height. !#zh - -e_circles: 没被使用到 - -e_faceA: polygonA 的法å‘é‡ - -e_faceB: polygonB 的法å‘é‡ */ - localNormal: Vec2; + 如果为 true,"top" 将会以åƒç´ 作为边è·ï¼Œå¦åˆ™å°†ä¼šä»¥ç›¸å¯¹çˆ¶ç‰©ä½“高度的百分比(0 到 1)作为边è·ã€‚ */ + isAbsoluteTop: boolean; /** !#en - the points of contact. + If true, bottom is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height. !#zh - 接触点信æ¯ã€‚ */ - points: ManifoldPoint[]; - } - /** !#en - Contact impulses for reporting. - !#zh - 用于返回给回调的接触冲é‡ã€‚ */ - export class PhysicsImpulse { + 如果为 true,"bottom" 将会以åƒç´ 作为边è·ï¼Œå¦åˆ™å°†ä¼šä»¥ç›¸å¯¹çˆ¶ç‰©ä½“高度的百分比(0 到 1)作为边è·ã€‚ */ + isAbsoluteBottom: boolean; /** !#en - Normal impulses. + If true, left is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width. !#zh - 法线方å‘çš„å†²é‡ */ - normalImpulses: any; + 如果为 true,"left" 将会以åƒç´ 作为边è·ï¼Œå¦åˆ™å°†ä¼šä»¥ç›¸å¯¹çˆ¶ç‰©ä½“宽度的百分比(0 到 1)作为边è·ã€‚ */ + isAbsoluteLeft: boolean; /** !#en - Tangent impulses + If true, right is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width. !#zh - 切线方å‘çš„å†²é‡ */ - tangentImpulses: any; - } - /** !#en - PhysicsContact will be generated during begin and end collision as a parameter of the collision callback. - Note that contacts will be reused for speed up cpu time, so do not cache anything in the contact. - !#zh - ç‰©ç†æŽ¥è§¦ä¼šåœ¨å¼€å§‹å’Œç»“æŸç¢°æ’žä¹‹é—´ç”Ÿæˆï¼Œå¹¶ä½œä¸ºå‚æ•°ä¼ å…¥åˆ°ç¢°æ’žå›žè°ƒå‡½æ•°ä¸ã€‚ - 注æ„ï¼šä¼ å…¥çš„ç‰©ç†æŽ¥è§¦ä¼šè¢«ç³»ç»Ÿè¿›è¡Œé‡ç”¨ï¼Œæ‰€ä»¥ä¸è¦åœ¨ä½¿ç”¨ä¸ç¼“å˜é‡Œé¢çš„任何信æ¯ã€‚ */ - export class PhysicsContact { + 如果为 true,"right" 将会以åƒç´ 作为边è·ï¼Œå¦åˆ™å°†ä¼šä»¥ç›¸å¯¹çˆ¶ç‰©ä½“宽度的百分比(0 到 1)作为边è·ã€‚ */ + isAbsoluteRight: boolean; + /** !#en Specifies the alignment mode of the Widget, which determines when the widget should refresh. + !#zh 指定 Widget çš„å¯¹é½æ¨¡å¼ï¼Œç”¨äºŽå†³å®š Widget 应该何时刷新。 */ + alignMode: Widget.AlignMode; /** !#en - Get the world manifold. + Immediately perform the widget alignment. You need to manually call this method only if + you need to get the latest results after the alignment before the end of current frame. !#zh - 获å–ä¸–ç•Œåæ ‡ç³»ä¸‹çš„碰撞信æ¯ã€‚ + 立刻执行 widget 坹齿“作。这个接å£ä¸€èˆ¬ä¸éœ€è¦æ‰‹å·¥è°ƒç”¨ã€‚ + åªæœ‰å½“ä½ éœ€è¦åœ¨å½“å‰å¸§ç»“æŸå‰èŽ·å¾— widget 对é½åŽçš„æœ€æ–°ç»“果时æ‰éœ€è¦æ‰‹åŠ¨è°ƒç”¨è¿™ä¸ªæ–¹æ³•ã€‚ + + @example + ```js + widget.top = 10; // change top margin + cc.log(widget.node.y); // not yet changed + widget.updateAlignment(); + cc.log(widget.node.y); // changed + ``` */ - getWorldManifold(): WorldManifold; - /** - !#en - Get the manifold. + updateAlignment(): void; + /** !#en + When turned on, it will only be aligned once at the end of the onEnable frame, + then immediately disables the current component. + This will allow the script or animation to continue controlling the current node. + Note: It will still be aligned at the frame when onEnable is called. !#zh - èŽ·å–æœ¬åœ°ï¼ˆå±€éƒ¨ï¼‰åæ ‡ç³»ä¸‹çš„ç¢°æ’žä¿¡æ¯ã€‚ + å¼€å¯åŽä»…会在 onEnable çš„å½“å¸§ç»“æŸæ—¶å¯¹é½ä¸€æ¬¡ï¼Œç„¶åŽç«‹åˆ»ç¦ç”¨å½“å‰ç»„件。 + è¿™æ ·ä¾¿äºŽè„šæœ¬æˆ–åŠ¨ç”»ç»§ç»æŽ§åˆ¶å½“å‰èŠ‚ç‚¹ã€‚ + 注æ„:onEnable 时所在的那一帧ä»ç„¶ä¼šè¿›è¡Œå¯¹é½ã€‚ */ + isAlignOnce: boolean; + } + /** !#en SubContextView is a view component which controls open data context viewport in minigame platform.<br/> + The component's node size decide the viewport of the sub context content in main context, + the entire sub context texture will be scaled to the node's bounding box area.<br/> + This component provides multiple important features:<br/> + 1. Sub context could use its own resolution size and policy.<br/> + 2. Sub context could be minized to smallest size it needed.<br/> + 3. Resolution of sub context content could be increased.<br/> + 4. User touch input is transformed to the correct viewport.<br/> + 5. Texture update is handled by this component. User don't need to worry.<br/> + One important thing to be noted, whenever the node's bounding box change, + !#zh SubContextView å¯ä»¥ç”¨æ¥æŽ§åˆ¶å°æ¸¸æˆå¹³å°å¼€æ”¾æ•°æ®åŸŸåœ¨ä¸»åŸŸä¸çš„视窗的ä½ç½®ã€‚<br/> + 这个组件的节点尺寸决定了开放数æ®åŸŸå†…容在主域ä¸çš„尺寸,整个开放数æ®åŸŸä¼šè¢«ç¼©æ”¾åˆ°èŠ‚ç‚¹çš„åŒ…å›´ç›’èŒƒå›´å†…ã€‚<br/> + 在这个组件的控制下,用户å¯ä»¥æ›´è‡ªç”±å¾—控制开放数æ®åŸŸï¼š<br/> + 1. å域ä¸å¯ä»¥ä½¿ç”¨ç‹¬ç«‹çš„è®¾è®¡åˆ†è¾¨çŽ‡å’Œé€‚é…æ¨¡å¼<br/> + 2. å域区域尺寸å¯ä»¥ç¼©å°åˆ°åªå®¹çº³å†…容å³å¯<br/> + 3. å域的分辨率也å¯ä»¥è¢«æ”¾å¤§ï¼Œä»¥ä¾¿èŽ·å¾—æ›´æ¸…æ™°çš„æ˜¾ç¤ºæ•ˆæžœ<br/> + 4. ç”¨æˆ·è¾“å…¥åæ ‡ä¼šè¢«è‡ªåŠ¨è½¬æ¢åˆ°æ£ç¡®çš„å域视窗ä¸<br/> + 5. å域内容贴图的更新由组件负责,用户ä¸éœ€è¦å¤„ç†<br/> */ + export class SubContextView extends Component { + /** + !#en Reset open data context size and viewport + !#zh é‡ç½®å¼€æ”¾æ•°æ®åŸŸçš„尺寸和视窗 */ - getManifold(): Manifold; + reset(): void; /** - !#en - Get the impulses. - Note: PhysicsImpulse can only used in onPostSolve callback. - !#zh - 获å–冲é‡ä¿¡æ¯ - 注æ„:这个信æ¯åªæœ‰åœ¨ onPostSolve å›žè°ƒä¸æ‰èƒ½èŽ·å–到 + !#en Update the sub context viewport manually, it should be called whenever the node's bounding box changes. + !#zh 更新开放数æ®åŸŸç›¸å¯¹äºŽä¸»åŸŸçš„ viewportï¼Œè¿™ä¸ªå‡½æ•°åº”è¯¥åœ¨èŠ‚ç‚¹åŒ…å›´ç›’æ”¹å˜æ—¶æ‰‹åŠ¨è°ƒç”¨ã€‚ */ - getImpulse(): PhysicsImpulse; - /** !#en - One of the collider that collided - !#zh - å‘生碰撞的碰撞体之一 */ - colliderA: Collider; - /** !#en - One of the collider that collided - !#zh - å‘生碰撞的碰撞体之一 */ - colliderB: Collider; - /** !#en - If set disabled to true, the contact will be ignored until contact end. - If you just want to disabled contact for current time step or sub-step, please use disabledOnce. - !#zh - 如果 disabled 被设置为 trueï¼Œé‚£ä¹ˆç›´åˆ°æŽ¥è§¦ç»“æŸæ¤æŽ¥è§¦éƒ½å°†è¢«å¿½ç•¥ã€‚ - å¦‚æžœåªæ˜¯å¸Œæœ›åœ¨å½“剿—¶é—´æ¥æˆ–忥ä¸å¿½ç•¥æ¤æŽ¥è§¦ï¼Œè¯·ä½¿ç”¨ disabledOnce 。 */ - disabled: boolean; - /** !#en - Disabled contact for current time step or sub-step. - !#zh - åœ¨å½“å‰æ—¶é—´æ¥æˆ–忥ä¸å¿½ç•¥æ¤æŽ¥è§¦ã€‚ */ - disabledOnce: boolean; + updateSubContextViewport(): void; + } + /** !#en WXSubContextView is deprecated since v2.4.1, please use SubContextView instead. + !#zh 自 v2.4.1 起,WXSubContextView å·²ç»åºŸå¼ƒï¼Œè¯·ä½¿ç”¨ SubContextView */ + export class WXSubContextView extends Component { + } + /** !#en SwanSubContextView is deprecated since v2.4.1, please use SubContextView instead. + !#zh 自 v2.4.1 起,SwanSubContextView å·²ç»åºŸå¼ƒï¼Œè¯·ä½¿ç”¨ SubContextView */ + export class SwanSubContextView extends Component { + } + /** !#en Mesh Asset. + !#zh ç½‘æ ¼èµ„æºã€‚ */ + export class Mesh extends Asset implements EventTarget { + /** !#en Get ir set the sub meshes. + !#zh 设置或者获å–åç½‘æ ¼ã€‚ */ + subMeshes: InputAssembler[]; /** !#en - Is this contact touching? + Init vertex buffer according to the vertex format. !#zh - 返回碰撞体是å¦å·²ç»æŽ¥è§¦åˆ°ã€‚ + æ ¹æ®é¡¶ç‚¹æ ¼å¼åˆå§‹åŒ–顶点内å˜ã€‚ + @param vertexFormat vertex format + @param vertexCount how much vertex should be create in this buffer. + @param dynamic whether or not to use dynamic buffer. + @param index index */ - isTouching(): boolean; + init(vertexFormat: gfx.VertexFormat, vertexCount: number, dynamic?: boolean, index?: boolean): void; /** !#en - Set the desired tangent speed for a conveyor belt behavior. + Set the vertex values. !#zh - ä¸ºä¼ é€å¸¦è®¾ç½®æœŸæœ›çš„切线速度 - @param tangentSpeed tangentSpeed + è®¾ç½®é¡¶ç‚¹æ•°æ® + @param name the attribute name, e.g. gfx.ATTR_POSITION + @param values the vertex values */ - setTangentSpeed(tangentSpeed: number): void; + setVertices(name: string, values: Vec2[]|Vec3[]|Color[]|number[]|Uint8Array|Float32Array): void; /** !#en - Get the desired tangent speed. + Set the sub mesh indices. !#zh - 获å–切线速度 + 设置åç½‘æ ¼ç´¢å¼•ã€‚ + @param indices the sub mesh indices. + @param index sub mesh index. + @param dynamic whether or not to use dynamic buffer. */ - getTangentSpeed(): number; + setIndices(indices: number[]|Uint16Array|Uint8Array, index?: number, dynamic?: boolean): void; /** !#en - Override the default friction mixture. You can call this in onPreSolve callback. + Set the sub mesh primitive type. !#zh - è¦†ç›–é»˜è®¤çš„æ‘©æ“¦åŠ›ç³»æ•°ã€‚ä½ å¯ä»¥åœ¨ onPreSolve 回调ä¸è°ƒç”¨æ¤å‡½æ•°ã€‚ - @param friction friction + 设置åç½‘æ ¼ç»˜åˆ¶çº¿æ¡çš„æ–¹å¼ã€‚ + @param type type + @param index index */ - setFriction(friction: number): void; + setPrimitiveType(type: number, index: number): void; /** !#en - Get the friction. + Clear the buffer data. !#zh - 获å–当剿‘©æ“¦åŠ›ç³»æ•° + æ¸…é™¤ç½‘æ ¼åˆ›å»ºçš„å†…å˜æ•°æ®ã€‚ */ - getFriction(): number; + clear(): void; + /** + !#en Set mesh bounding box + !#zh è®¾ç½®ç½‘æ ¼çš„åŒ…å›´ç›’ + @param min min + @param max max + */ + setBoundingBox(min: Vec3, max: Vec3): void; + /** + !#en Read the specified attributes of the subgrid into the target buffer. + !#zh 读å–åç½‘æ ¼çš„æŒ‡å®šå±žæ€§åˆ°ç›®æ ‡ç¼“å†²åŒºä¸ã€‚ + @param primitiveIndex The subgrid index. + @param attributeName attribute name. + @param buffer The target buffer. + @param stride The byte interval between adjacent attributes in the target buffer. + @param offset The offset of the first attribute in the target buffer. + */ + copyAttribute(primitiveIndex: number, attributeName: string, buffer: ArrayBuffer, stride: number, offset: number): boolean; + /** + !#en Read the index data of the subgrid into the target array. + !#zh 读å–åç½‘æ ¼çš„ç´¢å¼•æ•°æ®åˆ°ç›®æ ‡æ•°ç»„ä¸ã€‚ + @param primitiveIndex The subgrid index. + @param outputArray The target array. + */ + copyIndices(primitiveIndex: number, outputArray: DataView): boolean; + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh æ£€æŸ¥äº‹ä»¶ç›®æ ‡å¯¹è±¡æ˜¯å¦æœ‰ä¸ºç‰¹å®šç±»åž‹çš„事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; /** !#en - Reset the friction mixture to the default value. + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. !#zh - é‡ç½®æ‘©æ“¦åŠ›ç³»æ•°åˆ°é»˜è®¤å€¼ + æ³¨å†Œäº‹ä»¶ç›®æ ‡çš„ç‰¹å®šäº‹ä»¶ç±»åž‹å›žè°ƒã€‚è¿™ç§ç±»åž‹çš„事件应该被 `emit` 触å‘。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` */ - resetFriction(): void; + on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T; /** !#en - Override the default restitution mixture. You can call this in onPreSolve callback. + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. !#zh - 覆盖默认的æ¢å¤ç³»æ•°ã€‚ä½ å¯ä»¥åœ¨ onPreSolve 回调ä¸è°ƒç”¨æ¤å‡½æ•°ã€‚ - @param restitution restitution + åˆ é™¤ä¹‹å‰ç”¨åŒç±»åž‹ï¼Œå›žè°ƒï¼Œç›®æ ‡æˆ– useCapture 注册的事件监å¬å™¨ï¼Œå¦‚æžœåªä¼ 递 typeï¼Œå°†ä¼šåˆ é™¤ type 类型的所有事件监å¬å™¨ã€‚ + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // 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'); + ``` */ - setRestitution(restitution: number): void; + off(type: string, callback?: Function, target?: any): void; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh åœ¨å½“å‰ EventTarget ä¸Šåˆ é™¤æŒ‡å®šç›®æ ‡ï¼ˆtarget 傿•°ï¼‰æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ + è¿™ä¸ªå‡½æ•°æ— æ³•åˆ é™¤å½“å‰ EventTarget 的所有事件监å¬å™¨ï¼Œä¹Ÿæ— æ³•åˆ é™¤ target 傿•°æ‰€æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ + 这个函数åªèƒ½åˆ 除 target 傿•°åœ¨å½“å‰ EventTarget 上注册的所有事件监å¬å™¨ã€‚ + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; /** !#en - Get the restitution. + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. !#zh - 获å–当剿¢å¤ç³»æ•° + æ³¨å†Œäº‹ä»¶ç›®æ ‡çš„ç‰¹å®šäº‹ä»¶ç±»åž‹å›žè°ƒï¼Œå›žè°ƒä¼šåœ¨ç¬¬ä¸€æ—¶é—´è¢«è§¦å‘åŽåˆ 除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` */ - getRestitution(): number; + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; /** !#en - Reset the restitution mixture to the default value. + Send an event with the event object. !#zh - é‡ç½®æ¢å¤ç³»æ•°åˆ°é»˜è®¤å€¼ + 通过事件对象派å‘事件 + @param event event */ - resetRestitution(): void; + dispatchEvent(event: Event): void; } /** !#en - Physics manager uses box2d as the inner physics system, and hide most box2d implement details(creating rigidbody, synchronize rigidbody info to node). - You can visit some common box2d function through physics manager(hit testing, raycast, debug info). - Physics manager distributes the collision information to each collision callback when collision is produced. - Note: You need first enable the collision listener in the rigidbody. + Mesh Renderer Component !#zh - 物ç†ç³»ç»Ÿå°† box2d 作为内部物ç†ç³»ç»Ÿï¼Œå¹¶ä¸”éšè—了大部分 box2d å®žçŽ°ç»†èŠ‚ï¼ˆæ¯”å¦‚åˆ›å»ºåˆšä½“ï¼ŒåŒæ¥åˆšä½“ä¿¡æ¯åˆ°èŠ‚ç‚¹ä¸ç‰ï¼‰ã€‚ - ä½ å¯ä»¥é€šè¿‡ç‰©ç†ç³»ç»Ÿè®¿é—®ä¸€äº› box2d 常用的功能,比如点击测试,射线测试,设置测试信æ¯ç‰ã€‚ - 物ç†ç³»ç»Ÿè¿˜ç®¡ç†ç¢°æ’žä¿¡æ¯çš„分å‘,她会在产生碰撞时,将碰撞信æ¯åˆ†å‘到å„个碰撞回调ä¸ã€‚ - 注æ„ï¼šä½ éœ€è¦å…ˆåœ¨åˆšä½“ä¸å¼€å¯ç¢°æ’žæŽ¥å¬æ‰ä¼šäº§ç”Ÿç›¸åº”的碰撞回调。<br> - 支æŒçš„物ç†ç³»ç»ŸæŒ‡å®šç»˜åˆ¶ä¿¡æ¯äº‹ä»¶ï¼Œè¯·å‚阅 {{#crossLink "PhysicsManager.DrawBits"}}{{/crossLink}} */ - export class PhysicsManager implements EventTarget { + ç½‘æ ¼æ¸²æŸ“ç»„ä»¶ */ + export class MeshRenderer extends RenderComponent { /** !#en - The ratio transform between physics unit and pixel unit, generally is 32. + The mesh which the renderer uses. !#zh - 物ç†å•ä½ä¸Žåƒç´ å•ä½äº’相转æ¢çš„æ¯”率,一般是 32。 */ - static PTM_RATIO: number; + è®¾ç½®ä½¿ç”¨çš„ç½‘æ ¼ */ + mesh: Mesh; /** !#en - The velocity iterations for the velocity constraint solver. + Whether the mesh should receive shadows. !#zh - 速度更新è¿ä»£æ•° */ - static VELOCITY_ITERATIONS: number; + ç½‘æ ¼æ˜¯å¦æŽ¥å—å…‰æºæŠ•å°„çš„é˜´å½± */ + receiveShadows: boolean; /** !#en - The position Iterations for the position constraint solver. + Shadow Casting Mode !#zh - ä½ç½®è¿ä»£æ›´æ–°æ•° */ - static POSITION_ITERATIONS: number; + ç½‘æ ¼æŠ•å°„é˜´å½±çš„æ¨¡å¼ */ + shadowCastingMode: MeshRenderer.ShadowCastingMode; /** !#en - Specify the fixed time step. - Need enabledAccumulator to make it work. + Enable auto merge mesh, only support when mesh's VertexFormat, PrimitiveType, materials are all the same !#zh - æŒ‡å®šå›ºå®šçš„ç‰©ç†æ›´æ–°é—´é𔿗¶é—´ï¼Œéœ€è¦å¼€å¯ enabledAccumulator æ‰æœ‰æ•ˆã€‚ */ - static FIXED_TIME_STEP: number; + å¼€å¯è‡ªåЍåˆå¹¶ mesh åŠŸèƒ½ï¼Œåªæœ‰åœ¨ç½‘æ ¼çš„ é¡¶ç‚¹æ ¼å¼ï¼ŒPrimitiveType, 使用的æè´¨ 都一致的情况下æ‰ä¼šæœ‰æ•ˆ */ + enableAutoBatch: boolean; + } + /** The class BufferRange denotes a range of the buffer. */ + export class BufferRange { + /** The offset of the range. */ + offset: number; + /** The length of the range. */ + length: number; + } + /** undefined */ + export class VertexFormat { + /** The data range of this bundle. + This range of data is essentially mapped to a GPU vertex buffer. */ + data: BufferRange; + /** The attribute formats. */ + formats: VertexFormat; + /** The vertex bundle that the primitive use. */ + vertexBundleIndices: number[]; + /** The data range of the primitive. + This range of data is essentially mapped to a GPU indices buffer. */ + data: BufferRange; + /** The type of this primitive's indices. */ + indexUnit: number; + /** The primitive's topology. */ + topology: number; + } + /** undefined */ + export class Graphics extends RenderComponent { /** !#en - Specify the max accumulator time. - Need enabledAccumulator to make it work. + Current line width. !#zh - æ¯æ¬¡å¯ç”¨äºŽæ›´æ–°ç‰©ç†ç³»ç»Ÿçš„æœ€å¤§æ—¶é—´ï¼Œéœ€è¦å¼€å¯ enabledAccumulator æ‰æœ‰æ•ˆã€‚ */ - static MAX_ACCUMULATOR: number; + 当å‰çº¿æ¡å®½åº¦ */ + lineWidth: number; /** !#en - If enabled accumulator, then will call step function with the fixed time step FIXED_TIME_STEP. - And if the update dt is bigger than the time step, then will call step function several times. - If disabled accumulator, then will call step function with a time step calculated with the frame rate. + lineJoin determines how two connecting segments (of lines, arcs or curves) with non-zero lengths in a shape are joined together. !#zh - å¦‚æžœå¼€å¯æ¤é€‰é¡¹ï¼Œé‚£ä¹ˆå°†ä¼šä»¥å›ºå®šçš„间隔时间 FIXED_TIME_STEP æ¥æ›´æ–°ç‰©ç†å¼•擎,如果一个 update 的间隔时间大于 FIXED_TIME_STEP,则会对物ç†å¼•擎进行多次更新。 - å¦‚æžœå…³é—æ¤é€‰é¡¹ï¼Œé‚£ä¹ˆå°†ä¼šæ ¹æ®è®¾å®šçš„ frame rate è®¡ç®—å‡ºä¸€ä¸ªé—´éš”æ—¶é—´æ¥æ›´æ–°ç‰©ç†å¼•擎。 */ - enabledAccumulator: boolean; + lineJoin 用æ¥è®¾ç½®2个长度ä¸ä¸º0的相连部分(线段,圆弧,曲线)如何连接在一起的属性。 */ + lineJoin: Graphics.LineJoin; + /** !#en + lineCap determines how the end points of every line are drawn. + !#zh + lineCap 指定如何绘制æ¯ä¸€æ¡çº¿æ®µæœ«ç«¯ã€‚ */ + lineCap: Graphics.LineCap; + /** !#en + stroke color + !#zh + 线段颜色 */ + strokeColor: Color; + /** !#en + fill color + !#zh + 填充颜色 */ + fillColor: Color; + /** !#en + Sets the miter limit ratio + !#zh + 设置斜接é¢é™åˆ¶æ¯”例 */ + miterLimit: number; + /** + !#en Move path start point to (x,y). + !#zh ç§»åŠ¨è·¯å¾„èµ·ç‚¹åˆ°åæ ‡(x, y) + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + moveTo(x?: number, y?: number): void; + /** + !#en Adds a straight line to the path + !#zh 绘制直线路径 + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + lineTo(x?: number, y?: number): void; + /** + !#en Adds a cubic Bézier curve to the path + !#zh 绘制三次è´èµ›å°”曲线路径 + @param c1x The x axis of the coordinate for the first control point. + @param c1y The y axis of the coordinate for first control point. + @param c2x The x axis of the coordinate for the second control point. + @param c2y The y axis of the coordinate for the second control point. + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + bezierCurveTo(c1x?: number, c1y?: number, c2x?: number, c2y?: number, x?: number, y?: number): void; + /** + !#en Adds a quadratic Bézier curve to the path + !#zh 绘制二次è´èµ›å°”曲线路径 + @param cx The x axis of the coordinate for the control point. + @param cy The y axis of the coordinate for the control point. + @param x The x axis of the coordinate for the end point. + @param y The y axis of the coordinate for the end point. + */ + quadraticCurveTo(cx?: number, cy?: number, x?: number, y?: number): void; + /** + !#en Adds an arc to the path which is centered at (cx, cy) position with radius r starting at startAngle and ending at endAngle going in the given direction by counterclockwise (defaulting to false). + !#zh 绘制圆弧路径。圆弧路径的圆心在 (cx, cy) ä½ç½®ï¼ŒåŠå¾„为 r ï¼Œæ ¹æ® counterclockwise (默认为false)指定的方å‘从 startAngle 开始绘制,到 endAngle 结æŸã€‚ + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param r The arc's radius. + @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians. + @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians. + @param counterclockwise An optional Boolean which, if true, causes the arc to be drawn counter-clockwise between the two angles. By default it is drawn clockwise. + */ + arc(cx?: number, cy?: number, r?: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): void; + /** + !#en Adds an ellipse to the path. + !#zh 绘制æ¤åœ†è·¯å¾„。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param rx The ellipse's x-axis radius. + @param ry The ellipse's y-axis radius. + */ + ellipse(cx?: number, cy?: number, rx?: number, ry?: number): void; + /** + !#en Adds an circle to the path. + !#zh 绘制圆形路径。 + @param cx The x axis of the coordinate for the center point. + @param cy The y axis of the coordinate for the center point. + @param r The circle's radius. + */ + circle(cx?: number, cy?: number, r?: number): void; + /** + !#en Adds an rectangle to the path. + !#zh 绘制矩形路径。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangle's width. + @param h The rectangle's height. + */ + rect(x?: number, y?: number, w?: number, h?: number): void; + /** + !#en Adds an round corner rectangle to the path. + !#zh 绘制圆角矩形路径。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangles width. + @param h The rectangle's height. + @param r The radius of the rectangle. + */ + roundRect(x?: number, y?: number, w?: number, h?: number, r?: number): void; /** - !#en - Test which collider contains the given world point - !#zh - 获å–包å«ç»™å®šä¸–ç•Œåæ ‡ç³»ç‚¹çš„碰撞体 - @param point the world point + !#en Draws a filled rectangle. + !#zh 绘制填充矩形。 + @param x The x axis of the coordinate for the rectangle starting point. + @param y The y axis of the coordinate for the rectangle starting point. + @param w The rectangle's width. + @param h The rectangle's height. */ - testPoint(point: Vec2): PhysicsCollider; + fillRect(x?: number, y?: number, w?: number, h?: number): void; /** - !#en - Test which colliders intersect the given world rect - !#zh - 获å–ä¸Žç»™å®šä¸–ç•Œåæ ‡ç³»çŸ©å½¢ç›¸äº¤çš„碰撞体 - @param rect the world rect + !#en Erasing any previously drawn content. + !#zh 擦除之å‰ç»˜åˆ¶çš„æ‰€æœ‰å†…容的方法。 + @param clean Whether to clean the graphics inner cache. */ - testAABB(rect: Rect): PhysicsCollider[]; + clear(clean?: boolean): void; /** - !#en - Raycast the world for all colliders in the path of the ray. - The raycast ignores colliders that contain the starting point. - !#zh - 检测哪些碰撞体在给定射线的路径上,射线检测将忽略包å«èµ·å§‹ç‚¹çš„碰撞体。 - @param p1 start point of the raycast - @param p2 end point of the raycast - @param type optional, default is RayCastType.Closest + !#en Causes the point of the pen to move back to the start of the current path. It tries to add a straight line from the current point to the start. + !#zh 将笔点返回到当å‰è·¯å¾„起始点的。它å°è¯•从当å‰ç‚¹åˆ°èµ·å§‹ç‚¹ç»˜åˆ¶ä¸€æ¡ç›´çº¿ã€‚ */ - rayCast(p1: Vec2, p2: Vec2, type: RayCastType): PhysicsRayCastResult[]; - /** !#en - Enabled the physics manager? - !#zh - 指定是å¦å¯ç”¨ç‰©ç†ç³»ç»Ÿï¼Ÿ */ - enabled: boolean; - /** !#en - Debug draw flags. - !#zh - è®¾ç½®è°ƒè¯•ç»˜åˆ¶æ ‡å¿— */ - debugDrawFlags: number; - /** !#en - The physics world gravity. - !#zh - 物ç†ä¸–界é‡åЛ值 */ - gravity: Vec2; + close(): void; /** - !#en Checks whether the EventTarget object has any callback registered for a specific type of event. - !#zh æ£€æŸ¥äº‹ä»¶ç›®æ ‡å¯¹è±¡æ˜¯å¦æœ‰ä¸ºç‰¹å®šç±»åž‹çš„事件注册的回调。 - @param type The type of event. + !#en Strokes the current or given path with the current stroke style. + !#zh æ ¹æ®å½“å‰çš„ç”»çº¿æ ·å¼ï¼Œç»˜åˆ¶å½“剿ˆ–å·²ç»å˜åœ¨çš„路径。 */ - hasEventListener(type: string): boolean; + stroke(): void; /** - !#en - Register an callback of a specific event type on the EventTarget. - This type of event should be triggered via `emit`. - !#zh - æ³¨å†Œäº‹ä»¶ç›®æ ‡çš„ç‰¹å®šäº‹ä»¶ç±»åž‹å›žè°ƒã€‚è¿™ç§ç±»åž‹çš„事件应该被 `emit` 触å‘。 - @param type A string representing the event type to listen for. - @param callback The callback that will be invoked when the event is dispatched. - The callback is ignored if it is a duplicate (the callbacks are unique). - @param target The target (this object) to invoke the callback, can be null + !#en Fills the current or given path with the current fill style. + !#zh æ ¹æ®å½“å‰çš„ç”»çº¿æ ·å¼ï¼Œå¡«å……当剿ˆ–å·²ç»å˜åœ¨çš„路径。 + */ + fill(): void; + } + /** !#en The module provides utilities for working with file and directory paths + !#zh ç”¨äºŽå¤„ç†æ–‡ä»¶ä¸Žç›®å½•çš„è·¯å¾„çš„æ¨¡å— */ + export class path { + /** + !#en Join strings to be a path. + !#zh 拼接å—符串为 Path @example ```js - eventTarget.on('fire', function () { - cc.log("fire in the hole"); - }, node); + ------------------------------ + cc.path.join("a", "b.png"); //-->"a/b.png" + cc.path.join("a", "b", "c.png"); //-->"a/b/c.png" + cc.path.join("a", "b"); //-->"a/b" + cc.path.join("a", "b", "/"); //-->"a/b/" + cc.path.join("a", "b/", "/"); //-->"a/b/" + ``` */ - on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T; + static join(): string; /** - !#en - Removes the listeners previously registered with the same type, callback, target and or useCapture, - if only type is passed as parameter, all listeners registered with that type will be removed. - !#zh - åˆ é™¤ä¹‹å‰ç”¨åŒç±»åž‹ï¼Œå›žè°ƒï¼Œç›®æ ‡æˆ– useCapture 注册的事件监å¬å™¨ï¼Œå¦‚æžœåªä¼ 递 typeï¼Œå°†ä¼šåˆ é™¤ type 类型的所有事件监å¬å™¨ã€‚ - @param type A string representing the event type being removed. - @param callback The callback to remove. - @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + !#en Get the ext name of a path including '.', like '.png'. + !#zh 返回 Path 的扩展å,包括 '.',例如 '.png'。 + @param pathStr pathStr @example ```js - // 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'); + --------------------------- + cc.path.extname("a/b.png"); //-->".png" + cc.path.extname("a/b.png?a=1&b=2"); //-->".png" + cc.path.extname("a/b"); //-->null + cc.path.extname("a/b?a=1&b=2"); //-->null + ``` */ - off(type: string, callback?: Function, target?: any): void; + static extname(pathStr: string): any; /** - !#en Removes all callbacks previously registered with the same target (passed as parameter). - This is not for removing all listeners in the current event target, - and this is not for removing all listeners the target parameter have registered. - It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. - !#zh åœ¨å½“å‰ EventTarget ä¸Šåˆ é™¤æŒ‡å®šç›®æ ‡ï¼ˆtarget 傿•°ï¼‰æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ - è¿™ä¸ªå‡½æ•°æ— æ³•åˆ é™¤å½“å‰ EventTarget 的所有事件监å¬å™¨ï¼Œä¹Ÿæ— æ³•åˆ é™¤ target 傿•°æ‰€æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ - 这个函数åªèƒ½åˆ 除 target 傿•°åœ¨å½“å‰ EventTarget 上注册的所有事件监å¬å™¨ã€‚ - @param target The target to be searched for all related listeners + !#en Get the main name of a file name + !#zh èŽ·å–æ–‡ä»¶å的主åç§° + @param fileName fileName */ - targetOff(target: any): void; + static mainFileName(fileName: string): string; /** - !#en - Register an callback of a specific event type on the EventTarget, - the callback will remove itself after the first time it is triggered. - !#zh - æ³¨å†Œäº‹ä»¶ç›®æ ‡çš„ç‰¹å®šäº‹ä»¶ç±»åž‹å›žè°ƒï¼Œå›žè°ƒä¼šåœ¨ç¬¬ä¸€æ—¶é—´è¢«è§¦å‘åŽåˆ 除自身。 - @param type A string representing the event type to listen for. - @param callback The callback that will be invoked when the event is dispatched. - The callback is ignored if it is a duplicate (the callbacks are unique). - @param target The target (this object) to invoke the callback, can be null + !#en Get the file name of a file path. + !#zh èŽ·å–æ–‡ä»¶è·¯å¾„的文件å。 + @param pathStr pathStr + @param extname extname @example ```js - eventTarget.once('fire', function () { - cc.log("this is the callback and will be invoked only once"); - }, node); + --------------------------------- + cc.path.basename("a/b.png"); //-->"b.png" + cc.path.basename("a/b.png?a=1&b=2"); //-->"b.png" + cc.path.basename("a/b.png", ".png"); //-->"b" + cc.path.basename("a/b.png?a=1&b=2", ".png"); //-->"b" + cc.path.basename("a/b.png", ".txt"); //-->"b.png" + ``` */ - once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + static basename(pathStr: string, extname?: string): any; /** - !#en - Send an event with the event object. - !#zh - 通过事件对象派å‘事件 - @param event event + !#en Get dirname of a file path. + !#zh èŽ·å–æ–‡ä»¶è·¯å¾„的目录å。 + @param pathStr pathStr + + @example + ```js + --------------------------------- + * unix + cc.path.driname("a/b/c.png"); //-->"a/b" + cc.path.driname("a/b/c.png?a=1&b=2"); //-->"a/b" + cc.path.dirname("a/b/"); //-->"a/b" + cc.path.dirname("c.png"); //-->"" + * windows + cc.path.driname("a\\b\\c.png"); //-->"a\b" + cc.path.driname("a\\b\\c.png?a=1&b=2"); //-->"a\b" + + ``` */ - dispatchEvent(event: Event): void; - } - /** undefined */ - export class PhysicsRayCastResult { - /** !#en - The PhysicsCollider which intersects with the raycast - !#zh - 与射线相交的碰撞体 */ - collider: PhysicsCollider; - /** !#en - The intersection point - !#zh - 射线与碰撞体相交的点 */ - point: Vec2; - /** !#en - The normal vector at the point of intersection - !#zh - 射线与碰撞体相交的点的法å‘é‡ */ - normal: Vec2; - /** !#en - The fraction of the raycast path at the point of intersection - !#zh - 射线与碰撞体相交的点å 射线长度的分数 */ - fraction: number; - } - /** !#en Enum for RigidBodyType. - !#zh 刚体类型 */ - export enum RigidBodyType { - Static = 0, - Kinematic = 0, - Dynamic = 0, - Animated = 0, - } - /** !#en Enum for RayCastType. - !#zh 射线检测类型 */ - export enum RayCastType { - Closest = 0, - Any = 0, - AllClosest = 0, - All = 0, + static dirname(pathStr: string): any; + /** + !#en Change extname of a file path. + !#zh 更改文件路径的扩展å。 + @param pathStr pathStr + @param extname extname + + @example + ```js + --------------------------------- + cc.path.changeExtname("a/b.png", ".plist"); //-->"a/b.plist" + cc.path.changeExtname("a/b.png?a=1&b=2", ".plist"); //-->"a/b.plist?a=1&b=2" + + ``` + */ + static changeExtname(pathStr: string, extname?: string): string; } - /** undefined */ - export class RigidBody extends Component { - /** !#en - Should enabled contact listener? - When a collision is trigger, the collision callback will only be called when enabled contact listener. - !#zh - 是å¦å¯ç”¨æŽ¥è§¦æŽ¥å¬å™¨ã€‚ - 当 collider äº§ç”Ÿç¢°æ’žæ—¶ï¼Œåªæœ‰å¼€å¯äº†æŽ¥è§¦æŽ¥å¬å™¨æ‰ä¼šè°ƒç”¨ç›¸åº”的回调函数 */ - enabledContactListener: boolean; + /** !#en + AffineTransform class represent an affine transform matrix. It's composed basically by translation, rotation, scale transformations.<br/> + !#zh + AffineTransform ç±»ä»£è¡¨ä¸€ä¸ªä»¿å°„å˜æ¢çŸ©é˜µã€‚å®ƒåŸºæœ¬ä¸Šæ˜¯ç”±å¹³ç§»æ—‹è½¬ï¼Œç¼©æ”¾è½¬å˜æ‰€ç»„æˆã€‚<br/> */ + export class AffineTransform { + /** + !#en Create a AffineTransform object with all contents in the matrix. + !#zh 用在矩阵ä¸çš„æ‰€æœ‰å†…容创建一个 AffineTransform 对象。 + @param a a + @param b b + @param c c + @param d d + @param tx tx + @param ty ty + */ + static create(a: number, b: number, c: number, d: number, tx: number, ty: number): AffineTransform; /** !#en - Collision callback. - Called when two collider begin to touch. + Create a identity transformation matrix: <br/> + [ 1, 0, 0, <br/> + 0, 1, 0 ] !#zh - 碰撞回调。 - å¦‚æžœä½ çš„è„šæœ¬ä¸å®žçŽ°äº†è¿™ä¸ªå‡½æ•°ï¼Œé‚£ä¹ˆå®ƒå°†ä¼šåœ¨ä¸¤ä¸ªç¢°æ’žä½“å¼€å§‹æŽ¥è§¦æ—¶è¢«è°ƒç”¨ã€‚ - @param contact contact information - @param selfCollider the collider belong to this rigidbody - @param otherCollider the collider belong to another rigidbody + å•ä½çŸ©é˜µï¼š<br/> + [ 1, 0, 0, <br/> + 0, 1, 0 ] */ - onBeginContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + static identity(): AffineTransform; /** - !#en - Collision callback. - Called when two collider cease to touch. - !#zh - 碰撞回调。 - å¦‚æžœä½ çš„è„šæœ¬ä¸å®žçŽ°äº†è¿™ä¸ªå‡½æ•°ï¼Œé‚£ä¹ˆå®ƒå°†ä¼šåœ¨ä¸¤ä¸ªç¢°æ’žä½“åœæ¢æŽ¥è§¦æ—¶è¢«è°ƒç”¨ã€‚ - @param contact contact information - @param selfCollider the collider belong to this rigidbody - @param otherCollider the collider belong to another rigidbody + !#en Clone a AffineTransform object from the specified transform. + !#zh 克隆指定的 AffineTransform 对象。 + @param t t */ - onEndContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + static clone(t: AffineTransform): AffineTransform; /** !#en - Collision callback. - This is called when a contact is updated. - This allows you to inspect a contact before it goes to the solver(e.g. disable contact). - Note: this is called only for awake bodies. - Note: this is called even when the number of contact points is zero. - Note: this is not called for sensors. + Concatenate a transform matrix to another + The results are reflected in the out affine transform + out = t1 * t2 + This function is memory free, you should create the output affine transform by yourself and manage its memory. !#zh - 碰撞回调。 - å¦‚æžœä½ çš„è„šæœ¬ä¸å®žçŽ°äº†è¿™ä¸ªå‡½æ•°ï¼Œé‚£ä¹ˆå®ƒå°†ä¼šåœ¨æŽ¥è§¦æ›´æ–°æ—¶è¢«è°ƒç”¨ã€‚ - ä½ å¯ä»¥åœ¨æŽ¥è§¦è¢«å¤„ç†å‰æ ¹æ®ä»–包å«çš„ä¿¡æ¯ä½œå‡ºç›¸åº”的处ç†ï¼Œæ¯”如将这个接触ç¦ç”¨æŽ‰ã€‚ - 注æ„:回调åªä¼šä¸ºé†’ç€çš„刚体调用。 - 注æ„:接触点为零的时候也有å¯èƒ½è¢«è°ƒç”¨ã€‚ - 注æ„:感知体(sensor)的回调ä¸ä¼šè¢«è°ƒç”¨ã€‚ - @param contact contact information - @param selfCollider the collider belong to this rigidbody - @param otherCollider the collider belong to another rigidbody + 拼接两个矩阵,将结果ä¿å˜åˆ° out 矩阵。这个函数ä¸åˆ›å»ºä»»ä½•内å˜ï¼Œä½ 需è¦å…ˆåˆ›å»º AffineTransform 对象用æ¥å˜å‚¨ç»“æžœï¼Œå¹¶ä½œä¸ºç¬¬ä¸€ä¸ªå‚æ•°ä¼ 入函数。 + out = t1 * t2 + @param out Out object to store the concat result + @param t1 The first transform object. + @param t2 The transform object to concatenate. */ - onPreSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + static concat(out: AffineTransform, t1: AffineTransform, t2: AffineTransform): AffineTransform; /** - !#en - Collision callback. - This is called after a contact is updated. - You can get the impulses from the contact in this callback. - !#zh - 碰撞回调。 - å¦‚æžœä½ çš„è„šæœ¬ä¸å®žçŽ°äº†è¿™ä¸ªå‡½æ•°ï¼Œé‚£ä¹ˆå®ƒå°†ä¼šåœ¨æŽ¥è§¦æ›´æ–°å®ŒåŽè¢«è°ƒç”¨ã€‚ - ä½ å¯ä»¥åœ¨è¿™ä¸ªå›žè°ƒä¸ä»ŽæŽ¥è§¦ä¿¡æ¯ä¸èŽ·å–到冲é‡ä¿¡æ¯ã€‚ - @param contact contact information - @param selfCollider the collider belong to this rigidbody - @param otherCollider the collider belong to another rigidbody + !#en Get the invert transform of an AffineTransform object. + This function is memory free, you should create the output affine transform by yourself and manage its memory. + !#zh 求逆矩阵。这个函数ä¸åˆ›å»ºä»»ä½•内å˜ï¼Œä½ 需è¦å…ˆåˆ›å»º AffineTransform 对象用æ¥å˜å‚¨ç»“æžœï¼Œå¹¶ä½œä¸ºç¬¬ä¸€ä¸ªå‚æ•°ä¼ 入函数。 + @param out out + @param t t */ - onPostSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; - /** !#en - Is this a fast moving body that should be prevented from tunneling through - other moving bodies? - Note : - - All bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies. - - You should use this flag sparingly since it increases processing time. - !#zh - è¿™ä¸ªåˆšä½“æ˜¯å¦æ˜¯ä¸€ä¸ªå¿«é€Ÿç§»åŠ¨çš„åˆšä½“ï¼Œå¹¶ä¸”éœ€è¦ç¦æ¢ç©¿è¿‡å…¶ä»–快速移动的刚体? - éœ€è¦æ³¨æ„的是 : - - æ‰€æœ‰åˆšä½“éƒ½è¢«ç¦æ¢ä»Ž è¿åŠ¨åˆšä½“ å’Œ 陿€åˆšä½“ ä¸ç©¿è¿‡ã€‚æ¤é€‰é¡¹åªå…³æ³¨äºŽ 动æ€åˆšä½“。 - - 应该尽é‡å°‘的使用æ¤é€‰é¡¹ï¼Œå› ä¸ºå®ƒä¼šå¢žåŠ ç¨‹åºå¤„ç†æ—¶é—´ã€‚ */ - bullet: boolean; - /** !#en - Rigidbody type : Static, Kinematic, Dynamic or Animated. - !#zh - 刚体类型: Static, Kinematic, Dynamic or Animated. */ - type: RigidBodyType; - /** !#en - Set this flag to false if this body should never fall asleep. - Note that this increases CPU usage. - !#zh - 如果æ¤åˆšä½“永远都ä¸åº”该进入ç¡çœ ,那么设置这个属性为 false。 - éœ€è¦æ³¨æ„这将使 CPU å 用率æé«˜ã€‚ */ - allowSleep: boolean; - /** !#en - Scale the gravity applied to this body. - !#zh - 缩放应用在æ¤åˆšä½“上的é‡åЛ值 */ - gravityScale: number; - /** !#en - Linear damping is use to reduce the linear velocity. - The damping parameter can be larger than 1, but the damping effect becomes sensitive to the - time step when the damping parameter is large. - !#zh - Linear damping 用于衰å‡åˆšä½“的线性速度。衰å‡ç³»æ•°å¯ä»¥å¤§äºŽ 1,但是当衰å‡ç³»æ•°æ¯”较大的时候,衰å‡çš„æ•ˆæžœä¼šå˜å¾—æ¯”è¾ƒæ•æ„Ÿã€‚ */ - linearDamping: number; - /** !#en - Angular damping is use to reduce the angular velocity. The damping parameter - can be larger than 1 but the damping effect becomes sensitive to the - time step when the damping parameter is large. - !#zh - Angular damping 用于衰å‡åˆšä½“的角速度。衰å‡ç³»æ•°å¯ä»¥å¤§äºŽ 1,但是当衰å‡ç³»æ•°æ¯”较大的时候,衰å‡çš„æ•ˆæžœä¼šå˜å¾—æ¯”è¾ƒæ•æ„Ÿã€‚ */ - angularDamping: number; - /** !#en - The linear velocity of the body's origin in world co-ordinates. - !#zh - åˆšä½“åœ¨ä¸–ç•Œåæ ‡ä¸‹çš„线性速度 */ - linearVelocity: Vec2; - /** !#en - The angular velocity of the body. - !#zh - 刚体的角速度 */ - angularVelocity: number; - /** !#en - Should this body be prevented from rotating? - !#zh - 是å¦ç¦æ¢æ¤åˆšä½“进行旋转 */ - fixedRotation: boolean; - /** !#en - Set the sleep state of the body. A sleeping body has very low CPU cost.(When the rigid body is hit, if the rigid body is in sleep state, it will be immediately awakened.) - !#zh - 设置刚体的ç¡çœ 状æ€ã€‚ ç¡çœ 的刚体具有éžå¸¸ä½Žçš„ CPU æˆæœ¬ã€‚(当刚体被碰撞到时,如果刚体处于ç¡çœ 状æ€ï¼Œå®ƒä¼šç«‹å³è¢«å”¤é†’) */ - awake: boolean; - /** !#en - Whether to wake up this rigid body during initialization - !#zh - 是å¦åœ¨åˆå§‹åŒ–时唤醒æ¤åˆšä½“ */ - awakeOnLoad: boolean; + static invert(out: AffineTransform, t: AffineTransform): AffineTransform; + /** + !#en Get an AffineTransform object from a given matrix 4x4. + This function is memory free, you should create the output affine transform by yourself and manage its memory. + !#zh 从一个 4x4 Matrix èŽ·å– AffineTransform 对象。这个函数ä¸åˆ›å»ºä»»ä½•内å˜ï¼Œä½ 需è¦å…ˆåˆ›å»º AffineTransform 对象用æ¥å˜å‚¨ç»“æžœï¼Œå¹¶ä½œä¸ºç¬¬ä¸€ä¸ªå‚æ•°ä¼ 入函数。 + @param out out + @param mat mat + */ + static invert(out: AffineTransform, mat: Mat4): AffineTransform; + /** + !#en Apply the affine transformation on a point. + This function is memory free, you should create the output Vec2 by yourself and manage its memory. + !#zh å¯¹ä¸€ä¸ªç‚¹åº”ç”¨çŸ©é˜µå˜æ¢ã€‚这个函数ä¸åˆ›å»ºä»»ä½•内å˜ï¼Œä½ 需è¦å…ˆåˆ›å»ºä¸€ä¸ª Vec2 对象用æ¥å˜å‚¨ç»“æžœï¼Œå¹¶ä½œä¸ºç¬¬ä¸€ä¸ªå‚æ•°ä¼ 入函数。 + @param out The output point to store the result + @param point Point to apply transform or x. + @param transOrY transform matrix or y. + @param t transform matrix. + */ + static transformVec2(out: Vec2, point: Vec2|number, transOrY: AffineTransform|number, t?: AffineTransform): Vec2; + /** + !#en Apply the affine transformation on a size. + This function is memory free, you should create the output Size by yourself and manage its memory. + !#zh åº”ç”¨ä»¿å°„å˜æ¢çŸ©é˜µåˆ° Size 上。这个函数ä¸åˆ›å»ºä»»ä½•内å˜ï¼Œä½ 需è¦å…ˆåˆ›å»ºä¸€ä¸ª Size 对象用æ¥å˜å‚¨ç»“æžœï¼Œå¹¶ä½œä¸ºç¬¬ä¸€ä¸ªå‚æ•°ä¼ 入函数。 + @param out The output point to store the result + @param size size + @param t t + */ + static transformSize(out: Size, size: Size, t: AffineTransform): Size; + /** + !#en Apply the affine transformation on a rect. + This function is memory free, you should create the output Rect by yourself and manage its memory. + !#zh åº”ç”¨ä»¿å°„å˜æ¢çŸ©é˜µåˆ° Rect 上。这个函数ä¸åˆ›å»ºä»»ä½•内å˜ï¼Œä½ 需è¦å…ˆåˆ›å»ºä¸€ä¸ª Rect 对象用æ¥å˜å‚¨ç»“æžœï¼Œå¹¶ä½œä¸ºç¬¬ä¸€ä¸ªå‚æ•°ä¼ 入函数。 + @param out out + @param rect rect + @param anAffineTransform anAffineTransform + */ + static transformRect(out: Rect, rect: Rect, anAffineTransform: AffineTransform): Rect; + /** + !#en Apply the affine transformation on a rect, and truns to an Oriented Bounding Box. + This function is memory free, you should create the output vectors by yourself and manage their memory. + !#zh åº”ç”¨ä»¿å°„å˜æ¢çŸ©é˜µåˆ° Rect 上, 并转æ¢ä¸ºæœ‰å‘包围盒。这个函数ä¸åˆ›å»ºä»»ä½•内å˜ï¼Œä½ 需è¦å…ˆåˆ›å»ºåŒ…围盒的四个 Vector 对象用æ¥å˜å‚¨ç»“果,并作为å‰å››ä¸ªå‚æ•°ä¼ å…¥å‡½æ•°ã€‚ + @param out_bl out_bl + @param out_tl out_tl + @param out_tr out_tr + @param out_br out_br + @param rect rect + @param anAffineTransform anAffineTransform + */ + static transformObb(out_bl: Vec2, out_tl: Vec2, out_tr: Vec2, out_br: Vec2, rect: Rect, anAffineTransform: AffineTransform): void; + } + /** A base node for CCNode, it will: + - maintain scene hierarchy and active logic + - notifications if some properties changed + - define some interfaces shares between CCNode + - define machanisms for Enity Component Systems + - define prefab and serialize functions */ + export class _BaseNode extends Object implements EventTarget { + /** !#en Name of node. + !#zh 该节点å称。 */ + name: string; + /** !#en The uuid for editor, will be stripped before building project. + !#zh 主è¦ç”¨äºŽç¼–辑器的 uuid,在编辑器下å¯ç”¨äºŽæŒä¹…化å˜å‚¨ï¼Œåœ¨é¡¹ç›®æž„建之åŽå°†å˜æˆè‡ªå¢žçš„ id。 */ + uuid: string; + /** !#en All children nodes. + !#zh 节点的所有å节点。 */ + children: Node[]; + /** !#en All children nodes. + !#zh 节点的å节点数é‡ã€‚ */ + childrenCount: number; /** !#en - Set the active state of the body. An inactive body is not - simulated and cannot be collided with or woken up. - If body is active, all fixtures will be added to the - broad-phase. - If body is inactive, all fixtures will be removed from - the broad-phase and all contacts will be destroyed. - Fixtures on an inactive body are implicitly inactive and will - not participate in collisions, ray-casts, or queries. - Joints connected to an inactive body are implicitly inactive. + The local active state of this node.<br/> + Note that a Node may be inactive because a parent is not active, even if this returns true.<br/> + Use {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}} if you want to check if the Node is actually treated as active in the scene. !#zh - 设置刚体的激活状æ€ã€‚ä¸€ä¸ªéžæ¿€æ´»çжæ€ä¸‹çš„刚体是ä¸ä¼šè¢«æ¨¡æ‹Ÿå’Œç¢°æ’žçš„,ä¸ç®¡å®ƒæ˜¯å¦å¤„于ç¡çœ 状æ€ä¸‹ã€‚ - 如果刚体处于激活状æ€ä¸‹ï¼Œæ‰€æœ‰å¤¹å…·ä¼šè¢«æ·»åŠ åˆ° 粗测阶段(broad-phase)。 - å¦‚æžœåˆšä½“å¤„äºŽéžæ¿€æ´»çжæ€ä¸‹ï¼Œæ‰€æœ‰å¤¹å…·ä¼šè¢«ä»Ž 粗测阶段(broad-phase)ä¸ç§»é™¤ã€‚ - åœ¨éžæ¿€æ´»çжæ€ä¸‹çš„夹具ä¸ä¼šå‚ä¸Žåˆ°ç¢°æ’žï¼Œå°„çº¿ï¼Œæˆ–è€…æŸ¥æ‰¾ä¸ - é“¾æŽ¥åˆ°éžæ¿€æ´»çжæ€ä¸‹åˆšä½“çš„å…³èŠ‚ä¹Ÿæ˜¯éžæ¿€æ´»çš„。 */ + 当å‰èŠ‚ç‚¹çš„è‡ªèº«æ¿€æ´»çŠ¶æ€ã€‚<br/> + 值得注æ„的是,一个节点的父节点如果ä¸è¢«æ¿€æ´»ï¼Œé‚£ä¹ˆå³ä½¿å®ƒè‡ªèº«è®¾ä¸ºæ¿€æ´»ï¼Œå®ƒä»ç„¶æ— 法激活。<br/> + å¦‚æžœä½ æƒ³æ£€æŸ¥èŠ‚ç‚¹åœ¨åœºæ™¯ä¸å®žé™…的激活状æ€å¯ä»¥ä½¿ç”¨ {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}}。 */ active: boolean; + /** !#en Indicates whether this node is active in the scene. + !#zh 表示æ¤èŠ‚ç‚¹æ˜¯å¦åœ¨åœºæ™¯ä¸æ¿€æ´»ã€‚ */ + activeInHierarchy: boolean; + /** + + @param name name + */ + constructor(name?: string); + /** !#en The parent of the node. + !#zh 该节点的父节点。 */ + parent: Node; + /** + !#en Get parent of the node. + !#zh 获å–该节点的父节点。 + + @example + ```js + var parent = this.node.getParent(); + ``` + */ + getParent(): Node; + /** + !#en Set parent of the node. + !#zh 设置该节点的父节点。 + @param value value + + @example + ```js + node.setParent(newNode); + ``` + */ + setParent(value: Node): void; /** !#en - Gets a local point relative to the body's origin given a world point. - !#zh - å°†ä¸€ä¸ªç»™å®šçš„ä¸–ç•Œåæ ‡ç³»ä¸‹çš„点转æ¢ä¸ºåˆšä½“æœ¬åœ°åæ ‡ç³»ä¸‹çš„点 - @param worldPoint a point in world coordinates. - @param out optional, the receiving point + Properties configuration function <br/> + All properties in attrs will be set to the node, <br/> + when the setter of the node is available, <br/> + the property will be set via setter function.<br/> + !#zh 属性é…置函数。在 attrs 的所有属性将被设置为节点属性。 + @param attrs Properties to be set to node + + @example + ```js + var attrs = { key: 0, num: 100 }; + node.attr(attrs); + ``` */ - getLocalPoint(worldPoint: Vec2, out: Vec2): Vec2; + attr(attrs: any): void; /** - !#en - Get the world coordinates of a point given the local coordinates. - !#zh - å°†ä¸€ä¸ªç»™å®šçš„åˆšä½“æœ¬åœ°åæ ‡ç³»ä¸‹çš„点转æ¢ä¸ºä¸–ç•Œåæ ‡ç³»ä¸‹çš„点 - @param localPoint a point in local coordinates. - @param out optional, the receiving point + !#en Returns a child from the container given its uuid. + !#zh 通过 uuid 获å–节点的å节点。 + @param uuid The uuid to find the child node. + + @example + ```js + var child = node.getChildByUuid(uuid); + ``` */ - getWorldPoint(localPoint: Vec2, out: Vec2): Vec2; + getChildByUuid(uuid: string): Node; /** - !#en - Get the world coordinates of a vector given the local coordinates. - !#zh - å°†ä¸€ä¸ªç»™å®šçš„ä¸–ç•Œåæ ‡ç³»ä¸‹çš„å‘é‡è½¬æ¢ä¸ºåˆšä½“æœ¬åœ°åæ ‡ç³»ä¸‹çš„å‘é‡ - @param localVector a vector in world coordinates. - @param out optional, the receiving vector + !#en Returns a child from the container given its name. + !#zh 通过å称获å–节点的å节点。 + @param name A name to find the child node. + + @example + ```js + var child = node.getChildByName("Test Node"); + ``` */ - getWorldVector(localVector: Vec2, out: Vec2): Vec2; + getChildByName(name: string): Node; /** !#en - Gets a local vector relative to the body's origin given a world vector. + Inserts a child to the node at a specified index. !#zh - å°†ä¸€ä¸ªç»™å®šçš„ä¸–ç•Œåæ ‡ç³»ä¸‹çš„点转æ¢ä¸ºåˆšä½“æœ¬åœ°åæ ‡ç³»ä¸‹çš„点 - @param worldVector a vector in world coordinates. - @param out optional, the receiving vector + æ’å…¥å节点到指定ä½ç½® + @param child the child node to be inserted + @param siblingIndex the sibling index to place the child in + + @example + ```js + node.insertChild(child, 2); + ``` */ - getLocalVector(worldVector: Vec2, out: Vec2): Vec2; + insertChild(child: Node, siblingIndex: number): void; /** - !#en - Get the world body origin position. - !#zh - 获å–åˆšä½“ä¸–ç•Œåæ ‡ç³»ä¸‹çš„原点值 - @param out optional, the receiving point + !#en Get the sibling index. + !#zh 获å–åŒçº§ç´¢å¼•。 + + @example + ```js + var index = node.getSiblingIndex(); + ``` */ - getWorldPosition(out: Vec2): Vec2; + getSiblingIndex(): number; /** - !#en - Get the world body rotation angle. - !#zh - 获å–åˆšä½“ä¸–ç•Œåæ ‡ç³»ä¸‹çš„æ—‹è½¬å€¼ã€‚ + !#en Set the sibling index of this node. + !#zh 设置节点åŒçº§ç´¢å¼•。 + @param index index + + @example + ```js + node.setSiblingIndex(1); + ``` */ - getWorldRotation(): number; + setSiblingIndex(index: number): void; /** - !#en - Get the local position of the center of mass. - !#zh - 获å–åˆšä½“æœ¬åœ°åæ ‡ç³»ä¸‹çš„质心 + !#en Walk though the sub children tree of the current node. + Each node, including the current node, in the sub tree will be visited two times, before all children and after all children. + This function call is not recursive, it's based on stack. + Please don't walk any other node inside the walk process. + !#zh éåŽ†è¯¥èŠ‚ç‚¹çš„åæ ‘里的所有节点并按规则执行回调函数。 + å¯¹åæ ‘ä¸çš„æ‰€æœ‰èŠ‚ç‚¹ï¼ŒåŒ…å«å½“å‰èŠ‚ç‚¹ï¼Œä¼šæ‰§è¡Œä¸¤æ¬¡å›žè°ƒï¼Œprefunc 会在访问它的å节点之å‰è°ƒç”¨ï¼Œpostfunc 会在访问所有å节点之åŽè°ƒç”¨ã€‚ + è¿™ä¸ªå‡½æ•°çš„å®žçŽ°ä¸æ˜¯åŸºäºŽé€’å½’çš„ï¼Œè€Œæ˜¯åŸºäºŽæ ˆå±•å¼€é€’å½’çš„æ–¹å¼ã€‚ + 请ä¸è¦åœ¨ walk 过程ä¸å¯¹ä»»ä½•其他的节点嵌套执行 walk。 + @param prefunc The callback to process node when reach the node for the first time + @param postfunc The callback to process node when re-visit the node after walked all children in its sub tree + + @example + ```js + node.walk(function (target) { + console.log('Walked through node ' + target.name + ' for the first time'); + }, function (target) { + console.log('Walked through node ' + target.name + ' after walked all children in its sub tree'); + }); + ``` */ - getLocalCenter(): Vec2; + walk(prefunc: (target: _BaseNode) => void, postfunc: (target: _BaseNode) => void): void; /** !#en - Get the world position of the center of mass. + Remove itself from its parent node. If cleanup is `true`, then also remove all events and actions. <br/> + If the cleanup parameter is not passed, it will force a cleanup, so it is recommended that you always pass in the `false` parameter when calling this API.<br/> + If the node orphan, then nothing happens. !#zh - 获å–åˆšä½“ä¸–ç•Œåæ ‡ç³»ä¸‹çš„质心 + 从父节点ä¸åˆ 除该节点。如果ä¸ä¼ å…¥ cleanup 傿•°æˆ–è€…ä¼ å…¥ `true`,那么这个节点上所有绑定的事件ã€action éƒ½ä¼šè¢«åˆ é™¤ã€‚<br/> + å› æ¤å»ºè®®è°ƒç”¨è¿™ä¸ª API æ—¶æ€»æ˜¯ä¼ å…¥ `false` 傿•°ã€‚<br/> + 如果这个节点是一个å¤èŠ‚ç‚¹ï¼Œé‚£ä¹ˆä»€ä¹ˆéƒ½ä¸ä¼šå‘生。 + @param cleanup true if all actions and callbacks on this node should be removed, false otherwise. + + @example + ```js + node.removeFromParent(); + node.removeFromParent(false); + ``` */ - getWorldCenter(): Vec2; + removeFromParent(cleanup?: boolean): void; /** !#en - Get the world linear velocity of a world point attached to this body. + Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter. </p> + If the cleanup parameter is not passed, it will force a cleanup. <br/> + "remove" logic MUST only be on this method <br/> + If a class wants to extend the 'removeChild' behavior it only needs <br/> + to override this method. !#zh - 获å–刚体上指定点的线性速度 - @param worldPoint a point in world coordinates. - @param out optional, the receiving point + ç§»é™¤èŠ‚ç‚¹ä¸æŒ‡å®šçš„å节点,是å¦éœ€è¦æ¸…ç†æ‰€æœ‰æ£åœ¨è¿è¡Œçš„行为å–决于 cleanup 傿•°ã€‚<br/> + 如果 cleanup 傿•°ä¸ä¼ 入,默认为 true 表示清ç†ã€‚<br/> + @param child The child node which will be removed. + @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. + + @example + ```js + node.removeChild(newNode); + node.removeChild(newNode, false); + ``` */ - getLinearVelocityFromWorldPoint(worldPoint: Vec2, out: Vec2): Vec2; + removeChild(child: Node, cleanup?: boolean): void; /** !#en - Get total mass of the body. + Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter. <br/> + If the cleanup parameter is not passed, it will force a cleanup. !#zh - 获å–刚体的质é‡ã€‚ + 移除节点所有的å节点,是å¦éœ€è¦æ¸…ç†æ‰€æœ‰æ£åœ¨è¿è¡Œçš„行为å–决于 cleanup 傿•°ã€‚<br/> + 如果 cleanup 傿•°ä¸ä¼ 入,默认为 true 表示清ç†ã€‚ + @param cleanup true if all running actions on all children nodes should be cleanup, false otherwise. + + @example + ```js + node.removeAllChildren(); + node.removeAllChildren(false); + ``` */ - getMass(): number; + removeAllChildren(cleanup?: boolean): void; + /** + !#en Is this node a child of the given node? + !#zh æ˜¯å¦æ˜¯æŒ‡å®šèŠ‚ç‚¹çš„å节点? + @param parent parent + + @example + ```js + node.isChildOf(newNode); + ``` + */ + isChildOf(parent: Node): boolean; /** !#en - Get the rotational inertia of the body about the local origin. + Returns the component of supplied type if the node has one attached, null if it doesn't.<br/> + You can also get component in the node by passing in the name of the script. !#zh - 获å–åˆšä½“æœ¬åœ°åæ ‡ç³»ä¸‹åŽŸç‚¹çš„æ—‹è½¬æƒ¯æ€§ + 获å–èŠ‚ç‚¹ä¸ŠæŒ‡å®šç±»åž‹çš„ç»„ä»¶ï¼Œå¦‚æžœèŠ‚ç‚¹æœ‰é™„åŠ æŒ‡å®šç±»åž‹çš„ç»„ä»¶ï¼Œåˆ™è¿”å›žï¼Œå¦‚æžœæ²¡æœ‰åˆ™ä¸ºç©ºã€‚<br/> + ä¼ å…¥å‚æ•°ä¹Ÿå¯ä»¥æ˜¯è„šæœ¬çš„å称。 + @param typeOrClassName typeOrClassName + + @example + ```js + // get sprite component + var sprite = node.getComponent(cc.Sprite); + // get custom test class + var test = node.getComponent("Test"); + ``` + */ + getComponent<T extends Component>(type: {prototype: T}): T; + getComponent(className: string): any; + /** + !#en Returns all components of supplied type in the node. + !#zh 返回节点上指定类型的所有组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponents(cc.Sprite); + var tests = node.getComponents("Test"); + ``` + */ + getComponents<T extends Component>(type: {prototype: T}): T[]; + getComponents(className: string): any[]; + /** + !#en Returns the component of supplied type in any of its children using depth first search. + !#zh 递归查找所有å节点ä¸ç¬¬ä¸€ä¸ªåŒ¹é…指定类型的组件。 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprite = node.getComponentInChildren(cc.Sprite); + var Test = node.getComponentInChildren("Test"); + ``` + */ + getComponentInChildren<T extends Component>(type: {prototype: T}): T; + getComponentInChildren(className: string): any; + /** + !#en Returns all components of supplied type in self or any of its children. + !#zh 递归查找自身或所有åèŠ‚ç‚¹ä¸æŒ‡å®šç±»åž‹çš„组件 + @param typeOrClassName typeOrClassName + + @example + ```js + var sprites = node.getComponentsInChildren(cc.Sprite); + var tests = node.getComponentsInChildren("Test"); + ``` + */ + getComponentsInChildren<T extends Component>(type: {prototype: T}): T[]; + getComponentsInChildren(className: string): any[]; + /** + !#en Adds a component class to the node. You can also add component to node by passing in the name of the script. + !#zh å‘èŠ‚ç‚¹æ·»åŠ ä¸€ä¸ªæŒ‡å®šç±»åž‹çš„ç»„ä»¶ç±»ï¼Œä½ è¿˜å¯ä»¥é€šè¿‡ä¼ 入脚本的åç§°æ¥æ·»åŠ ç»„ä»¶ã€‚ + @param typeOrClassName The constructor or the class name of the component to add + + @example + ```js + var sprite = node.addComponent(cc.Sprite); + var test = node.addComponent("Test"); + ``` */ - getInertia(): number; + addComponent<T extends Component>(type: {new(): T}): T; + addComponent(className: string): any; /** !#en - Get all the joints connect to the rigidbody. + Removes a component identified by the given name or removes the component object given. + You can also use component.destroy() if you already have the reference. !#zh - 获å–链接到æ¤åˆšä½“的所有关节 + åˆ é™¤èŠ‚ç‚¹ä¸Šçš„æŒ‡å®šç»„ä»¶ï¼Œä¼ å…¥å‚æ•°å¯ä»¥æ˜¯ä¸€ä¸ªç»„ä»¶æž„é€ å‡½æ•°æˆ–ç»„ä»¶å,也å¯ä»¥æ˜¯å·²ç»èŽ·å¾—çš„ç»„ä»¶å¼•ç”¨ã€‚ + å¦‚æžœä½ å·²ç»èŽ·å¾—ç»„ä»¶å¼•ç”¨ï¼Œä½ ä¹Ÿå¯ä»¥ç›´æŽ¥è°ƒç”¨ component.destroy() + @param component The need remove component. + + @example + ```js + node.removeComponent(cc.Sprite); + var Test = require("Test"); + node.removeComponent(Test); + ``` */ - getJointList(): Joint[]; + removeComponent(component: string|Function|Component): void; /** !#en - Apply a force at a world point. If the force is not - applied at the center of mass, it will generate a torque and - affect the angular velocity. + Destroy all children from the node, and release all their own references to other objects.<br/> + Actual destruct operation will delayed until before rendering. !#zh - æ–½åŠ ä¸€ä¸ªåŠ›åˆ°åˆšä½“ä¸Šçš„ä¸€ä¸ªç‚¹ã€‚å¦‚æžœåŠ›æ²¡æœ‰æ–½åŠ åˆ°åˆšä½“çš„è´¨å¿ƒä¸Šï¼Œè¿˜ä¼šäº§ç”Ÿä¸€ä¸ªæ‰çŸ©å¹¶ä¸”å½±å“到角速度。 - @param force the world force vector. - @param point the world position. - @param wake also wake up the body. + é”€æ¯æ‰€æœ‰å节点,并释放所有它们对其它对象的引用。<br/> + å®žé™…é”€æ¯æ“作会延迟到当å‰å¸§æ¸²æŸ“剿‰§è¡Œã€‚ + + @example + ```js + node.destroyAllChildren(); + ``` */ - applyForce(force: Vec2, point: Vec2, wake: boolean): void; + destroyAllChildren(): void; /** - !#en - Apply a force to the center of mass. - !#zh - æ–½åŠ ä¸€ä¸ªåŠ›åˆ°åˆšä½“ä¸Šçš„è´¨å¿ƒä¸Šã€‚ - @param force the world force vector. - @param wake also wake up the body. + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh æ£€æŸ¥äº‹ä»¶ç›®æ ‡å¯¹è±¡æ˜¯å¦æœ‰ä¸ºç‰¹å®šç±»åž‹çš„事件注册的回调。 + @param type The type of event. */ - applyForceToCenter(force: Vec2, wake: boolean): void; + hasEventListener(type: string): boolean; /** !#en - Apply a torque. This affects the angular velocity. + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. !#zh - æ–½åŠ ä¸€ä¸ªæ‰çŸ©åŠ›ï¼Œå°†å½±å“刚体的角速度 - @param torque about the z-axis (out of the screen), usually in N-m. - @param wake also wake up the body + æ³¨å†Œäº‹ä»¶ç›®æ ‡çš„ç‰¹å®šäº‹ä»¶ç±»åž‹å›žè°ƒã€‚è¿™ç§ç±»åž‹çš„事件应该被 `emit` 触å‘。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); + ``` */ - applyTorque(torque: number, wake: boolean): void; + on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T; /** !#en - Apply a impulse at a world point, This immediately modifies the velocity. - If the impulse is not applied at the center of mass, it will generate a torque and - affect the angular velocity. + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. !#zh - æ–½åŠ å†²é‡åˆ°åˆšä½“ä¸Šçš„ä¸€ä¸ªç‚¹ï¼Œå°†ç«‹å³æ”¹å˜åˆšä½“的线性速度。 - å¦‚æžœå†²é‡æ–½åŠ åˆ°çš„ç‚¹ä¸æ˜¯åˆšä½“的质心,那么将产生一个æ‰çŸ©å¹¶å½±å“刚体的角速度。 - @param impulse the world impulse vector, usually in N-seconds or kg-m/s. - @param point the world position - @param wake alse wake up the body + åˆ é™¤ä¹‹å‰ç”¨åŒç±»åž‹ï¼Œå›žè°ƒï¼Œç›®æ ‡æˆ– useCapture 注册的事件监å¬å™¨ï¼Œå¦‚æžœåªä¼ 递 typeï¼Œå°†ä¼šåˆ é™¤ type 类型的所有事件监å¬å™¨ã€‚ + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed + + @example + ```js + // 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'); + ``` */ - applyLinearImpulse(impulse: Vec2, point: Vec2, wake: boolean): void; + off(type: string, callback?: Function, target?: any): void; /** - !#en - Apply an angular impulse. - !#zh - æ–½åŠ ä¸€ä¸ªè§’é€Ÿåº¦å†²é‡ã€‚ - @param impulse the angular impulse in units of kg*m*m/s - @param wake also wake up the body + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh åœ¨å½“å‰ EventTarget ä¸Šåˆ é™¤æŒ‡å®šç›®æ ‡ï¼ˆtarget 傿•°ï¼‰æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ + è¿™ä¸ªå‡½æ•°æ— æ³•åˆ é™¤å½“å‰ EventTarget 的所有事件监å¬å™¨ï¼Œä¹Ÿæ— æ³•åˆ é™¤ target 傿•°æ‰€æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ + 这个函数åªèƒ½åˆ 除 target 傿•°åœ¨å½“å‰ EventTarget 上注册的所有事件监å¬å™¨ã€‚ + @param target The target to be searched for all related listeners */ - applyAngularImpulse(impulse: number, wake: boolean): void; + targetOff(target: any): void; /** !#en - Synchronize node's world position to box2d rigidbody's position. - If enableAnimated is true and rigidbody's type is Animated type, - will set linear velocity instead of directly set rigidbody's position. + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. !#zh - åŒæ¥èŠ‚ç‚¹çš„ä¸–ç•Œåæ ‡åˆ° box2d åˆšä½“çš„åæ ‡ä¸Šã€‚ - 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的线性速度æ¥ä»£æ›¿ç›´æŽ¥è®¾ç½®åˆšä½“çš„ä½ç½®ã€‚ - @param enableAnimated enableAnimated + æ³¨å†Œäº‹ä»¶ç›®æ ‡çš„ç‰¹å®šäº‹ä»¶ç±»åž‹å›žè°ƒï¼Œå›žè°ƒä¼šåœ¨ç¬¬ä¸€æ—¶é—´è¢«è§¦å‘åŽåˆ 除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null + + @example + ```js + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); + ``` */ - syncPosition(enableAnimated: boolean): void; + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; /** !#en - Synchronize node's world angle to box2d rigidbody's angle. - If enableAnimated is true and rigidbody's type is Animated type, - will set angular velocity instead of directly set rigidbody's angle. - !#zh - åŒæ¥èŠ‚ç‚¹çš„ä¸–ç•Œæ—‹è½¬è§’åº¦å€¼åˆ° box2d 刚体的旋转值上。 - 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的角速度æ¥ä»£æ›¿ç›´æŽ¥è®¾ç½®åˆšä½“的角度。 - @param enableAnimated enableAnimated - */ - syncRotation(enableAnimated: boolean): void; - } - /** undefined */ - export class Graphics extends RenderComponent { - /** !#en - Current line width. - !#zh - 当å‰çº¿æ¡å®½åº¦ */ - lineWidth: number; - /** !#en - lineJoin determines how two connecting segments (of lines, arcs or curves) with non-zero lengths in a shape are joined together. - !#zh - lineJoin 用æ¥è®¾ç½®2个长度ä¸ä¸º0的相连部分(线段,圆弧,曲线)如何连接在一起的属性。 */ - lineJoin: Graphics.LineJoin; - /** !#en - lineCap determines how the end points of every line are drawn. - !#zh - lineCap 指定如何绘制æ¯ä¸€æ¡çº¿æ®µæœ«ç«¯ã€‚ */ - lineCap: Graphics.LineCap; - /** !#en - stroke color - !#zh - 线段颜色 */ - strokeColor: Color; - /** !#en - fill color - !#zh - 填充颜色 */ - fillColor: Color; - /** !#en - Sets the miter limit ratio + Send an event with the event object. !#zh - 设置斜接é¢é™åˆ¶æ¯”例 */ - miterLimit: number; - /** - !#en Move path start point to (x,y). - !#zh ç§»åŠ¨è·¯å¾„èµ·ç‚¹åˆ°åæ ‡(x, y) - @param x The x axis of the coordinate for the end point. - @param y The y axis of the coordinate for the end point. - */ - moveTo(x?: number, y?: number): void; - /** - !#en Adds a straight line to the path - !#zh 绘制直线路径 - @param x The x axis of the coordinate for the end point. - @param y The y axis of the coordinate for the end point. - */ - lineTo(x?: number, y?: number): void; - /** - !#en Adds a cubic Bézier curve to the path - !#zh 绘制三次è´èµ›å°”曲线路径 - @param c1x The x axis of the coordinate for the first control point. - @param c1y The y axis of the coordinate for first control point. - @param c2x The x axis of the coordinate for the second control point. - @param c2y The y axis of the coordinate for the second control point. - @param x The x axis of the coordinate for the end point. - @param y The y axis of the coordinate for the end point. - */ - bezierCurveTo(c1x?: number, c1y?: number, c2x?: number, c2y?: number, x?: number, y?: number): void; - /** - !#en Adds a quadratic Bézier curve to the path - !#zh 绘制二次è´èµ›å°”曲线路径 - @param cx The x axis of the coordinate for the control point. - @param cy The y axis of the coordinate for the control point. - @param x The x axis of the coordinate for the end point. - @param y The y axis of the coordinate for the end point. - */ - quadraticCurveTo(cx?: number, cy?: number, x?: number, y?: number): void; - /** - !#en Adds an arc to the path which is centered at (cx, cy) position with radius r starting at startAngle and ending at endAngle going in the given direction by counterclockwise (defaulting to false). - !#zh 绘制圆弧路径。圆弧路径的圆心在 (cx, cy) ä½ç½®ï¼ŒåŠå¾„为 r ï¼Œæ ¹æ® counterclockwise (默认为false)指定的方å‘从 startAngle 开始绘制,到 endAngle 结æŸã€‚ - @param cx The x axis of the coordinate for the center point. - @param cy The y axis of the coordinate for the center point. - @param r The arc's radius. - @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians. - @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians. - @param counterclockwise An optional Boolean which, if true, causes the arc to be drawn counter-clockwise between the two angles. By default it is drawn clockwise. - */ - arc(cx?: number, cy?: number, r?: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): void; - /** - !#en Adds an ellipse to the path. - !#zh 绘制æ¤åœ†è·¯å¾„。 - @param cx The x axis of the coordinate for the center point. - @param cy The y axis of the coordinate for the center point. - @param rx The ellipse's x-axis radius. - @param ry The ellipse's y-axis radius. - */ - ellipse(cx?: number, cy?: number, rx?: number, ry?: number): void; - /** - !#en Adds an circle to the path. - !#zh 绘制圆形路径。 - @param cx The x axis of the coordinate for the center point. - @param cy The y axis of the coordinate for the center point. - @param r The circle's radius. - */ - circle(cx?: number, cy?: number, r?: number): void; - /** - !#en Adds an rectangle to the path. - !#zh 绘制矩形路径。 - @param x The x axis of the coordinate for the rectangle starting point. - @param y The y axis of the coordinate for the rectangle starting point. - @param w The rectangle's width. - @param h The rectangle's height. + 通过事件对象派å‘事件 + @param event event */ - rect(x?: number, y?: number, w?: number, h?: number): void; - /** - !#en Adds an round corner rectangle to the path. - !#zh 绘制圆角矩形路径。 - @param x The x axis of the coordinate for the rectangle starting point. - @param y The y axis of the coordinate for the rectangle starting point. - @param w The rectangles width. - @param h The rectangle's height. - @param r The radius of the rectangle. + dispatchEvent(event: Event): void; + /** + !#en + Destroy all callbackInfos. + !#zh + 销æ¯è®°å½•的事件 */ - roundRect(x?: number, y?: number, w?: number, h?: number, r?: number): void; + clear(): void; + } + /** !#en + Helper class for setting material blend function. + !#zh + 设置æè´¨æ··åˆæ¨¡å¼çš„辅助类。 */ + export class BlendFunc { + /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. + !#zh æŒ‡å®šåŽŸå›¾çš„æ··åˆæ¨¡å¼ï¼Œè¿™ä¼šå…‹éš†ä¸€ä¸ªæ–°çš„æè´¨å¯¹è±¡ï¼Œæ³¨æ„这带æ¥çš„开销 */ + srcBlendFactor: macro.BlendFactor; + /** !#en specify the destination Blend Factor. + !#zh æŒ‡å®šç›®æ ‡çš„æ··åˆæ¨¡å¼ */ + dstBlendFactor: macro.BlendFactor; + } + /** An internal helper class for switching render component's material between normal sprite material and gray sprite material. */ + export class GraySpriteState { + /** !#en The normal material. + !#zh æ£å¸¸çжæ€çš„æè´¨ã€‚ */ + normalMaterial: Material; + /** !#en The gray material. + !#zh ç½®ç°çжæ€çš„æè´¨ã€‚ */ + grayMaterial: Material; + } + /** misc utilities */ + export class misc { /** - !#en Draws a filled rectangle. - !#zh 绘制填充矩形。 - @param x The x axis of the coordinate for the rectangle starting point. - @param y The y axis of the coordinate for the rectangle starting point. - @param w The rectangle's width. - @param h The rectangle's height. + !#en Clamp a value between from and to. + !#zh + é™å®šæµ®ç‚¹æ•°çš„æœ€å¤§æœ€å°å€¼ã€‚<br/> + 数值大于 max_inclusive 则返回 max_inclusive。<br/> + 数值å°äºŽ min_inclusive 则返回 min_inclusive。<br/> + å¦åˆ™è¿”回自身。 + @param value value + @param min_inclusive min_inclusive + @param max_inclusive max_inclusive + + @example + ```js + var v1 = cc.misc.clampf(20, 0, 20); // 20; + var v2 = cc.misc.clampf(-1, 0, 20); // 0; + var v3 = cc.misc.clampf(10, 0, 20); // 10; + ``` */ - fillRect(x?: number, y?: number, w?: number, h?: number): void; + static clampf(value: number, min_inclusive: number, max_inclusive: number): number; /** - !#en Erasing any previously drawn content. - !#zh 擦除之å‰ç»˜åˆ¶çš„æ‰€æœ‰å†…容的方法。 - @param clean Whether to clean the graphics inner cache. + !#en Clamp a value between 0 and 1. + !#zh é™å®šæµ®ç‚¹æ•°çš„å–值范围为 0 ~ 1 之间。 + @param value value + + @example + ```js + var v1 = cc.misc.clamp01(20); // 1; + var v2 = cc.misc.clamp01(-1); // 0; + var v3 = cc.misc.clamp01(0.5); // 0.5; + ``` */ - clear(clean?: boolean): void; + static clamp01(value: number): number; /** - !#en Causes the point of the pen to move back to the start of the current path. It tries to add a straight line from the current point to the start. - !#zh 将笔点返回到当å‰è·¯å¾„起始点的。它å°è¯•从当å‰ç‚¹åˆ°èµ·å§‹ç‚¹ç»˜åˆ¶ä¸€æ¡ç›´çº¿ã€‚ + Linear interpolation between 2 numbers, the ratio sets how much it is biased to each end + @param a number A + @param b number B + @param r ratio between 0 and 1 + + @example + ```js + ---- + lerp + cc.misc.lerp(2,10,0.5)//returns 6 + cc.misc.lerp(2,10,0.2)//returns 3.6 + + ``` */ - close(): void; + static lerp(a: number, b: number, r: number): number; /** - !#en Strokes the current or given path with the current stroke style. - !#zh æ ¹æ®å½“å‰çš„ç”»çº¿æ ·å¼ï¼Œç»˜åˆ¶å½“剿ˆ–å·²ç»å˜åœ¨çš„路径。 + converts degrees to radians + @param angle angle */ - stroke(): void; + static degreesToRadians(angle: number): number; /** - !#en Fills the current or given path with the current fill style. - !#zh æ ¹æ®å½“å‰çš„ç”»çº¿æ ·å¼ï¼Œå¡«å……当剿ˆ–å·²ç»å˜åœ¨çš„路径。 + converts radians to degrees + @param angle angle */ - fill(): void; + static radiansToDegrees(angle: number): number; + } + /** !#en The renderer object which provide access to render system APIs, + detailed APIs will be available progressively. + !#zh æä¾›åŸºç¡€æ¸²æŸ“接å£çš„æ¸²æŸ“器对象,渲染层的基础接å£å°†é€æ¥å¼€æ”¾ç»™ç”¨æˆ· */ + export class renderer { + /** !#en The render engine is available only after cc.game.EVENT_ENGINE_INITED event.<br/> + Normally it will be inited as the webgl render engine, but in wechat open context domain, + it will be inited as the canvas render engine. Canvas render engine is no longer available for other use case since v2.0. + !#zh 基础渲染引擎对象åªåœ¨ cc.game.EVENT_ENGINE_INITED 事件触å‘åŽæ‰å¯èŽ·å–。<br/> + 大多数情况下,它都会是 WebGL 渲染引擎实例,但是在微信开放数æ®åŸŸå½“ä¸ï¼Œå®ƒä¼šæ˜¯ Canvas 渲染引擎实例。请注æ„,从 2.0 开始,我们在其他平å°å’ŒçŽ¯å¢ƒä¸‹éƒ½åºŸå¼ƒäº† Canvas 渲染器。 */ + static renderEngine: any; + /** !#en The total draw call count in last rendered frame. + !#zh 上一次渲染帧所æäº¤çš„æ¸²æŸ“批次总数。 */ + static drawCalls: number; } /** !#en the device accelerometer reports values for each axis in units of g-force. !#zh 设备é‡åŠ›ä¼ æ„Ÿå™¨ä¼ é€’çš„å„个轴的数æ®ã€‚ */ @@ -10730,35 +10725,6 @@ declare namespace cc { EditorOnly = 0, HideInHierarchy = 0, } - /** The fullscreen API provides an easy way for web content to be presented using the user's entire screen. - It's invalid on safari, QQbrowser and android browser */ - export class screen { - /** - initialize - */ - init(): void; - /** - return true if it's full now. - */ - fullScreen(): boolean; - /** - change the screen to full mode. - @param element element - @param onFullScreenChange onFullScreenChange - @param onFullScreenError onFullScreenError - */ - requestFullScreen(element: Element, onFullScreenChange: Function, onFullScreenError: Function): void; - /** - exit the full mode. - */ - exitFullScreen(): boolean; - /** - Automatically request full screen with a touch/click event - @param element element - @param onFullScreenChange onFullScreenChange - */ - autoFullScreen(element: Element, onFullScreenChange: Function): void; - } /** System variables */ export class sys { /** English language code */ @@ -10844,22 +10810,11 @@ declare namespace cc { static WECHAT_GAME_SUB: number; static BAIDU_GAME_SUB: number; static QTT_GAME: number; + static BYTEDANCE_GAME: number; + static BYTEDANCE_GAME_SUB: number; + static LINKSURE: number; /** BROWSER_TYPE_WECHAT */ static BROWSER_TYPE_WECHAT: string; - /** BROWSER_TYPE_WECHAT_GAME */ - static BROWSER_TYPE_WECHAT_GAME: string; - /** BROWSER_TYPE_WECHAT_GAME_SUB */ - static BROWSER_TYPE_WECHAT_GAME_SUB: string; - /** BROWSER_TYPE_BAIDU_GAME */ - static BROWSER_TYPE_BAIDU_GAME: string; - /** BROWSER_TYPE_BAIDU_GAME_SUB */ - static BROWSER_TYPE_BAIDU_GAME_SUB: string; - /** BROWSER_TYPE_XIAOMI_GAME */ - static BROWSER_TYPE_XIAOMI_GAME: string; - /** BROWSER_TYPE_ALIPAY_GAME */ - static BROWSER_TYPE_ALIPAY_GAME: string; - /** BROWSER_TYPE_QQ_PLAY */ - static BROWSER_TYPE_QQ_PLAY: string; static BROWSER_TYPE_ANDROID: string; static BROWSER_TYPE_IE: string; static BROWSER_TYPE_EDGE: string; @@ -10881,6 +10836,7 @@ declare namespace cc { static BROWSER_TYPE_LIEBAO: string; static BROWSER_TYPE_QZONE: string; static BROWSER_TYPE_SOUGOU: string; + static BROWSER_TYPE_HUAWEI: string; static BROWSER_TYPE_UNKNOWN: string; /** Is native ? This is set to be true in jsb auto. */ static isNative: boolean; @@ -10890,17 +10846,17 @@ declare namespace cc { Is webgl extension support? @param name name */ - static glExtension(name: any): void; + static glExtension(name: any): boolean; /** Get max joint matrix size for skinned mesh renderer. */ static getMaxJointMatrixSize(): void; /** !#en - Returns the safe area of the screen. If the screen is not notched, the design resolution will be returned by default. - Only supported on Android, iOS and WeChat Mini Game platform. + Returns the safe area of the screen (in design resolution). If the screen is not notched, the visibleRect will be returned by default. + Currently supports Android, iOS and WeChat Mini Game platform. !#zh - 返回手机å±å¹•å®‰å…¨åŒºåŸŸï¼Œå¦‚æžœä¸æ˜¯å¼‚å½¢å±å°†é»˜è®¤è¿”回设计分辨率尺寸。目å‰åªæ”¯æŒå®‰å“ã€iOS 原生平å°å’Œå¾®ä¿¡å°æ¸¸æˆå¹³å°ã€‚ + 返回手机å±å¹•安全区域(设计分辨率为å•ä½ï¼‰ï¼Œå¦‚æžœä¸æ˜¯å¼‚å½¢å±å°†é»˜è®¤è¿”回 visibleRectã€‚ç›®å‰æ”¯æŒå®‰å“ã€iOS 原生平å°å’Œå¾®ä¿¡å°æ¸¸æˆå¹³å°ã€‚ */ static getSafeAreaRect(): Rect; /** Indicate whether system is mobile system */ @@ -10920,9 +10876,9 @@ declare namespace cc { /** Indicate the running os main version */ static osMainVersion: number; /** Indicate the running browser type */ - static browserType: string; + static browserType: string|void; /** Indicate the running browser version */ - static browserVersion: string; + static browserVersion: string|void; /** Indicate the real pixel resolution of the whole game window */ static windowPixelResolution: Size; /** cc.sys.localStorage is a local storage component. */ @@ -10972,6 +10928,35 @@ declare namespace cc { */ static now(): number; } + /** The fullscreen API provides an easy way for web content to be presented using the user's entire screen. + It's invalid on safari, QQbrowser and android browser */ + export class screen { + /** + initialize + */ + init(): void; + /** + return true if it's full now. + */ + fullScreen(): boolean; + /** + change the screen to full mode. + @param element element + @param onFullScreenChange onFullScreenChange + @param onFullScreenError onFullScreenError + */ + requestFullScreen(element: Element, onFullScreenChange: Function, onFullScreenError: Function): void; + /** + exit the full mode. + */ + exitFullScreen(): boolean; + /** + Automatically request full screen with a touch/click event + @param element element + @param onFullScreenChange onFullScreenChange + */ + autoFullScreen(element: Element, onFullScreenChange: Function): void; + } /** cc.view is the singleton object which represents the game window.<br/> It's main task include: <br/> - Apply the design resolution policy<br/> @@ -11491,710 +11476,795 @@ declare namespace cc { /** !#en Contains information collected during deserialization !#zh 包å«ååºåˆ—åŒ–æ—¶çš„ä¸€äº›ä¿¡æ¯ */ export class Details { - /** list of the depends assets' uuid */ - uuidList: string[]; /** the obj list whose field needs to load asset by uuid */ uuidObjList: any[]; /** the corresponding field name which referenced to the asset */ - uuidPropList: string[]; - reset(): void; - /** - - @param obj obj - @param propName propName - @param uuid uuid - */ - push(obj: any, propName: string, uuid: string): void; - } - /** !#en The module provides utilities for working with file and directory paths - !#zh ç”¨äºŽå¤„ç†æ–‡ä»¶ä¸Žç›®å½•çš„è·¯å¾„çš„æ¨¡å— */ - export class path { - /** - !#en Join strings to be a path. - !#zh 拼接å—符串为 Path - - @example - ```js - ------------------------------ - cc.path.join("a", "b.png"); //-->"a/b.png" - cc.path.join("a", "b", "c.png"); //-->"a/b/c.png" - cc.path.join("a", "b"); //-->"a/b" - cc.path.join("a", "b", "/"); //-->"a/b/" - cc.path.join("a", "b/", "/"); //-->"a/b/" - - ``` - */ - static join(): string; - /** - !#en Get the ext name of a path including '.', like '.png'. - !#zh 返回 Path 的扩展å,包括 '.',例如 '.png'。 - @param pathStr pathStr - - @example - ```js - --------------------------- - cc.path.extname("a/b.png"); //-->".png" - cc.path.extname("a/b.png?a=1&b=2"); //-->".png" - cc.path.extname("a/b"); //-->null - cc.path.extname("a/b?a=1&b=2"); //-->null - - ``` - */ - static extname(pathStr: string): any; - /** - !#en Get the main name of a file name - !#zh èŽ·å–æ–‡ä»¶å的主åç§° - @param fileName fileName - */ - static mainFileName(fileName: string): string; + uuidPropList: (String|Number)[]; + /** list of the depends assets' uuid */ + uuidList: string[]; /** - !#en Get the file name of a file path. - !#zh èŽ·å–æ–‡ä»¶è·¯å¾„的文件å。 - @param pathStr pathStr - @param extname extname - - @example - ```js - --------------------------------- - cc.path.basename("a/b.png"); //-->"b.png" - cc.path.basename("a/b.png?a=1&b=2"); //-->"b.png" - cc.path.basename("a/b.png", ".png"); //-->"b" - cc.path.basename("a/b.png?a=1&b=2", ".png"); //-->"b" - cc.path.basename("a/b.png", ".txt"); //-->"b.png" - ``` + @param data data */ - static basename(pathStr: string, extname?: string): any; + init(data: any): void; + reset(): void; /** - !#en Get dirname of a file path. - !#zh èŽ·å–æ–‡ä»¶è·¯å¾„的目录å。 - @param pathStr pathStr - - @example - ```js - --------------------------------- - * unix - cc.path.driname("a/b/c.png"); //-->"a/b" - cc.path.driname("a/b/c.png?a=1&b=2"); //-->"a/b" - cc.path.dirname("a/b/"); //-->"a/b" - cc.path.dirname("c.png"); //-->"" - * windows - cc.path.driname("a\\b\\c.png"); //-->"a\b" - cc.path.driname("a\\b\\c.png?a=1&b=2"); //-->"a\b" - ``` + @param obj obj + @param propName propName + @param uuid uuid */ - static dirname(pathStr: string): any; + push(obj: any, propName: string, uuid: string): void; + /** list of the depends assets' uuid */ + uuidList: string[]; + /** the obj list whose field needs to load asset by uuid */ + uuidObjList: any[]; + /** the corresponding field name which referenced to the asset */ + uuidPropList: string[]; + reset(): void; /** - !#en Change extname of a file path. - !#zh 更改文件路径的扩展å。 - @param pathStr pathStr - @param extname extname - @example - ```js - --------------------------------- - cc.path.changeExtname("a/b.png", ".plist"); //-->"a/b.plist" - cc.path.changeExtname("a/b.png?a=1&b=2", ".plist"); //-->"a/b.plist?a=1&b=2" - - ``` + @param obj obj + @param propName propName + @param uuid uuid */ - static changeExtname(pathStr: string, extname?: string): string; + push(obj: any, propName: string, uuid: string): void; + } + /** undefined */ + export class WorldManifold { + /** !#en + world contact point (point of intersection) + !#zh + ç¢°æ’žç‚¹é›†åˆ */ + points: Vec2[]; + /** !#en + world vector pointing from A to B + !#zh + ä¸–ç•Œåæ ‡ç³»ä¸‹ç”± A æŒ‡å‘ B çš„å‘é‡ */ + normal: Vec2; } /** !#en - AffineTransform class represent an affine transform matrix. It's composed basically by translation, rotation, scale transformations.<br/> + A manifold point is a contact point belonging to a contact manifold. + It holds details related to the geometry and dynamics of the contact points. + Note: the impulses are used for internal caching and may not + provide reliable contact forces, especially for high speed collisions. !#zh - AffineTransform ç±»ä»£è¡¨ä¸€ä¸ªä»¿å°„å˜æ¢çŸ©é˜µã€‚å®ƒåŸºæœ¬ä¸Šæ˜¯ç”±å¹³ç§»æ—‹è½¬ï¼Œç¼©æ”¾è½¬å˜æ‰€ç»„æˆã€‚<br/> */ - export class AffineTransform { + ManifoldPoint 是接触信æ¯ä¸çš„æŽ¥è§¦ç‚¹ä¿¡æ¯ã€‚å®ƒæ‹¥æœ‰å…³äºŽå‡ ä½•å’ŒæŽ¥è§¦ç‚¹çš„è¯¦ç»†ä¿¡æ¯ã€‚ + 注æ„:信æ¯ä¸çš„冲é‡ç”¨äºŽç³»ç»Ÿå†…部缓å˜ï¼Œæä¾›çš„æŽ¥è§¦åŠ›å¯èƒ½ä¸æ˜¯å¾ˆå‡†ç¡®ï¼Œç‰¹åˆ«æ˜¯é«˜é€Ÿç§»åЍä¸çš„碰撞信æ¯ã€‚ */ + export class ManifoldPoint { + /** !#en + The local point usage depends on the manifold type: + -e_circles: the local center of circleB + -e_faceA: the local center of circleB or the clip point of polygonB + -e_faceB: the clip point of polygonA + !#zh + æœ¬åœ°åæ ‡ç‚¹çš„用途å–决于 manifold 的类型 + - e_circles: circleB 的本地ä¸å¿ƒç‚¹ + - e_faceA: circleB 的本地ä¸å¿ƒç‚¹ 或者是 polygonB 的截å–点 + - e_faceB: polygonB 的截å–点 */ + localPoint: Vec2; + /** !#en + Normal impulse. + !#zh + 法线冲é‡ã€‚ */ + normalImpulse: number; + /** !#en + Tangent impulse. + !#zh + 切线冲é‡ã€‚ */ + tangentImpulse: number; + } + /** undefined */ + export class Manifold { + /** !#en + Manifold type : 0: e_circles, 1: e_faceA, 2: e_faceB + !#zh + Manifold 类型 : 0: e_circles, 1: e_faceA, 2: e_faceB */ + type: number; + /** !#en + The local point usage depends on the manifold type: + -e_circles: the local center of circleA + -e_faceA: the center of faceA + -e_faceB: the center of faceB + !#zh + 用途å–决于 manifold 类型 + -e_circles: circleA 的本地ä¸å¿ƒç‚¹ + -e_faceA: faceA 的本地ä¸å¿ƒç‚¹ + -e_faceB: faceB 的本地ä¸å¿ƒç‚¹ */ + localPoint: Vec2; + /** !#en + -e_circles: not used + -e_faceA: the normal on polygonA + -e_faceB: the normal on polygonB + !#zh + -e_circles: 没被使用到 + -e_faceA: polygonA 的法å‘é‡ + -e_faceB: polygonB 的法å‘é‡ */ + localNormal: Vec2; + /** !#en + the points of contact. + !#zh + 接触点信æ¯ã€‚ */ + points: ManifoldPoint[]; + } + /** !#en + Contact impulses for reporting. + !#zh + 用于返回给回调的接触冲é‡ã€‚ */ + export class PhysicsImpulse { + /** !#en + Normal impulses. + !#zh + 法线方å‘çš„å†²é‡ */ + normalImpulses: any; + /** !#en + Tangent impulses + !#zh + 切线方å‘çš„å†²é‡ */ + tangentImpulses: any; + } + /** !#en + PhysicsContact will be generated during begin and end collision as a parameter of the collision callback. + Note that contacts will be reused for speed up cpu time, so do not cache anything in the contact. + !#zh + ç‰©ç†æŽ¥è§¦ä¼šåœ¨å¼€å§‹å’Œç»“æŸç¢°æ’žä¹‹é—´ç”Ÿæˆï¼Œå¹¶ä½œä¸ºå‚æ•°ä¼ å…¥åˆ°ç¢°æ’žå›žè°ƒå‡½æ•°ä¸ã€‚ + 注æ„ï¼šä¼ å…¥çš„ç‰©ç†æŽ¥è§¦ä¼šè¢«ç³»ç»Ÿè¿›è¡Œé‡ç”¨ï¼Œæ‰€ä»¥ä¸è¦åœ¨ä½¿ç”¨ä¸ç¼“å˜é‡Œé¢çš„任何信æ¯ã€‚ */ + export class PhysicsContact { /** - !#en Create a AffineTransform object with all contents in the matrix. - !#zh 用在矩阵ä¸çš„æ‰€æœ‰å†…容创建一个 AffineTransform 对象。 - @param a a - @param b b - @param c c - @param d d - @param tx tx - @param ty ty + !#en + Get the world manifold. + !#zh + 获å–ä¸–ç•Œåæ ‡ç³»ä¸‹çš„碰撞信æ¯ã€‚ */ - static create(a: number, b: number, c: number, d: number, tx: number, ty: number): AffineTransform; + getWorldManifold(): WorldManifold; /** !#en - Create a identity transformation matrix: <br/> - [ 1, 0, 0, <br/> - 0, 1, 0 ] + Get the manifold. !#zh - å•ä½çŸ©é˜µï¼š<br/> - [ 1, 0, 0, <br/> - 0, 1, 0 ] + èŽ·å–æœ¬åœ°ï¼ˆå±€éƒ¨ï¼‰åæ ‡ç³»ä¸‹çš„ç¢°æ’žä¿¡æ¯ã€‚ */ - static identity(): AffineTransform; + getManifold(): Manifold; /** - !#en Clone a AffineTransform object from the specified transform. - !#zh 克隆指定的 AffineTransform 对象。 - @param t t + !#en + Get the impulses. + Note: PhysicsImpulse can only used in onPostSolve callback. + !#zh + 获å–冲é‡ä¿¡æ¯ + 注æ„:这个信æ¯åªæœ‰åœ¨ onPostSolve å›žè°ƒä¸æ‰èƒ½èŽ·å–到 */ - static clone(t: AffineTransform): AffineTransform; + getImpulse(): PhysicsImpulse; + /** !#en + One of the collider that collided + !#zh + å‘生碰撞的碰撞体之一 */ + colliderA: Collider; + /** !#en + One of the collider that collided + !#zh + å‘生碰撞的碰撞体之一 */ + colliderB: Collider; + /** !#en + If set disabled to true, the contact will be ignored until contact end. + If you just want to disabled contact for current time step or sub-step, please use disabledOnce. + !#zh + 如果 disabled 被设置为 trueï¼Œé‚£ä¹ˆç›´åˆ°æŽ¥è§¦ç»“æŸæ¤æŽ¥è§¦éƒ½å°†è¢«å¿½ç•¥ã€‚ + å¦‚æžœåªæ˜¯å¸Œæœ›åœ¨å½“剿—¶é—´æ¥æˆ–忥ä¸å¿½ç•¥æ¤æŽ¥è§¦ï¼Œè¯·ä½¿ç”¨ disabledOnce 。 */ + disabled: boolean; + /** !#en + Disabled contact for current time step or sub-step. + !#zh + åœ¨å½“å‰æ—¶é—´æ¥æˆ–忥ä¸å¿½ç•¥æ¤æŽ¥è§¦ã€‚ */ + disabledOnce: boolean; /** !#en - Concatenate a transform matrix to another - The results are reflected in the out affine transform - out = t1 * t2 - This function is memory free, you should create the output affine transform by yourself and manage its memory. + Is this contact touching? !#zh - 拼接两个矩阵,将结果ä¿å˜åˆ° out 矩阵。这个函数ä¸åˆ›å»ºä»»ä½•内å˜ï¼Œä½ 需è¦å…ˆåˆ›å»º AffineTransform 对象用æ¥å˜å‚¨ç»“æžœï¼Œå¹¶ä½œä¸ºç¬¬ä¸€ä¸ªå‚æ•°ä¼ 入函数。 - out = t1 * t2 - @param out Out object to store the concat result - @param t1 The first transform object. - @param t2 The transform object to concatenate. + 返回碰撞体是å¦å·²ç»æŽ¥è§¦åˆ°ã€‚ */ - static concat(out: AffineTransform, t1: AffineTransform, t2: AffineTransform): AffineTransform; + isTouching(): boolean; /** - !#en Get the invert transform of an AffineTransform object. - This function is memory free, you should create the output affine transform by yourself and manage its memory. - !#zh 求逆矩阵。这个函数ä¸åˆ›å»ºä»»ä½•内å˜ï¼Œä½ 需è¦å…ˆåˆ›å»º AffineTransform 对象用æ¥å˜å‚¨ç»“æžœï¼Œå¹¶ä½œä¸ºç¬¬ä¸€ä¸ªå‚æ•°ä¼ 入函数。 - @param out out - @param t t + !#en + Set the desired tangent speed for a conveyor belt behavior. + !#zh + ä¸ºä¼ é€å¸¦è®¾ç½®æœŸæœ›çš„切线速度 + @param tangentSpeed tangentSpeed */ - static invert(out: AffineTransform, t: AffineTransform): AffineTransform; + setTangentSpeed(tangentSpeed: number): void; /** - !#en Get an AffineTransform object from a given matrix 4x4. - This function is memory free, you should create the output affine transform by yourself and manage its memory. - !#zh 从一个 4x4 Matrix èŽ·å– AffineTransform 对象。这个函数ä¸åˆ›å»ºä»»ä½•内å˜ï¼Œä½ 需è¦å…ˆåˆ›å»º AffineTransform 对象用æ¥å˜å‚¨ç»“æžœï¼Œå¹¶ä½œä¸ºç¬¬ä¸€ä¸ªå‚æ•°ä¼ 入函数。 - @param out out - @param mat mat + !#en + Get the desired tangent speed. + !#zh + 获å–切线速度 */ - static invert(out: AffineTransform, mat: Mat4): AffineTransform; + getTangentSpeed(): number; /** - !#en Apply the affine transformation on a point. - This function is memory free, you should create the output Vec2 by yourself and manage its memory. - !#zh å¯¹ä¸€ä¸ªç‚¹åº”ç”¨çŸ©é˜µå˜æ¢ã€‚这个函数ä¸åˆ›å»ºä»»ä½•内å˜ï¼Œä½ 需è¦å…ˆåˆ›å»ºä¸€ä¸ª Vec2 对象用æ¥å˜å‚¨ç»“æžœï¼Œå¹¶ä½œä¸ºç¬¬ä¸€ä¸ªå‚æ•°ä¼ 入函数。 - @param out The output point to store the result - @param point Point to apply transform or x. - @param transOrY transform matrix or y. - @param t transform matrix. + !#en + Override the default friction mixture. You can call this in onPreSolve callback. + !#zh + è¦†ç›–é»˜è®¤çš„æ‘©æ“¦åŠ›ç³»æ•°ã€‚ä½ å¯ä»¥åœ¨ onPreSolve 回调ä¸è°ƒç”¨æ¤å‡½æ•°ã€‚ + @param friction friction */ - static transformVec2(out: Vec2, point: Vec2|number, transOrY: AffineTransform|number, t?: AffineTransform): Vec2; + setFriction(friction: number): void; /** - !#en Apply the affine transformation on a size. - This function is memory free, you should create the output Size by yourself and manage its memory. - !#zh åº”ç”¨ä»¿å°„å˜æ¢çŸ©é˜µåˆ° Size 上。这个函数ä¸åˆ›å»ºä»»ä½•内å˜ï¼Œä½ 需è¦å…ˆåˆ›å»ºä¸€ä¸ª Size 对象用æ¥å˜å‚¨ç»“æžœï¼Œå¹¶ä½œä¸ºç¬¬ä¸€ä¸ªå‚æ•°ä¼ 入函数。 - @param out The output point to store the result - @param size size - @param t t + !#en + Get the friction. + !#zh + 获å–当剿‘©æ“¦åŠ›ç³»æ•° + */ + getFriction(): number; + /** + !#en + Reset the friction mixture to the default value. + !#zh + é‡ç½®æ‘©æ“¦åŠ›ç³»æ•°åˆ°é»˜è®¤å€¼ + */ + resetFriction(): void; + /** + !#en + Override the default restitution mixture. You can call this in onPreSolve callback. + !#zh + 覆盖默认的æ¢å¤ç³»æ•°ã€‚ä½ å¯ä»¥åœ¨ onPreSolve 回调ä¸è°ƒç”¨æ¤å‡½æ•°ã€‚ + @param restitution restitution */ - static transformSize(out: Size, size: Size, t: AffineTransform): Size; + setRestitution(restitution: number): void; /** - !#en Apply the affine transformation on a rect. - This function is memory free, you should create the output Rect by yourself and manage its memory. - !#zh åº”ç”¨ä»¿å°„å˜æ¢çŸ©é˜µåˆ° Rect 上。这个函数ä¸åˆ›å»ºä»»ä½•内å˜ï¼Œä½ 需è¦å…ˆåˆ›å»ºä¸€ä¸ª Rect 对象用æ¥å˜å‚¨ç»“æžœï¼Œå¹¶ä½œä¸ºç¬¬ä¸€ä¸ªå‚æ•°ä¼ 入函数。 - @param out out - @param rect rect - @param anAffineTransform anAffineTransform + !#en + Get the restitution. + !#zh + 获å–当剿¢å¤ç³»æ•° */ - static transformRect(out: Rect, rect: Rect, anAffineTransform: AffineTransform): Rect; + getRestitution(): number; /** - !#en Apply the affine transformation on a rect, and truns to an Oriented Bounding Box. - This function is memory free, you should create the output vectors by yourself and manage their memory. - !#zh åº”ç”¨ä»¿å°„å˜æ¢çŸ©é˜µåˆ° Rect 上, 并转æ¢ä¸ºæœ‰å‘包围盒。这个函数ä¸åˆ›å»ºä»»ä½•内å˜ï¼Œä½ 需è¦å…ˆåˆ›å»ºåŒ…围盒的四个 Vector 对象用æ¥å˜å‚¨ç»“果,并作为å‰å››ä¸ªå‚æ•°ä¼ å…¥å‡½æ•°ã€‚ - @param out_bl out_bl - @param out_tl out_tl - @param out_tr out_tr - @param out_br out_br - @param rect rect - @param anAffineTransform anAffineTransform + !#en + Reset the restitution mixture to the default value. + !#zh + é‡ç½®æ¢å¤ç³»æ•°åˆ°é»˜è®¤å€¼ */ - static transformObb(out_bl: Vec2, out_tl: Vec2, out_tr: Vec2, out_br: Vec2, rect: Rect, anAffineTransform: AffineTransform): void; + resetRestitution(): void; } - /** A base node for CCNode, it will: - - maintain scene hierarchy and active logic - - notifications if some properties changed - - define some interfaces shares between CCNode - - define machanisms for Enity Component Systems - - define prefab and serialize functions */ - export class _BaseNode extends Object implements EventTarget { - /** !#en Name of node. - !#zh 该节点å称。 */ - name: string; - /** !#en The uuid for editor, will be stripped before building project. - !#zh 主è¦ç”¨äºŽç¼–辑器的 uuid,在编辑器下å¯ç”¨äºŽæŒä¹…化å˜å‚¨ï¼Œåœ¨é¡¹ç›®æž„建之åŽå°†å˜æˆè‡ªå¢žçš„ id。 */ - uuid: string; - /** !#en All children nodes. - !#zh 节点的所有å节点。 */ - children: Node[]; - /** !#en All children nodes. - !#zh 节点的å节点数é‡ã€‚ */ - childrenCount: number; + /** !#en + Physics manager uses box2d as the inner physics system, and hide most box2d implement details(creating rigidbody, synchronize rigidbody info to node). + You can visit some common box2d function through physics manager(hit testing, raycast, debug info). + Physics manager distributes the collision information to each collision callback when collision is produced. + Note: You need first enable the collision listener in the rigidbody. + !#zh + 物ç†ç³»ç»Ÿå°† box2d 作为内部物ç†ç³»ç»Ÿï¼Œå¹¶ä¸”éšè—了大部分 box2d å®žçŽ°ç»†èŠ‚ï¼ˆæ¯”å¦‚åˆ›å»ºåˆšä½“ï¼ŒåŒæ¥åˆšä½“ä¿¡æ¯åˆ°èŠ‚ç‚¹ä¸ç‰ï¼‰ã€‚ + ä½ å¯ä»¥é€šè¿‡ç‰©ç†ç³»ç»Ÿè®¿é—®ä¸€äº› box2d 常用的功能,比如点击测试,射线测试,设置测试信æ¯ç‰ã€‚ + 物ç†ç³»ç»Ÿè¿˜ç®¡ç†ç¢°æ’žä¿¡æ¯çš„分å‘,她会在产生碰撞时,将碰撞信æ¯åˆ†å‘到å„个碰撞回调ä¸ã€‚ + 注æ„ï¼šä½ éœ€è¦å…ˆåœ¨åˆšä½“ä¸å¼€å¯ç¢°æ’žæŽ¥å¬æ‰ä¼šäº§ç”Ÿç›¸åº”的碰撞回调。<br> + 支æŒçš„物ç†ç³»ç»ŸæŒ‡å®šç»˜åˆ¶ä¿¡æ¯äº‹ä»¶ï¼Œè¯·å‚阅 {{#crossLink "PhysicsManager.DrawBits"}}{{/crossLink}} */ + export class PhysicsManager implements EventTarget { /** !#en - The local active state of this node.<br/> - Note that a Node may be inactive because a parent is not active, even if this returns true.<br/> - Use {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}} if you want to check if the Node is actually treated as active in the scene. + The ratio transform between physics unit and pixel unit, generally is 32. !#zh - 当å‰èŠ‚ç‚¹çš„è‡ªèº«æ¿€æ´»çŠ¶æ€ã€‚<br/> - 值得注æ„的是,一个节点的父节点如果ä¸è¢«æ¿€æ´»ï¼Œé‚£ä¹ˆå³ä½¿å®ƒè‡ªèº«è®¾ä¸ºæ¿€æ´»ï¼Œå®ƒä»ç„¶æ— 法激活。<br/> - å¦‚æžœä½ æƒ³æ£€æŸ¥èŠ‚ç‚¹åœ¨åœºæ™¯ä¸å®žé™…的激活状æ€å¯ä»¥ä½¿ç”¨ {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}}。 */ - active: boolean; - /** !#en Indicates whether this node is active in the scene. - !#zh 表示æ¤èŠ‚ç‚¹æ˜¯å¦åœ¨åœºæ™¯ä¸æ¿€æ´»ã€‚ */ - activeInHierarchy: boolean; - /** - - @param name name - */ - constructor(name?: string); - /** !#en The parent of the node. - !#zh 该节点的父节点。 */ - parent: Node; + 物ç†å•ä½ä¸Žåƒç´ å•ä½äº’相转æ¢çš„æ¯”率,一般是 32。 */ + static PTM_RATIO: number; + /** !#en + The velocity iterations for the velocity constraint solver. + !#zh + 速度更新è¿ä»£æ•° */ + static VELOCITY_ITERATIONS: number; + /** !#en + The position Iterations for the position constraint solver. + !#zh + ä½ç½®è¿ä»£æ›´æ–°æ•° */ + static POSITION_ITERATIONS: number; + /** !#en + Specify the fixed time step. + Need enabledAccumulator to make it work. + !#zh + æŒ‡å®šå›ºå®šçš„ç‰©ç†æ›´æ–°é—´é𔿗¶é—´ï¼Œéœ€è¦å¼€å¯ enabledAccumulator æ‰æœ‰æ•ˆã€‚ */ + static FIXED_TIME_STEP: number; + /** !#en + Specify the max accumulator time. + Need enabledAccumulator to make it work. + !#zh + æ¯æ¬¡å¯ç”¨äºŽæ›´æ–°ç‰©ç†ç³»ç»Ÿçš„æœ€å¤§æ—¶é—´ï¼Œéœ€è¦å¼€å¯ enabledAccumulator æ‰æœ‰æ•ˆã€‚ */ + static MAX_ACCUMULATOR: number; + /** !#en + If enabled accumulator, then will call step function with the fixed time step FIXED_TIME_STEP. + And if the update dt is bigger than the time step, then will call step function several times. + If disabled accumulator, then will call step function with a time step calculated with the frame rate. + !#zh + å¦‚æžœå¼€å¯æ¤é€‰é¡¹ï¼Œé‚£ä¹ˆå°†ä¼šä»¥å›ºå®šçš„间隔时间 FIXED_TIME_STEP æ¥æ›´æ–°ç‰©ç†å¼•擎,如果一个 update 的间隔时间大于 FIXED_TIME_STEP,则会对物ç†å¼•擎进行多次更新。 + å¦‚æžœå…³é—æ¤é€‰é¡¹ï¼Œé‚£ä¹ˆå°†ä¼šæ ¹æ®è®¾å®šçš„ frame rate è®¡ç®—å‡ºä¸€ä¸ªé—´éš”æ—¶é—´æ¥æ›´æ–°ç‰©ç†å¼•擎。 */ + enabledAccumulator: boolean; /** - !#en Get parent of the node. - !#zh 获å–该节点的父节点。 - - @example - ```js - var parent = this.node.getParent(); - ``` + !#en + Test which collider contains the given world point + !#zh + 获å–包å«ç»™å®šä¸–ç•Œåæ ‡ç³»ç‚¹çš„碰撞体 + @param point the world point */ - getParent(): Node; + testPoint(point: Vec2): PhysicsCollider; /** - !#en Set parent of the node. - !#zh 设置该节点的父节点。 - @param value value - - @example - ```js - node.setParent(newNode); - ``` + !#en + Test which colliders intersect the given world rect + !#zh + 获å–ä¸Žç»™å®šä¸–ç•Œåæ ‡ç³»çŸ©å½¢ç›¸äº¤çš„碰撞体 + @param rect the world rect */ - setParent(value: Node): void; + testAABB(rect: Rect): PhysicsCollider[]; /** !#en - Properties configuration function <br/> - All properties in attrs will be set to the node, <br/> - when the setter of the node is available, <br/> - the property will be set via setter function.<br/> - !#zh 属性é…置函数。在 attrs 的所有属性将被设置为节点属性。 - @param attrs Properties to be set to node - - @example - ```js - var attrs = { key: 0, num: 100 }; - node.attr(attrs); - ``` + Raycast the world for all colliders in the path of the ray. + The raycast ignores colliders that contain the starting point. + !#zh + 检测哪些碰撞体在给定射线的路径上,射线检测将忽略包å«èµ·å§‹ç‚¹çš„碰撞体。 + @param p1 start point of the raycast + @param p2 end point of the raycast + @param type optional, default is RayCastType.Closest */ - attr(attrs: any): void; + rayCast(p1: Vec2, p2: Vec2, type: RayCastType): PhysicsRayCastResult[]; + /** !#en + Enabled the physics manager? + !#zh + 指定是å¦å¯ç”¨ç‰©ç†ç³»ç»Ÿï¼Ÿ */ + enabled: boolean; + /** !#en + Debug draw flags. + !#zh + è®¾ç½®è°ƒè¯•ç»˜åˆ¶æ ‡å¿— */ + debugDrawFlags: number; + /** !#en + The physics world gravity. + !#zh + 物ç†ä¸–界é‡åЛ值 */ + gravity: Vec2; /** - !#en Returns a child from the container given its uuid. - !#zh 通过 uuid 获å–节点的å节点。 - @param uuid The uuid to find the child node. - - @example - ```js - var child = node.getChildByUuid(uuid); - ``` + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh æ£€æŸ¥äº‹ä»¶ç›®æ ‡å¯¹è±¡æ˜¯å¦æœ‰ä¸ºç‰¹å®šç±»åž‹çš„事件注册的回调。 + @param type The type of event. */ - getChildByUuid(uuid: string): Node; + hasEventListener(type: string): boolean; /** - !#en Returns a child from the container given its name. - !#zh 通过å称获å–节点的å节点。 - @param name A name to find the child node. + !#en + Register an callback of a specific event type on the EventTarget. + This type of event should be triggered via `emit`. + !#zh + æ³¨å†Œäº‹ä»¶ç›®æ ‡çš„ç‰¹å®šäº‹ä»¶ç±»åž‹å›žè°ƒã€‚è¿™ç§ç±»åž‹çš„事件应该被 `emit` 触å‘。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null @example ```js - var child = node.getChildByName("Test Node"); + eventTarget.on('fire', function () { + cc.log("fire in the hole"); + }, node); ``` */ - getChildByName(name: string): Node; + on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T; /** !#en - Inserts a child to the node at a specified index. + Removes the listeners previously registered with the same type, callback, target and or useCapture, + if only type is passed as parameter, all listeners registered with that type will be removed. !#zh - æ’å…¥å节点到指定ä½ç½® - @param child the child node to be inserted - @param siblingIndex the sibling index to place the child in + åˆ é™¤ä¹‹å‰ç”¨åŒç±»åž‹ï¼Œå›žè°ƒï¼Œç›®æ ‡æˆ– useCapture 注册的事件监å¬å™¨ï¼Œå¦‚æžœåªä¼ 递 typeï¼Œå°†ä¼šåˆ é™¤ type 类型的所有事件监å¬å™¨ã€‚ + @param type A string representing the event type being removed. + @param callback The callback to remove. + @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed @example ```js - node.insertChild(child, 2); + // 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'); ``` */ - insertChild(child: Node, siblingIndex: number): void; + off(type: string, callback?: Function, target?: any): void; /** - !#en Get the sibling index. - !#zh 获å–åŒçº§ç´¢å¼•。 - - @example - ```js - var index = node.getSiblingIndex(); - ``` + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh åœ¨å½“å‰ EventTarget ä¸Šåˆ é™¤æŒ‡å®šç›®æ ‡ï¼ˆtarget 傿•°ï¼‰æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ + è¿™ä¸ªå‡½æ•°æ— æ³•åˆ é™¤å½“å‰ EventTarget 的所有事件监å¬å™¨ï¼Œä¹Ÿæ— æ³•åˆ é™¤ target 傿•°æ‰€æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ + 这个函数åªèƒ½åˆ 除 target 傿•°åœ¨å½“å‰ EventTarget 上注册的所有事件监å¬å™¨ã€‚ + @param target The target to be searched for all related listeners */ - getSiblingIndex(): number; + targetOff(target: any): void; /** - !#en Set the sibling index of this node. - !#zh 设置节点åŒçº§ç´¢å¼•。 - @param index index + !#en + Register an callback of a specific event type on the EventTarget, + the callback will remove itself after the first time it is triggered. + !#zh + æ³¨å†Œäº‹ä»¶ç›®æ ‡çš„ç‰¹å®šäº‹ä»¶ç±»åž‹å›žè°ƒï¼Œå›žè°ƒä¼šåœ¨ç¬¬ä¸€æ—¶é—´è¢«è§¦å‘åŽåˆ 除自身。 + @param type A string representing the event type to listen for. + @param callback The callback that will be invoked when the event is dispatched. + The callback is ignored if it is a duplicate (the callbacks are unique). + @param target The target (this object) to invoke the callback, can be null @example ```js - node.setSiblingIndex(1); + eventTarget.once('fire', function () { + cc.log("this is the callback and will be invoked only once"); + }, node); ``` */ - setSiblingIndex(index: number): void; + once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; /** - !#en Walk though the sub children tree of the current node. - Each node, including the current node, in the sub tree will be visited two times, before all children and after all children. - This function call is not recursive, it's based on stack. - Please don't walk any other node inside the walk process. - !#zh éåŽ†è¯¥èŠ‚ç‚¹çš„åæ ‘里的所有节点并按规则执行回调函数。 - å¯¹åæ ‘ä¸çš„æ‰€æœ‰èŠ‚ç‚¹ï¼ŒåŒ…å«å½“å‰èŠ‚ç‚¹ï¼Œä¼šæ‰§è¡Œä¸¤æ¬¡å›žè°ƒï¼Œprefunc 会在访问它的å节点之å‰è°ƒç”¨ï¼Œpostfunc 会在访问所有å节点之åŽè°ƒç”¨ã€‚ - è¿™ä¸ªå‡½æ•°çš„å®žçŽ°ä¸æ˜¯åŸºäºŽé€’å½’çš„ï¼Œè€Œæ˜¯åŸºäºŽæ ˆå±•å¼€é€’å½’çš„æ–¹å¼ã€‚ - 请ä¸è¦åœ¨ walk 过程ä¸å¯¹ä»»ä½•其他的节点嵌套执行 walk。 - @param prefunc The callback to process node when reach the node for the first time - @param postfunc The callback to process node when re-visit the node after walked all children in its sub tree - - @example - ```js - node.walk(function (target) { - console.log('Walked through node ' + target.name + ' for the first time'); - }, function (target) { - console.log('Walked through node ' + target.name + ' after walked all children in its sub tree'); - }); - ``` + !#en + Send an event with the event object. + !#zh + 通过事件对象派å‘事件 + @param event event */ - walk(prefunc: (target: _BaseNode) => void, postfunc: (target: _BaseNode) => void): void; + dispatchEvent(event: Event): void; /** !#en - Remove itself from its parent node. If cleanup is `true`, then also remove all events and actions. <br/> - If the cleanup parameter is not passed, it will force a cleanup, so it is recommended that you always pass in the `false` parameter when calling this API.<br/> - If the node orphan, then nothing happens. + Destroy all callbackInfos. !#zh - 从父节点ä¸åˆ 除该节点。如果ä¸ä¼ å…¥ cleanup 傿•°æˆ–è€…ä¼ å…¥ `true`,那么这个节点上所有绑定的事件ã€action éƒ½ä¼šè¢«åˆ é™¤ã€‚<br/> - å› æ¤å»ºè®®è°ƒç”¨è¿™ä¸ª API æ—¶æ€»æ˜¯ä¼ å…¥ `false` 傿•°ã€‚<br/> - 如果这个节点是一个å¤èŠ‚ç‚¹ï¼Œé‚£ä¹ˆä»€ä¹ˆéƒ½ä¸ä¼šå‘生。 - @param cleanup true if all actions and callbacks on this node should be removed, false otherwise. - - @example - ```js - node.removeFromParent(); - node.removeFromParent(false); - ``` + 销æ¯è®°å½•的事件 */ - removeFromParent(cleanup?: boolean): void; + clear(): void; + } + /** undefined */ + export class PhysicsRayCastResult { + /** !#en + The PhysicsCollider which intersects with the raycast + !#zh + 与射线相交的碰撞体 */ + collider: PhysicsCollider; + /** !#en + The intersection point + !#zh + 射线与碰撞体相交的点 */ + point: Vec2; + /** !#en + The normal vector at the point of intersection + !#zh + 射线与碰撞体相交的点的法å‘é‡ */ + normal: Vec2; + /** !#en + The fraction of the raycast path at the point of intersection + !#zh + 射线与碰撞体相交的点å 射线长度的分数 */ + fraction: number; + } + /** !#en Enum for RigidBodyType. + !#zh 刚体类型 */ + export enum RigidBodyType { + Static = 0, + Kinematic = 0, + Dynamic = 0, + Animated = 0, + } + /** !#en Enum for RayCastType. + !#zh 射线检测类型 */ + export enum RayCastType { + Closest = 0, + Any = 0, + AllClosest = 0, + All = 0, + } + /** undefined */ + export class RigidBody extends Component { + /** !#en + Should enabled contact listener? + When a collision is trigger, the collision callback will only be called when enabled contact listener. + !#zh + 是å¦å¯ç”¨æŽ¥è§¦æŽ¥å¬å™¨ã€‚ + 当 collider äº§ç”Ÿç¢°æ’žæ—¶ï¼Œåªæœ‰å¼€å¯äº†æŽ¥è§¦æŽ¥å¬å™¨æ‰ä¼šè°ƒç”¨ç›¸åº”的回调函数 */ + enabledContactListener: boolean; /** !#en - Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter. </p> - If the cleanup parameter is not passed, it will force a cleanup. <br/> - "remove" logic MUST only be on this method <br/> - If a class wants to extend the 'removeChild' behavior it only needs <br/> - to override this method. + Collision callback. + Called when two collider begin to touch. !#zh - ç§»é™¤èŠ‚ç‚¹ä¸æŒ‡å®šçš„å节点,是å¦éœ€è¦æ¸…ç†æ‰€æœ‰æ£åœ¨è¿è¡Œçš„行为å–决于 cleanup 傿•°ã€‚<br/> - 如果 cleanup 傿•°ä¸ä¼ 入,默认为 true 表示清ç†ã€‚<br/> - @param child The child node which will be removed. - @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise. - - @example - ```js - node.removeChild(newNode); - node.removeChild(newNode, false); - ``` + 碰撞回调。 + å¦‚æžœä½ çš„è„šæœ¬ä¸å®žçŽ°äº†è¿™ä¸ªå‡½æ•°ï¼Œé‚£ä¹ˆå®ƒå°†ä¼šåœ¨ä¸¤ä¸ªç¢°æ’žä½“å¼€å§‹æŽ¥è§¦æ—¶è¢«è°ƒç”¨ã€‚ + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody */ - removeChild(child: Node, cleanup?: boolean): void; + onBeginContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; /** !#en - Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter. <br/> - If the cleanup parameter is not passed, it will force a cleanup. + Collision callback. + Called when two collider cease to touch. !#zh - 移除节点所有的å节点,是å¦éœ€è¦æ¸…ç†æ‰€æœ‰æ£åœ¨è¿è¡Œçš„行为å–决于 cleanup 傿•°ã€‚<br/> - 如果 cleanup 傿•°ä¸ä¼ 入,默认为 true 表示清ç†ã€‚ - @param cleanup true if all running actions on all children nodes should be cleanup, false otherwise. - - @example - ```js - node.removeAllChildren(); - node.removeAllChildren(false); - ``` + 碰撞回调。 + å¦‚æžœä½ çš„è„šæœ¬ä¸å®žçŽ°äº†è¿™ä¸ªå‡½æ•°ï¼Œé‚£ä¹ˆå®ƒå°†ä¼šåœ¨ä¸¤ä¸ªç¢°æ’žä½“åœæ¢æŽ¥è§¦æ—¶è¢«è°ƒç”¨ã€‚ + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody */ - removeAllChildren(cleanup?: boolean): void; + onEndContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + This is called when a contact is updated. + This allows you to inspect a contact before it goes to the solver(e.g. disable contact). + Note: this is called only for awake bodies. + Note: this is called even when the number of contact points is zero. + Note: this is not called for sensors. + !#zh + 碰撞回调。 + å¦‚æžœä½ çš„è„šæœ¬ä¸å®žçŽ°äº†è¿™ä¸ªå‡½æ•°ï¼Œé‚£ä¹ˆå®ƒå°†ä¼šåœ¨æŽ¥è§¦æ›´æ–°æ—¶è¢«è°ƒç”¨ã€‚ + ä½ å¯ä»¥åœ¨æŽ¥è§¦è¢«å¤„ç†å‰æ ¹æ®ä»–包å«çš„ä¿¡æ¯ä½œå‡ºç›¸åº”的处ç†ï¼Œæ¯”如将这个接触ç¦ç”¨æŽ‰ã€‚ + 注æ„:回调åªä¼šä¸ºé†’ç€çš„刚体调用。 + 注æ„:接触点为零的时候也有å¯èƒ½è¢«è°ƒç”¨ã€‚ + 注æ„:感知体(sensor)的回调ä¸ä¼šè¢«è°ƒç”¨ã€‚ + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onPreSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** + !#en + Collision callback. + This is called after a contact is updated. + You can get the impulses from the contact in this callback. + !#zh + 碰撞回调。 + å¦‚æžœä½ çš„è„šæœ¬ä¸å®žçŽ°äº†è¿™ä¸ªå‡½æ•°ï¼Œé‚£ä¹ˆå®ƒå°†ä¼šåœ¨æŽ¥è§¦æ›´æ–°å®ŒåŽè¢«è°ƒç”¨ã€‚ + ä½ å¯ä»¥åœ¨è¿™ä¸ªå›žè°ƒä¸ä»ŽæŽ¥è§¦ä¿¡æ¯ä¸èŽ·å–到冲é‡ä¿¡æ¯ã€‚ + @param contact contact information + @param selfCollider the collider belong to this rigidbody + @param otherCollider the collider belong to another rigidbody + */ + onPostSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void; + /** !#en + Is this a fast moving body that should be prevented from tunneling through + other moving bodies? + Note : + - All bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies. + - You should use this flag sparingly since it increases processing time. + !#zh + è¿™ä¸ªåˆšä½“æ˜¯å¦æ˜¯ä¸€ä¸ªå¿«é€Ÿç§»åŠ¨çš„åˆšä½“ï¼Œå¹¶ä¸”éœ€è¦ç¦æ¢ç©¿è¿‡å…¶ä»–快速移动的刚体? + éœ€è¦æ³¨æ„的是 : + - æ‰€æœ‰åˆšä½“éƒ½è¢«ç¦æ¢ä»Ž è¿åŠ¨åˆšä½“ å’Œ 陿€åˆšä½“ ä¸ç©¿è¿‡ã€‚æ¤é€‰é¡¹åªå…³æ³¨äºŽ 动æ€åˆšä½“。 + - 应该尽é‡å°‘的使用æ¤é€‰é¡¹ï¼Œå› ä¸ºå®ƒä¼šå¢žåŠ ç¨‹åºå¤„ç†æ—¶é—´ã€‚ */ + bullet: boolean; + /** !#en + Rigidbody type : Static, Kinematic, Dynamic or Animated. + !#zh + 刚体类型: Static, Kinematic, Dynamic or Animated. */ + type: RigidBodyType; + /** !#en + Set this flag to false if this body should never fall asleep. + Note that this increases CPU usage. + !#zh + 如果æ¤åˆšä½“永远都ä¸åº”该进入ç¡çœ ,那么设置这个属性为 false。 + éœ€è¦æ³¨æ„这将使 CPU å 用率æé«˜ã€‚ */ + allowSleep: boolean; + /** !#en + Scale the gravity applied to this body. + !#zh + 缩放应用在æ¤åˆšä½“上的é‡åЛ值 */ + gravityScale: number; + /** !#en + Linear damping is use to reduce the linear velocity. + The damping parameter can be larger than 1, but the damping effect becomes sensitive to the + time step when the damping parameter is large. + !#zh + Linear damping 用于衰å‡åˆšä½“的线性速度。衰å‡ç³»æ•°å¯ä»¥å¤§äºŽ 1,但是当衰å‡ç³»æ•°æ¯”较大的时候,衰å‡çš„æ•ˆæžœä¼šå˜å¾—æ¯”è¾ƒæ•æ„Ÿã€‚ */ + linearDamping: number; + /** !#en + Angular damping is use to reduce the angular velocity. The damping parameter + can be larger than 1 but the damping effect becomes sensitive to the + time step when the damping parameter is large. + !#zh + Angular damping 用于衰å‡åˆšä½“的角速度。衰å‡ç³»æ•°å¯ä»¥å¤§äºŽ 1,但是当衰å‡ç³»æ•°æ¯”较大的时候,衰å‡çš„æ•ˆæžœä¼šå˜å¾—æ¯”è¾ƒæ•æ„Ÿã€‚ */ + angularDamping: number; + /** !#en + The linear velocity of the body's origin in world co-ordinates. + !#zh + åˆšä½“åœ¨ä¸–ç•Œåæ ‡ä¸‹çš„线性速度 */ + linearVelocity: Vec2; + /** !#en + The angular velocity of the body. + !#zh + 刚体的角速度 */ + angularVelocity: number; + /** !#en + Should this body be prevented from rotating? + !#zh + 是å¦ç¦æ¢æ¤åˆšä½“进行旋转 */ + fixedRotation: boolean; + /** !#en + Set the sleep state of the body. A sleeping body has very low CPU cost.(When the rigid body is hit, if the rigid body is in sleep state, it will be immediately awakened.) + !#zh + 设置刚体的ç¡çœ 状æ€ã€‚ ç¡çœ 的刚体具有éžå¸¸ä½Žçš„ CPU æˆæœ¬ã€‚(当刚体被碰撞到时,如果刚体处于ç¡çœ 状æ€ï¼Œå®ƒä¼šç«‹å³è¢«å”¤é†’) */ + awake: boolean; + /** !#en + Whether to wake up this rigid body during initialization + !#zh + 是å¦åœ¨åˆå§‹åŒ–时唤醒æ¤åˆšä½“ */ + awakeOnLoad: boolean; + /** !#en + Set the active state of the body. An inactive body is not + simulated and cannot be collided with or woken up. + If body is active, all fixtures will be added to the + broad-phase. + If body is inactive, all fixtures will be removed from + the broad-phase and all contacts will be destroyed. + Fixtures on an inactive body are implicitly inactive and will + not participate in collisions, ray-casts, or queries. + Joints connected to an inactive body are implicitly inactive. + !#zh + 设置刚体的激活状æ€ã€‚ä¸€ä¸ªéžæ¿€æ´»çжæ€ä¸‹çš„刚体是ä¸ä¼šè¢«æ¨¡æ‹Ÿå’Œç¢°æ’žçš„,ä¸ç®¡å®ƒæ˜¯å¦å¤„于ç¡çœ 状æ€ä¸‹ã€‚ + 如果刚体处于激活状æ€ä¸‹ï¼Œæ‰€æœ‰å¤¹å…·ä¼šè¢«æ·»åŠ åˆ° 粗测阶段(broad-phase)。 + å¦‚æžœåˆšä½“å¤„äºŽéžæ¿€æ´»çжæ€ä¸‹ï¼Œæ‰€æœ‰å¤¹å…·ä¼šè¢«ä»Ž 粗测阶段(broad-phase)ä¸ç§»é™¤ã€‚ + åœ¨éžæ¿€æ´»çжæ€ä¸‹çš„夹具ä¸ä¼šå‚ä¸Žåˆ°ç¢°æ’žï¼Œå°„çº¿ï¼Œæˆ–è€…æŸ¥æ‰¾ä¸ + é“¾æŽ¥åˆ°éžæ¿€æ´»çжæ€ä¸‹åˆšä½“çš„å…³èŠ‚ä¹Ÿæ˜¯éžæ¿€æ´»çš„。 */ + active: boolean; /** - !#en Is this node a child of the given node? - !#zh æ˜¯å¦æ˜¯æŒ‡å®šèŠ‚ç‚¹çš„å节点? - @param parent parent - - @example - ```js - node.isChildOf(newNode); - ``` + !#en + Converts a given point in the world coordinate system to this rigid body's local coordinate system + !#zh + å°†ä¸€ä¸ªç»™å®šçš„ä¸–ç•Œåæ ‡ç³»ä¸‹çš„点转æ¢ä¸ºåˆšä½“æœ¬åœ°åæ ‡ç³»ä¸‹çš„点 + @param worldPoint a point in world coordinates. + @param out optional, the receiving point */ - isChildOf(parent: Node): boolean; + getLocalPoint(worldPoint: Vec2, out: Vec2): Vec2; /** !#en - Returns the component of supplied type if the node has one attached, null if it doesn't.<br/> - You can also get component in the node by passing in the name of the script. + Converts a given point in this rigid body's local coordinate system to the world coordinate system !#zh - 获å–èŠ‚ç‚¹ä¸ŠæŒ‡å®šç±»åž‹çš„ç»„ä»¶ï¼Œå¦‚æžœèŠ‚ç‚¹æœ‰é™„åŠ æŒ‡å®šç±»åž‹çš„ç»„ä»¶ï¼Œåˆ™è¿”å›žï¼Œå¦‚æžœæ²¡æœ‰åˆ™ä¸ºç©ºã€‚<br/> - ä¼ å…¥å‚æ•°ä¹Ÿå¯ä»¥æ˜¯è„šæœ¬çš„å称。 - @param typeOrClassName typeOrClassName - - @example - ```js - // get sprite component - var sprite = node.getComponent(cc.Sprite); - // get custom test class - var test = node.getComponent("Test"); - ``` + å°†ä¸€ä¸ªç»™å®šçš„åˆšä½“æœ¬åœ°åæ ‡ç³»ä¸‹çš„点转æ¢ä¸ºä¸–ç•Œåæ ‡ç³»ä¸‹çš„点 + @param localPoint a point in local coordinates. + @param out optional, the receiving point */ - getComponent<T extends Component>(type: {prototype: T}): T; - getComponent(className: string): any; + getWorldPoint(localPoint: Vec2, out: Vec2): Vec2; /** - !#en Returns all components of supplied type in the node. - !#zh 返回节点上指定类型的所有组件。 - @param typeOrClassName typeOrClassName - - @example - ```js - var sprites = node.getComponents(cc.Sprite); - var tests = node.getComponents("Test"); - ``` + !#en + Converts a given vector in this rigid body's local coordinate system to the world coordinate system + !#zh + å°†ä¸€ä¸ªç»™å®šçš„åˆšä½“æœ¬åœ°åæ ‡ç³»ä¸‹çš„å‘é‡è½¬æ¢ä¸ºä¸–ç•Œåæ ‡ç³»ä¸‹çš„å‘é‡ + @param localVector a vector in world coordinates. + @param out optional, the receiving vector */ - getComponents<T extends Component>(type: {prototype: T}): T[]; - getComponents(className: string): any[]; + getWorldVector(localVector: Vec2, out: Vec2): Vec2; /** - !#en Returns the component of supplied type in any of its children using depth first search. - !#zh 递归查找所有å节点ä¸ç¬¬ä¸€ä¸ªåŒ¹é…指定类型的组件。 - @param typeOrClassName typeOrClassName - - @example - ```js - var sprite = node.getComponentInChildren(cc.Sprite); - var Test = node.getComponentInChildren("Test"); - ``` + !#en + Converts a given vector in the world coordinate system to this rigid body's local coordinate system + !#zh + å°†ä¸€ä¸ªç»™å®šçš„ä¸–ç•Œåæ ‡ç³»ä¸‹çš„å‘é‡è½¬æ¢ä¸ºåˆšä½“æœ¬åœ°åæ ‡ç³»ä¸‹çš„å‘é‡ + @param worldVector a vector in world coordinates. + @param out optional, the receiving vector */ - getComponentInChildren<T extends Component>(type: {prototype: T}): T; - getComponentInChildren(className: string): any; + getLocalVector(worldVector: Vec2, out: Vec2): Vec2; /** - !#en Returns all components of supplied type in self or any of its children. - !#zh 递归查找自身或所有åèŠ‚ç‚¹ä¸æŒ‡å®šç±»åž‹çš„组件 - @param typeOrClassName typeOrClassName - - @example - ```js - var sprites = node.getComponentsInChildren(cc.Sprite); - var tests = node.getComponentsInChildren("Test"); - ``` + !#en + Get the world body origin position. + !#zh + 获å–åˆšä½“ä¸–ç•Œåæ ‡ç³»ä¸‹çš„原点值 + @param out optional, the receiving point */ - getComponentsInChildren<T extends Component>(type: {prototype: T}): T[]; - getComponentsInChildren(className: string): any[]; + getWorldPosition(out: Vec2): Vec2; /** - !#en Adds a component class to the node. You can also add component to node by passing in the name of the script. - !#zh å‘èŠ‚ç‚¹æ·»åŠ ä¸€ä¸ªæŒ‡å®šç±»åž‹çš„ç»„ä»¶ç±»ï¼Œä½ è¿˜å¯ä»¥é€šè¿‡ä¼ 入脚本的åç§°æ¥æ·»åŠ ç»„ä»¶ã€‚ - @param typeOrClassName The constructor or the class name of the component to add - - @example - ```js - var sprite = node.addComponent(cc.Sprite); - var test = node.addComponent("Test"); - ``` + !#en + Get the world body rotation angle. + !#zh + 获å–åˆšä½“ä¸–ç•Œåæ ‡ç³»ä¸‹çš„æ—‹è½¬å€¼ã€‚ */ - addComponent<T extends Component>(type: {new(): T}): T; - addComponent(className: string): any; + getWorldRotation(): number; /** !#en - Removes a component identified by the given name or removes the component object given. - You can also use component.destroy() if you already have the reference. + Get the local position of the center of mass. !#zh - åˆ é™¤èŠ‚ç‚¹ä¸Šçš„æŒ‡å®šç»„ä»¶ï¼Œä¼ å…¥å‚æ•°å¯ä»¥æ˜¯ä¸€ä¸ªç»„ä»¶æž„é€ å‡½æ•°æˆ–ç»„ä»¶å,也å¯ä»¥æ˜¯å·²ç»èŽ·å¾—çš„ç»„ä»¶å¼•ç”¨ã€‚ - å¦‚æžœä½ å·²ç»èŽ·å¾—ç»„ä»¶å¼•ç”¨ï¼Œä½ ä¹Ÿå¯ä»¥ç›´æŽ¥è°ƒç”¨ component.destroy() - @param component The need remove component. - - @example - ```js - node.removeComponent(cc.Sprite); - var Test = require("Test"); - node.removeComponent(Test); - ``` + 获å–åˆšä½“æœ¬åœ°åæ ‡ç³»ä¸‹çš„质心 */ - removeComponent(component: string|Function|Component): void; + getLocalCenter(): Vec2; /** !#en - Destroy all children from the node, and release all their own references to other objects.<br/> - Actual destruct operation will delayed until before rendering. + Get the world position of the center of mass. !#zh - é”€æ¯æ‰€æœ‰å节点,并释放所有它们对其它对象的引用。<br/> - å®žé™…é”€æ¯æ“作会延迟到当å‰å¸§æ¸²æŸ“剿‰§è¡Œã€‚ - - @example - ```js - node.destroyAllChildren(); - ``` + 获å–åˆšä½“ä¸–ç•Œåæ ‡ç³»ä¸‹çš„质心 */ - destroyAllChildren(): void; + getWorldCenter(): Vec2; /** - !#en Checks whether the EventTarget object has any callback registered for a specific type of event. - !#zh æ£€æŸ¥äº‹ä»¶ç›®æ ‡å¯¹è±¡æ˜¯å¦æœ‰ä¸ºç‰¹å®šç±»åž‹çš„事件注册的回调。 - @param type The type of event. + !#en + Get the world linear velocity of a world point attached to this body. + !#zh + 获å–刚体上指定点的线性速度 + @param worldPoint a point in world coordinates. + @param out optional, the receiving point */ - hasEventListener(type: string): boolean; + getLinearVelocityFromWorldPoint(worldPoint: Vec2, out: Vec2): Vec2; /** !#en - Register an callback of a specific event type on the EventTarget. - This type of event should be triggered via `emit`. + Get total mass of the body. !#zh - æ³¨å†Œäº‹ä»¶ç›®æ ‡çš„ç‰¹å®šäº‹ä»¶ç±»åž‹å›žè°ƒã€‚è¿™ç§ç±»åž‹çš„事件应该被 `emit` 触å‘。 - @param type A string representing the event type to listen for. - @param callback The callback that will be invoked when the event is dispatched. - The callback is ignored if it is a duplicate (the callbacks are unique). - @param target The target (this object) to invoke the callback, can be null - - @example - ```js - eventTarget.on('fire', function () { - cc.log("fire in the hole"); - }, node); - ``` + 获å–刚体的质é‡ã€‚ */ - on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T; + getMass(): number; /** !#en - Removes the listeners previously registered with the same type, callback, target and or useCapture, - if only type is passed as parameter, all listeners registered with that type will be removed. + Get the rotational inertia of the body about the local origin. !#zh - åˆ é™¤ä¹‹å‰ç”¨åŒç±»åž‹ï¼Œå›žè°ƒï¼Œç›®æ ‡æˆ– useCapture 注册的事件监å¬å™¨ï¼Œå¦‚æžœåªä¼ 递 typeï¼Œå°†ä¼šåˆ é™¤ type 类型的所有事件监å¬å™¨ã€‚ - @param type A string representing the event type being removed. - @param callback The callback to remove. - @param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed - - @example - ```js - // 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'); - ``` + 获å–åˆšä½“æœ¬åœ°åæ ‡ç³»ä¸‹åŽŸç‚¹çš„æ—‹è½¬æƒ¯æ€§ */ - off(type: string, callback?: Function, target?: any): void; + getInertia(): number; /** - !#en Removes all callbacks previously registered with the same target (passed as parameter). - This is not for removing all listeners in the current event target, - and this is not for removing all listeners the target parameter have registered. - It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. - !#zh åœ¨å½“å‰ EventTarget ä¸Šåˆ é™¤æŒ‡å®šç›®æ ‡ï¼ˆtarget 傿•°ï¼‰æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ - è¿™ä¸ªå‡½æ•°æ— æ³•åˆ é™¤å½“å‰ EventTarget 的所有事件监å¬å™¨ï¼Œä¹Ÿæ— æ³•åˆ é™¤ target 傿•°æ‰€æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ - 这个函数åªèƒ½åˆ 除 target 傿•°åœ¨å½“å‰ EventTarget 上注册的所有事件监å¬å™¨ã€‚ - @param target The target to be searched for all related listeners + !#en + Get all the joints connect to the rigidbody. + !#zh + 获å–链接到æ¤åˆšä½“的所有关节 */ - targetOff(target: any): void; + getJointList(): Joint[]; /** !#en - Register an callback of a specific event type on the EventTarget, - the callback will remove itself after the first time it is triggered. + Apply a force at a world point. If the force is not + applied at the center of mass, it will generate a torque and + affect the angular velocity. !#zh - æ³¨å†Œäº‹ä»¶ç›®æ ‡çš„ç‰¹å®šäº‹ä»¶ç±»åž‹å›žè°ƒï¼Œå›žè°ƒä¼šåœ¨ç¬¬ä¸€æ—¶é—´è¢«è§¦å‘åŽåˆ 除自身。 - @param type A string representing the event type to listen for. - @param callback The callback that will be invoked when the event is dispatched. - The callback is ignored if it is a duplicate (the callbacks are unique). - @param target The target (this object) to invoke the callback, can be null - - @example - ```js - eventTarget.once('fire', function () { - cc.log("this is the callback and will be invoked only once"); - }, node); - ``` + æ–½åŠ ä¸€ä¸ªåŠ›åˆ°åˆšä½“ä¸Šçš„ä¸€ä¸ªç‚¹ã€‚å¦‚æžœåŠ›æ²¡æœ‰æ–½åŠ åˆ°åˆšä½“çš„è´¨å¿ƒä¸Šï¼Œè¿˜ä¼šäº§ç”Ÿä¸€ä¸ªæ‰çŸ©å¹¶ä¸”å½±å“到角速度。 + @param force the world force vector. + @param point the world position. + @param wake also wake up the body. */ - once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void; + applyForce(force: Vec2, point: Vec2, wake: boolean): void; /** !#en - Send an event with the event object. + Apply a force to the center of mass. !#zh - 通过事件对象派å‘事件 - @param event event - */ - dispatchEvent(event: Event): void; - } - /** !#en - Helper class for setting material blend function. - !#zh - 设置æè´¨æ··åˆæ¨¡å¼çš„辅助类。 */ - export class BlendFunc { - /** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost. - !#zh æŒ‡å®šåŽŸå›¾çš„æ··åˆæ¨¡å¼ï¼Œè¿™ä¼šå…‹éš†ä¸€ä¸ªæ–°çš„æè´¨å¯¹è±¡ï¼Œæ³¨æ„这带æ¥çš„开销 */ - srcBlendFactor: macro.BlendFactor; - /** !#en specify the destination Blend Factor. - !#zh æŒ‡å®šç›®æ ‡çš„æ··åˆæ¨¡å¼ */ - dstBlendFactor: macro.BlendFactor; - } - /** An internal helper class for switching render component's material between normal sprite material and gray sprite material. */ - export class GraySpriteState { - /** !#en The normal material. - !#zh æ£å¸¸çжæ€çš„æè´¨ã€‚ */ - normalMaterial: Material; - /** !#en The gray material. - !#zh ç½®ç°çжæ€çš„æè´¨ã€‚ */ - grayMaterial: Material; - } - /** misc utilities */ - export class misc { + æ–½åŠ ä¸€ä¸ªåŠ›åˆ°åˆšä½“ä¸Šçš„è´¨å¿ƒä¸Šã€‚ + @param force the world force vector. + @param wake also wake up the body. + */ + applyForceToCenter(force: Vec2, wake: boolean): void; /** - !#en Clamp a value between from and to. + !#en + Apply a torque. This affects the angular velocity. !#zh - é™å®šæµ®ç‚¹æ•°çš„æœ€å¤§æœ€å°å€¼ã€‚<br/> - 数值大于 max_inclusive 则返回 max_inclusive。<br/> - 数值å°äºŽ min_inclusive 则返回 min_inclusive。<br/> - å¦åˆ™è¿”回自身。 - @param value value - @param min_inclusive min_inclusive - @param max_inclusive max_inclusive - - @example - ```js - var v1 = cc.misc.clampf(20, 0, 20); // 20; - var v2 = cc.misc.clampf(-1, 0, 20); // 0; - var v3 = cc.misc.clampf(10, 0, 20); // 10; - ``` + æ–½åŠ ä¸€ä¸ªæ‰çŸ©åŠ›ï¼Œå°†å½±å“刚体的角速度 + @param torque about the z-axis (out of the screen), usually in N-m. + @param wake also wake up the body */ - static clampf(value: number, min_inclusive: number, max_inclusive: number): number; + applyTorque(torque: number, wake: boolean): void; /** - !#en Clamp a value between 0 and 1. - !#zh é™å®šæµ®ç‚¹æ•°çš„å–值范围为 0 ~ 1 之间。 - @param value value - - @example - ```js - var v1 = cc.misc.clamp01(20); // 1; - var v2 = cc.misc.clamp01(-1); // 0; - var v3 = cc.misc.clamp01(0.5); // 0.5; - ``` + !#en + Apply a impulse at a world point, This immediately modifies the velocity. + If the impulse is not applied at the center of mass, it will generate a torque and + affect the angular velocity. + !#zh + æ–½åŠ å†²é‡åˆ°åˆšä½“ä¸Šçš„ä¸€ä¸ªç‚¹ï¼Œå°†ç«‹å³æ”¹å˜åˆšä½“的线性速度。 + å¦‚æžœå†²é‡æ–½åŠ åˆ°çš„ç‚¹ä¸æ˜¯åˆšä½“的质心,那么将产生一个æ‰çŸ©å¹¶å½±å“刚体的角速度。 + @param impulse the world impulse vector, usually in N-seconds or kg-m/s. + @param point the world position + @param wake alse wake up the body */ - static clamp01(value: number): number; + applyLinearImpulse(impulse: Vec2, point: Vec2, wake: boolean): void; /** - Linear interpolation between 2 numbers, the ratio sets how much it is biased to each end - @param a number A - @param b number B - @param r ratio between 0 and 1 - - @example - ```js - ---- - lerp - cc.misc.lerp(2,10,0.5)//returns 6 - cc.misc.lerp(2,10,0.2)//returns 3.6 - - ``` + !#en + Apply an angular impulse. + !#zh + æ–½åŠ ä¸€ä¸ªè§’é€Ÿåº¦å†²é‡ã€‚ + @param impulse the angular impulse in units of kg*m*m/s + @param wake also wake up the body */ - static lerp(a: number, b: number, r: number): number; + applyAngularImpulse(impulse: number, wake: boolean): void; /** - converts degrees to radians - @param angle angle + !#en + Synchronize node's world position to box2d rigidbody's position. + If enableAnimated is true and rigidbody's type is Animated type, + will set linear velocity instead of directly set rigidbody's position. + !#zh + åŒæ¥èŠ‚ç‚¹çš„ä¸–ç•Œåæ ‡åˆ° box2d åˆšä½“çš„åæ ‡ä¸Šã€‚ + 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的线性速度æ¥ä»£æ›¿ç›´æŽ¥è®¾ç½®åˆšä½“çš„ä½ç½®ã€‚ + @param enableAnimated enableAnimated */ - static degreesToRadians(angle: number): number; + syncPosition(enableAnimated: boolean): void; /** - converts radians to degrees - @param angle angle + !#en + Synchronize node's world angle to box2d rigidbody's angle. + If enableAnimated is true and rigidbody's type is Animated type, + will set angular velocity instead of directly set rigidbody's angle. + !#zh + åŒæ¥èŠ‚ç‚¹çš„ä¸–ç•Œæ—‹è½¬è§’åº¦å€¼åˆ° box2d 刚体的旋转值上。 + 如果 enableAnimated 是 true,并且刚体的类型是 Animated ,那么将设置刚体的角速度æ¥ä»£æ›¿ç›´æŽ¥è®¾ç½®åˆšä½“的角度。 + @param enableAnimated enableAnimated */ - static radiansToDegrees(angle: number): number; + syncRotation(enableAnimated: boolean): void; } /** !#en Representation of RGBA colors. @@ -13097,6 +13167,11 @@ declare namespace cc { */ static lerp<Out extends IQuatLike> (out: Out, a: Out, b: Out, t: number): Out; /** + !#zh 四元数çƒé¢æ’值 + !#en Spherical quaternion interpolation + */ + static slerp<Out extends IQuatLike, QuatLike_1 extends IQuatLike, QuatLike_2 extends IQuatLike>(out: Out, a: QuatLike_1, b: QuatLike_2, t: number): Out; + /** !#zh 带两个控制点的四元数çƒé¢æ’值 !#en Quaternion with two spherical interpolation control points */ @@ -13602,7 +13677,7 @@ declare namespace cc { ```js var v = cc.v2(10, 10); v.sub(cc.v2(5, 5)); // return Vec2 {x: 5, y: 5}; - var v1; + var v1 = new Vec2; v.sub(cc.v2(5, 5), v1); // return Vec2 {x: 5, y: 5}; ``` */ @@ -13629,7 +13704,7 @@ declare namespace cc { ```js var v = cc.v2(10, 10); v.mul(5); // return Vec2 {x: 50, y: 50}; - var v1; + var v1 = new Vec2; v.mul(5, v1); // return Vec2 {x: 50, y: 50}; ``` */ @@ -13656,7 +13731,7 @@ declare namespace cc { ```js var v = cc.v2(10, 10); v.div(5); // return Vec2 {x: 2, y: 2}; - var v1; + var v1 = new Vec2; v.div(5, v1); // return Vec2 {x: 2, y: 2}; ``` */ @@ -13683,7 +13758,7 @@ declare namespace cc { ```js var v = cc.v2(10, 10); v.scale(cc.v2(5, 5)); // return Vec2 {x: 50, y: 50}; - var v1; + var v1 = new Vec2; v.scale(cc.v2(5, 5), v1); // return Vec2 {x: 50, y: 50}; ``` */ @@ -13707,7 +13782,7 @@ declare namespace cc { @example ```js var v = cc.v2(10, 10); - var v1; + var v1 = new Vec2; v.neg(v1); // return Vec2 {x: -10, y: -10}; ``` */ @@ -15074,9 +15149,42 @@ declare namespace cc { */ maxAxis(): number; } + /** !#en . + !#zh 。 */ + export class SkeletonAnimation extends Animation { + } + /** !#en SkeletonAnimationClip Asset. + !#zh 骨骼动画剪辑。 */ + export class SkeletonAnimationClip extends AnimationClip { + } + /** !#en + Skinned Mesh Renderer + !#zh + 蒙皮渲染组件 */ + export class SkinnedMeshRenderer extends MeshRenderer { + /** !#en + Skeleton Asset + !#zh + éª¨éª¼èµ„æº */ + skeleton: sp.Skeleton; + /** !#en + Root Bone + !#zh + éª¨éª¼æ ¹èŠ‚ç‚¹ */ + rootBone: Node; + } /** !#en The animation curve of 3d particle. !#zh 3D ç²’å动画曲线 */ - export class AnimationCurve { + export class AnimationCurve { + /** !#en Array of key value. + !#zh 关键值列表。 */ + keyFrames: Keyframe[]; + /** !#en Pre-wrap mode. + !#zh å‰ç½®å¾ªçŽ¯æ¨¡å¼ã€‚ */ + preWrapMode: WrapMode; + /** !#en Post-wrap mode. + !#zh åŽç½®å¾ªçŽ¯æ¨¡å¼ã€‚ */ + postWrapMode: WrapMode; } /** !#en The burst of 3d particle. !#zh 3D ç²’åå‘射时的爆å‘个数 */ @@ -15369,30 +15477,6 @@ declare namespace cc { */ static create (material: Material, owner: cc.RenderComponent): MaterialVariant | null; } - /** !#en SkeletonAnimationClip Asset. - !#zh 骨骼动画剪辑。 */ - export class SkeletonAnimationClip extends AnimationClip { - } - /** !#en . - !#zh 。 */ - export class SkeletonAnimation extends Animation { - } - /** !#en - Skinned Mesh Renderer - !#zh - 蒙皮渲染组件 */ - export class SkinnedMeshRenderer { - /** !#en - Skeleton Asset - !#zh - éª¨éª¼èµ„æº */ - skeleton: sp.Skeleton; - /** !#en - Root Bone - !#zh - éª¨éª¼æ ¹èŠ‚ç‚¹ */ - rootBone: Node; - } /** !#en cc.EditBox is a component for inputing text, you can use it to gather small amounts of text from users. !#zh EditBox 组件,用于获å–用户的输入文本。 */ export class EditBox extends Component { @@ -15726,7 +15810,7 @@ declare namespace cc { Note : generally mouse joint only used in test bed. !#zh é¼ æ ‡å…³èŠ‚ç”¨äºŽä½¿åˆšä½“ä¸Šçš„ä¸€ä¸ªç‚¹è¿½è¸ªä¸€ä¸ªæŒ‡å®šçš„ä¸–ç•Œåæ ‡ç³»ä¸‹çš„ä½ç½®ã€‚ - é¼ æ ‡å…³èŠ‚å¯ä»¥æŒ‡å®šä¸€ä¸ªæœ€å¤§çš„é‡Œæ¥æ–½åŠ ä¸€ä¸ªæŸ”å’Œçš„çº¦æŸã€‚ + é¼ æ ‡å…³èŠ‚å¯ä»¥æŒ‡å®šä¸€ä¸ªæœ€å¤§çš„åŠ›æ¥æ–½åŠ ä¸€ä¸ªæŸ”å’Œçš„çº¦æŸã€‚ é¼ æ ‡å…³èŠ‚ä¼šè‡ªåŠ¨ä½¿ç”¨ mouse region èŠ‚ç‚¹æ¥æ³¨å†Œé¼ æ ‡äº‹ä»¶ï¼Œå¹¶ä¸”åœ¨è§¦æ‘¸ç§»åŠ¨äº‹ä»¶ä¸ç§»åЍ选ä¸çš„刚体。 注æ„ï¼šä¸€èˆ¬é¼ æ ‡å…³èŠ‚åªåœ¨æµ‹è¯•环境ä¸ä½¿ç”¨ã€‚ */ export class MouseJoint extends Joint { @@ -16086,182 +16170,122 @@ declare namespace cc { @param maxDistance Maximum detection distance @param queryTrigger Detect trigger or not */ - raycast(worldRay: geomUtils.Ray, groupIndexOrName: number|string, maxDistance: number, queryTrigger: boolean): PhysicsRayResult[]; - /** - !#en Detect all collision boxes and return the detection result with the shortest ray distance. If not, return null value. Note that the return value is taken from the object pool, so do not save the result reference or modify the result. - !#zh 检测所有的碰撞盒,并返回射线è·ç¦»æœ€çŸçš„æ£€æµ‹ç»“果,若没有,则返回空值。注æ„è¿”å›žå€¼æ˜¯ä»Žå¯¹è±¡æ± ä¸å–的,所以请ä¸è¦ä¿å˜ç»“果引用或者修改结果。 - @param worldRay A ray in world space - @param groupIndexOrName Collision group index or group name - @param maxDistance Maximum detection distance - @param queryTrigger Detect trigger or not - */ - raycastClosest(worldRay: geomUtils.Ray, groupIndexOrName: number|string, maxDistance: number, queryTrigger: boolean): PhysicsRayResult; - } - /** !#en - Used to store physical ray detection results - !#zh - 用于ä¿å˜ç‰©ç†å°„线检测结果 */ - export class PhysicsRayResult { - /** !#en - Hit the point - !#zh - 击ä¸ç‚¹ */ - hitPoint: Vec3; - /** !#en - Distance - !#zh - è·ç¦» */ - distance: number; - /** !#en - Hit the collision box - !#zh - 击ä¸çš„碰撞盒 */ - collider: Collider3D; - /** - !#en - Set up ray. This method is used internally by the engine. Do not call it from an external script - !#zh - è®¾ç½®å°„çº¿ï¼Œæ¤æ–¹æ³•由引擎内部使用,请勿在外部脚本调用 - @param hitPoint hitPoint - @param distance distance - @param collider collider - */ - _assign(hitPoint: Vec3, distance: number, collider: Collider3D): void; - /** - !#en - Clone - !#zh - 克隆 - */ - clone(): void; - } - /** Rigid body interface */ - export class IRigidBody { - rigidBody: RigidBody3D; - mass: number; - linearDamping: number; - angularDamping: number; - isKinematic: boolean; - useGravity: boolean; - fixedRotation: boolean; - linearFactor: IVec3Like; - angularFactor: IVec3Like; - allowSleep: boolean; - isAwake: boolean; - isSleepy: boolean; - isSleeping: boolean; - wakeUp(): void; - sleep(): void; - /** - - @param out out - */ - getLinearVelocity(out: IVec3Like): void; - /** - - @param out out - */ - setLinearVelocity(out: IVec3Like): void; - /** - - @param out out - */ - getAngularVelocity(out: IVec3Like): void; - /** - - @param out out - */ - setAngularVelocity(out: IVec3Like): void; - /** - - @param force force - @param relativePoint relativePoint - */ - applyForce(force: IVec3Like, relativePoint: IVec3Like): void; - /** - - @param force force - @param relativePoint relativePoint - */ - applyLocalForce(force: IVec3Like, relativePoint: IVec3Like): void; - /** - - @param force force - @param relativePoint relativePoint - */ - applyImpulse(force: IVec3Like, relativePoint: IVec3Like): void; - /** - - @param force force - @param relativePoint relativePoint - */ - applyLocalImpulse(force: IVec3Like, relativePoint: IVec3Like): void; - /** - - @param torque torque - */ - applyTorque(torque: IVec3Like): void; + raycast(worldRay: geomUtils.Ray, groupIndexOrName: number|string, maxDistance: number, queryTrigger: boolean): PhysicsRayResult[]; /** - - @param torque torque + !#en Detect all collision boxes and return the detection result with the shortest ray distance. If not, return null value. Note that the return value is taken from the object pool, so do not save the result reference or modify the result. + !#zh 检测所有的碰撞盒,并返回射线è·ç¦»æœ€çŸçš„æ£€æµ‹ç»“果,若没有,则返回空值。注æ„è¿”å›žå€¼æ˜¯ä»Žå¯¹è±¡æ± ä¸å–的,所以请ä¸è¦ä¿å˜ç»“果引用或者修改结果。 + @param worldRay A ray in world space + @param groupIndexOrName Collision group index or group name + @param maxDistance Maximum detection distance + @param queryTrigger Detect trigger or not */ - applyLocalTorque(torque: IVec3Like): void; - } - /** Class has x y z properties */ - export class IVec3Like { - x: number; - y: number; - z: number; - } - /** Class has x y z w properties */ - export class IQuatLike { - x: number; - y: number; - z: number; - w: number; + raycastClosest(worldRay: geomUtils.Ray, groupIndexOrName: number|string, maxDistance: number, queryTrigger: boolean): PhysicsRayResult; } - /** !#en Base shape interface. */ - export class IBaseShape { + /** !#en + Used to store physical ray detection results + !#zh + 用于ä¿å˜ç‰©ç†å°„线检测结果 */ + export class PhysicsRayResult { + /** !#en + Hit the point + !#zh + 击ä¸ç‚¹ */ + hitPoint: Vec3; + /** !#en + Distance + !#zh + è·ç¦» */ + distance: number; + /** !#en + Hit the collision box + !#zh + 击ä¸çš„碰撞盒 */ collider: Collider3D; - attachedRigidBody: RigidBody3D|void; - material: any; - isTrigger: boolean; - center: IVec3Like; - } - /** !#en box shape interface */ - export class IBoxShape { - size: IVec3Like; - } - /** !#en Sphere shape interface */ - export class ISphereShape { - radius: number; - } - /** Ray cast options */ - export class IRaycastOptions { - groupIndex: number; - queryTrigger: boolean; - maxDistance: number; - } - /** Collision detect */ - export class ICollisionDetect { /** - Ray cast, and return information of the closest hit. - @param worldRay worldRay - @param options options - @param out out + !#en + Set up ray. This method is used internally by the engine. Do not call it from an external script + !#zh + è®¾ç½®å°„çº¿ï¼Œæ¤æ–¹æ³•由引擎内部使用,请勿在外部脚本调用 + @param hitPoint hitPoint + @param distance distance + @param collider collider */ - raycastClosest(worldRay: geomUtils.Ray, options: IRaycastOptions, out: PhysicsRayResult): boolean; + _assign(hitPoint: Vec3, distance: number, collider: Collider3D): void; /** - Ray cast against all bodies. The provided callback will be executed for each hit with a RaycastResult as single argument. - @param worldRay worldRay - @param options options - @param pool pool - @param resultes resultes + !#en + Clone + !#zh + 克隆 */ - raycast(worldRay: geomUtils.Ray, options: IRaycastOptions, pool: RecyclePool, resultes: PhysicsRayResult[]): boolean; + clone(): void; } - /** Physics world interface */ - export class IPhysicsWorld { + /** !#en The shape module of 3d particle. + !#zh 3D ç²’åçš„å‘å°„å½¢çŠ¶æ¨¡å— */ + export class ShapeModule { + /** !#en The enable of shapeModule. + !#zh 是å¦å¯ç”¨ */ + enable: boolean; + /** !#en Particle emitter type. + !#zh ç²’åå‘射器类型。 */ + shapeType: shapeModule.ShapeType; + /** !#en The emission site of the particle. + !#zh ç²’å从å‘射器哪个部ä½å‘射。 */ + emitFrom: shapeModule.EmitLocation; + /** !#en Particle emitter radius. + !#zh ç²’åå‘射器åŠå¾„。 */ + radius: number; + /** !#en Particle emitter emission position (not valid for Box type emitters):<bg> + - 0 means emitted from the surface; + - 1 means launch from the center; + - 0 ~ 1 indicates emission from the center to the surface. + !#zh ç²’åå‘射器å‘å°„ä½ç½®ï¼ˆå¯¹ Box 类型的å‘å°„å™¨æ— æ•ˆï¼‰ï¼š<bg> + - 0 表示从表é¢å‘å°„ï¼› + - 1 表示从ä¸å¿ƒå‘å°„ï¼› + - 0 ~ 1 之间表示在ä¸å¿ƒåˆ°è¡¨é¢ä¹‹é—´å‘射。 */ + radiusThickness: number; + /** !#en The angle between the axis of the cone and the generatrix<bg> + Determines the opening and closing of the cone launcher + !#zh 圆锥的轴与æ¯çº¿çš„夹角<bg>。 + 决定圆锥å‘射器的开åˆç¨‹åº¦ã€‚ */ + angle: number; + /** !#en Particle emitters emit in a fan-shaped range. + !#zh ç²’åå‘射器在一个扇形范围内å‘射。 */ + arc: number; + /** !#en How particles are emitted in the sector range. + !#zh ç²’å在扇形范围内的å‘å°„æ–¹å¼ã€‚ */ + arcMode: shapeModule.ArcMode; + /** !#en Controls the discrete intervals around the arcs where particles might be generated. + !#zh 控制å¯èƒ½äº§ç”Ÿç²’å的弧周围的离散间隔。 */ + arcSpread: number; + /** !#en The speed at which particles are emitted around the circumference. + !#zh ç²’åæ²¿åœ†å‘¨å‘射的速度。 */ + arcSpeed: CurveRange; + /** !#en Axis length from top of cone to bottom of cone <bg>. + Determines the height of the cone emitter. + !#zh 圆锥顶部截é¢è·ç¦»åº•部的轴长<bg>。 + 决定圆锥å‘射器的高度。 */ + length: number; + /** !#en Particle emitter emission location (for box-type particle emitters). + !#zh ç²’åå‘射器å‘å°„ä½ç½®ï¼ˆé’ˆå¯¹ Box 类型的粒åå‘射器。 */ + boxThickness: Vec3; + /** !#en Particle Emitter Position + !#zh ç²’åå‘射器ä½ç½®ã€‚ */ + position: Vec3; + /** !#en Particle emitter rotation angle. + !#zh ç²’åå‘射器旋转角度。 */ + rotation: Vec3; + /** !#en Particle emitter scaling + !#zh ç²’åå‘射器缩放比例。 */ + scale: Vec3; + /** !#en The direction of particle movement is determined based on the initial direction of the particles. + !#zh æ ¹æ®ç²’åçš„åˆå§‹æ–¹å‘决定粒å的移动方å‘。 */ + alignToDirection: boolean; + /** !#en Set particle generation direction randomly. + !#zh ç²’åç”Ÿæˆæ–¹å‘éšæœºè®¾å®šã€‚ */ + randomDirectionAmount: number; + /** !#en Interpolation between the current emission direction and the direction from the current position to the center of the node. + !#zh 表示当å‰å‘å°„æ–¹å‘与当å‰ä½ç½®åˆ°ç»“点ä¸å¿ƒè¿žçº¿æ–¹å‘çš„æ’值。 */ + sphericalDirectionAmount: number; } /** !#en The color over time module of 3d particle. !#zh 3D ç²’å颜色å˜åŒ–æ¨¡å— */ @@ -16275,7 +16299,7 @@ declare namespace cc { export class CurveRange { /** !#en Curve type. !#zh 曲线类型。 */ - mode: ParticleSystem.EmitterMode; + mode: debug.DebugMode; /** !#en The curve to use when mode is Curve. !#zh 当 mode 为 Curve 时,使用的曲线。 */ curve: AnimationCurve; @@ -16322,7 +16346,7 @@ declare namespace cc { export class GradientRange { /** !#en Gradient type. !#zh æ¸å˜è‰²ç±»åž‹ã€‚ */ - mode: ParticleSystem.EmitterMode; + mode: debug.DebugMode; /** !#en The color when mode is Color. !#zh 当 mode 为 Color 时的颜色。 */ color: Color; @@ -16344,15 +16368,36 @@ declare namespace cc { } /** !#en The color key of gradient. !#zh color 关键帧 */ - export class ColorKey { + export class ColorKey { + /** !#en Color value. + !#zh 颜色值。 */ + color: Color; + /** !#en Time value. + !#zh 时间值。 */ + time: number; } /** !#en The alpha key of gradient. !#zh alpha 关键帧 */ - export class AlphaKey { + export class AlphaKey { + /** !#en Alpha value. + !#zh 逿˜Žåº¦ã€‚ */ + alpha: number; + /** !#en Time. + !#zh 时间帧。 */ + time: number; } /** !#en The gradient data of color. !#zh 颜色æ¸å˜æ•°æ® */ - export class Gradient { + export class Gradient { + /** !#en Array of color key. + !#zh 颜色关键帧列表。 */ + colorKeys: ColorKey[]; + /** !#en Array of alpha key. + !#zh 逿˜Žåº¦å…³é”®å¸§åˆ—表。 */ + alphaKeys: AlphaKey[]; + /** !#en Blend mode. + !#zh æ··åˆæ¨¡å¼ã€‚ */ + mode: debug.DebugMode; } /** !#en The limit velocity module of 3d particle. !#zh 3D ç²’åçš„é™é€Ÿæ¨¡å— */ @@ -16435,7 +16480,7 @@ declare namespace cc { enable: boolean; /** !#en Set the type of particle map animation (only supports Grid mode for the time being) !#zh 设定粒åè´´å›¾åŠ¨ç”»çš„ç±»åž‹ï¼ˆæš‚åªæ”¯æŒ Grid 模å¼ã€‚ */ - mode: ParticleSystem.EmitterMode; + mode: debug.DebugMode; /** !#en Animation frames in X direction. !#zh X æ–¹å‘动画帧数。 */ numTilesX: number; @@ -16487,73 +16532,133 @@ declare namespace cc { !#zh 速度修æ£ç³»æ•°ï¼ˆåªæ”¯æŒ CPU ç²’å)。 */ speedModifier: CurveRange; } - /** !#en The shape module of 3d particle. - !#zh 3D ç²’åçš„å‘å°„å½¢çŠ¶æ¨¡å— */ - export class ShapeModule { - /** !#en The enable of shapeModule. - !#zh 是å¦å¯ç”¨ */ - enable: boolean; - /** !#en Particle emitter type. - !#zh ç²’åå‘射器类型。 */ - shapeType: shapeModule.ShapeType; - /** !#en The emission site of the particle. - !#zh ç²’å从å‘射器哪个部ä½å‘射。 */ - emitFrom: shapeModule.EmitLocation; - /** !#en Particle emitter radius. - !#zh ç²’åå‘射器åŠå¾„。 */ - radius: number; - /** !#en Particle emitter emission position (not valid for Box type emitters):<bg> - - 0 means emitted from the surface; - - 1 means launch from the center; - - 0 ~ 1 indicates emission from the center to the surface. - !#zh ç²’åå‘射器å‘å°„ä½ç½®ï¼ˆå¯¹ Box 类型的å‘å°„å™¨æ— æ•ˆï¼‰ï¼š<bg> - - 0 表示从表é¢å‘å°„ï¼› - - 1 表示从ä¸å¿ƒå‘å°„ï¼› - - 0 ~ 1 之间表示在ä¸å¿ƒåˆ°è¡¨é¢ä¹‹é—´å‘射。 */ - radiusThickness: number; - /** !#en The angle between the axis of the cone and the generatrix<bg> - Determines the opening and closing of the cone launcher - !#zh 圆锥的轴与æ¯çº¿çš„夹角<bg>。 - 决定圆锥å‘射器的开åˆç¨‹åº¦ã€‚ */ - angle: number; - /** !#en Particle emitters emit in a fan-shaped range. - !#zh ç²’åå‘射器在一个扇形范围内å‘射。 */ - arc: number; - /** !#en How particles are emitted in the sector range. - !#zh ç²’å在扇形范围内的å‘å°„æ–¹å¼ã€‚ */ - arcMode: shapeModule.ArcMode; - /** !#en Controls the discrete intervals around the arcs where particles might be generated. - !#zh 控制å¯èƒ½äº§ç”Ÿç²’å的弧周围的离散间隔。 */ - arcSpread: number; - /** !#en The speed at which particles are emitted around the circumference. - !#zh ç²’åæ²¿åœ†å‘¨å‘射的速度。 */ - arcSpeed: CurveRange; - /** !#en Axis length from top of cone to bottom of cone <bg>. - Determines the height of the cone emitter. - !#zh 圆锥顶部截é¢è·ç¦»åº•部的轴长<bg>。 - 决定圆锥å‘射器的高度。 */ - length: number; - /** !#en Particle emitter emission location (for box-type particle emitters). - !#zh ç²’åå‘射器å‘å°„ä½ç½®ï¼ˆé’ˆå¯¹ Box 类型的粒åå‘射器。 */ - boxThickness: Vec3; - /** !#en Particle Emitter Position - !#zh ç²’åå‘射器ä½ç½®ã€‚ */ - position: Vec3; - /** !#en Particle emitter rotation angle. - !#zh ç²’åå‘射器旋转角度。 */ - rotation: Vec3; - /** !#en Particle emitter scaling - !#zh ç²’åå‘射器缩放比例。 */ - scale: Vec3; - /** !#en The direction of particle movement is determined based on the initial direction of the particles. - !#zh æ ¹æ®ç²’åçš„åˆå§‹æ–¹å‘决定粒å的移动方å‘。 */ - alignToDirection: boolean; - /** !#en Set particle generation direction randomly. - !#zh ç²’åç”Ÿæˆæ–¹å‘éšæœºè®¾å®šã€‚ */ - randomDirectionAmount: number; - /** !#en Interpolation between the current emission direction and the direction from the current position to the center of the node. - !#zh 表示当å‰å‘å°„æ–¹å‘与当å‰ä½ç½®åˆ°ç»“点ä¸å¿ƒè¿žçº¿æ–¹å‘çš„æ’值。 */ - sphericalDirectionAmount: number; + /** Rigid body interface */ + export class IRigidBody { + rigidBody: RigidBody3D; + mass: number; + linearDamping: number; + angularDamping: number; + isKinematic: boolean; + useGravity: boolean; + fixedRotation: boolean; + linearFactor: IVec3Like; + angularFactor: IVec3Like; + allowSleep: boolean; + isAwake: boolean; + isSleepy: boolean; + isSleeping: boolean; + wakeUp(): void; + sleep(): void; + /** + + @param out out + */ + getLinearVelocity(out: IVec3Like): void; + /** + + @param out out + */ + setLinearVelocity(out: IVec3Like): void; + /** + + @param out out + */ + getAngularVelocity(out: IVec3Like): void; + /** + + @param out out + */ + setAngularVelocity(out: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyForce(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyLocalForce(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyImpulse(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param force force + @param relativePoint relativePoint + */ + applyLocalImpulse(force: IVec3Like, relativePoint: IVec3Like): void; + /** + + @param torque torque + */ + applyTorque(torque: IVec3Like): void; + /** + + @param torque torque + */ + applyLocalTorque(torque: IVec3Like): void; + } + /** Class has x y z properties */ + export class IVec3Like { + x: number; + y: number; + z: number; + } + /** Class has x y z w properties */ + export class IQuatLike { + x: number; + y: number; + z: number; + w: number; + } + /** !#en Base shape interface. */ + export class IBaseShape { + collider: Collider3D; + attachedRigidBody: RigidBody3D|void; + material: any; + isTrigger: boolean; + center: IVec3Like; + } + /** !#en box shape interface */ + export class IBoxShape { + size: IVec3Like; + } + /** !#en Sphere shape interface */ + export class ISphereShape { + radius: number; + } + /** Ray cast options */ + export class IRaycastOptions { + groupIndex: number; + queryTrigger: boolean; + maxDistance: number; + } + /** Collision detect */ + export class ICollisionDetect { + /** + Ray cast, and return information of the closest hit. + @param worldRay worldRay + @param options options + @param out out + */ + raycastClosest(worldRay: geomUtils.Ray, options: IRaycastOptions, out: PhysicsRayResult): boolean; + /** + Ray cast against all bodies. The provided callback will be executed for each hit with a RaycastResult as single argument. + @param worldRay worldRay + @param options options + @param pool pool + @param resultes resultes + */ + raycast(worldRay: geomUtils.Ray, options: IRaycastOptions, pool: RecyclePool, resultes: PhysicsRayResult[]): boolean; + } + /** Physics world interface */ + export class IPhysicsWorld { } /** !#en The trail module of 3d particle. !#zh 3D ç²’åæ‹–å°¾æ¨¡å— */ @@ -16604,6 +16709,9 @@ declare namespace cc { /** !#en The maximum number of atlas that can be created. !#zh å¯ä»¥åˆ›å»ºçš„æœ€å¤§å›¾é›†æ•°é‡ã€‚ */ maxAtlasCount: number; + /** !#en Get the current created atlas count. + !#zh 获å–当å‰å·²ç»åˆ›å»ºçš„图集数é‡ã€‚ */ + atlasCount: number; /** !#en Is enable textureBleeding. !#zh 是å¦å¼€å¯ textureBleeding */ textureBleeding: boolean; @@ -16944,163 +17052,51 @@ declare namespace cc { ``` */ once(type: string, callback: (event: ITriggerEvent|ICollisionEvent) => void, target?: any): void; - /** - !#en Checks whether the EventTarget object has any callback registered for a specific type of event. - !#zh æ£€æŸ¥äº‹ä»¶ç›®æ ‡å¯¹è±¡æ˜¯å¦æœ‰ä¸ºç‰¹å®šç±»åž‹çš„事件注册的回调。 - @param type The type of event. - */ - hasEventListener(type: string): boolean; - /** - !#en Removes all callbacks previously registered with the same target (passed as parameter). - This is not for removing all listeners in the current event target, - and this is not for removing all listeners the target parameter have registered. - It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. - !#zh åœ¨å½“å‰ EventTarget ä¸Šåˆ é™¤æŒ‡å®šç›®æ ‡ï¼ˆtarget 傿•°ï¼‰æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ - è¿™ä¸ªå‡½æ•°æ— æ³•åˆ é™¤å½“å‰ EventTarget 的所有事件监å¬å™¨ï¼Œä¹Ÿæ— æ³•åˆ é™¤ target 傿•°æ‰€æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ - 这个函数åªèƒ½åˆ 除 target 傿•°åœ¨å½“å‰ EventTarget 上注册的所有事件监å¬å™¨ã€‚ - @param target The target to be searched for all related listeners - */ - targetOff(target: any): void; - /** - !#en - Send an event with the event object. - !#zh - 通过事件对象派å‘事件 - @param event event - */ - dispatchEvent(event: Event): void; - } - /** !#en - Physics sphere collider - !#zh - 物ç†çƒç¢°æ’žå™¨ */ - export class SphereCollider3D extends Collider3D { - /** !#en - Get or set the radius of the sphere. - !#zh - èŽ·å–æˆ–设置çƒçš„åŠå¾„。 */ - radius: number; - sphereShape: ISphereShape; - } - /**************************************************** - * TiledMap - *****************************************************/ - - export namespace TiledMap { - /** !#en The orientation of tiled map. - !#zh Tiled Map 地图方å‘。 */ - export enum Orientation { - ORTHO = 0, - HEX = 0, - ISO = 0, - } - } - - /**************************************************** - * TiledMap - *****************************************************/ - - export namespace TiledMap { - /** The property type of tiled map. */ - export enum Property { - NONE = 0, - MAP = 0, - LAYER = 0, - OBJECTGROUP = 0, - OBJECT = 0, - TILE = 0, - } - } - - /**************************************************** - * TiledMap - *****************************************************/ - - export namespace TiledMap { - /** The tile flags of tiled map. */ - export enum TileFlag { - HORIZONTAL = 0, - VERTICAL = 0, - DIAGONAL = 0, - FLIPPED_ALL = 0, - FLIPPED_MASK = 0, - } - } - - /**************************************************** - * TiledMap - *****************************************************/ - - export namespace TiledMap { - /** !#en The stagger axis of Hex tiled map. - !#zh å…边形地图的 stagger axis 值 */ - export enum StaggerAxis { - STAGGERAXIS_X = 0, - STAGGERAXIS_Y = 0, - } - } - - /**************************************************** - * TiledMap - *****************************************************/ - - export namespace TiledMap { - /** !#en The render order of tiled map. - !#zh åœ°å›¾çš„æ¸²æŸ“é¡ºåº */ - export enum RenderOrder { - STAGGERINDEX_ODD = 0, - STAGGERINDEX_EVEN = 0, - RightDown = 0, - RightUp = 0, - LeftDown = 0, - LeftUp = 0, - } - } - - /**************************************************** - * TiledMap - *****************************************************/ - - export namespace TiledMap { - /** !#en TiledMap Object Type - !#zh 地图物体类型 */ - export enum TMXObjectType { - RECT = 0, - ELLIPSE = 0, - POLYGON = 0, - POLYLINE = 0, - IMAGE = 0, - TEXT = 0, - } - } - - /**************************************************** - * ParticleSystem - *****************************************************/ - - export namespace ParticleSystem { - /** !#en Enum for emitter modes - !#zh å‘å°„æ¨¡å¼ */ - export enum EmitterMode { - GRAVITY = 0, - RADIUS = 0, - } - } - - /**************************************************** - * ParticleSystem - *****************************************************/ - - export namespace ParticleSystem { - /** !#en Enum for particles movement type. - !#zh ç²’åä½ç½®ç±»åž‹ */ - export enum PositionType { - FREE = 0, - RELATIVE = 0, - GROUPED = 0, - } - } - + /** + !#en Checks whether the EventTarget object has any callback registered for a specific type of event. + !#zh æ£€æŸ¥äº‹ä»¶ç›®æ ‡å¯¹è±¡æ˜¯å¦æœ‰ä¸ºç‰¹å®šç±»åž‹çš„事件注册的回调。 + @param type The type of event. + */ + hasEventListener(type: string): boolean; + /** + !#en Removes all callbacks previously registered with the same target (passed as parameter). + This is not for removing all listeners in the current event target, + and this is not for removing all listeners the target parameter have registered. + It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter. + !#zh åœ¨å½“å‰ EventTarget ä¸Šåˆ é™¤æŒ‡å®šç›®æ ‡ï¼ˆtarget 傿•°ï¼‰æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ + è¿™ä¸ªå‡½æ•°æ— æ³•åˆ é™¤å½“å‰ EventTarget 的所有事件监å¬å™¨ï¼Œä¹Ÿæ— æ³•åˆ é™¤ target 傿•°æ‰€æ³¨å†Œçš„æ‰€æœ‰äº‹ä»¶ç›‘å¬å™¨ã€‚ + 这个函数åªèƒ½åˆ 除 target 傿•°åœ¨å½“å‰ EventTarget 上注册的所有事件监å¬å™¨ã€‚ + @param target The target to be searched for all related listeners + */ + targetOff(target: any): void; + /** + !#en + Send an event with the event object. + !#zh + 通过事件对象派å‘事件 + @param event event + */ + dispatchEvent(event: Event): void; + /** + !#en + Destroy all callbackInfos. + !#zh + 销æ¯è®°å½•的事件 + */ + clear(): void; + } + /** !#en + Physics sphere collider + !#zh + 物ç†çƒç¢°æ’žå™¨ */ + export class SphereCollider3D extends Collider3D { + /** !#en + Get or set the radius of the sphere. + !#zh + èŽ·å–æˆ–设置çƒçš„åŠå¾„。 */ + radius: number; + sphereShape: ISphereShape; + } /**************************************************** * audioEngine *****************************************************/ @@ -17117,51 +17113,6 @@ declare namespace cc { } } - /**************************************************** - * WebView - *****************************************************/ - - export namespace WebView { - /** !#en WebView event type - !#zh 网页视图事件类型 */ - export enum EventType { - LOADED = 0, - LOADING = 0, - ERROR = 0, - } - } - - /**************************************************** - * VideoPlayer - *****************************************************/ - - export namespace VideoPlayer { - /** !#en Video event type - !#zh 视频事件类型 */ - export enum EventType { - PLAYING = 0, - PAUSED = 0, - STOPPED = 0, - COMPLETED = 0, - META_LOADED = 0, - CLICKED = 0, - READY_TO_PLAY = 0, - } - } - - /**************************************************** - * VideoPlayer - *****************************************************/ - - export namespace VideoPlayer { - /** !#en Enum for video resouce type type. - !#zh è§†é¢‘æ¥æº */ - export enum ResourceType { - REMOTE = 0, - LOCAL = 0, - } - } - /**************************************************** * debug *****************************************************/ @@ -17243,1427 +17194,708 @@ declare namespace cc { /** !#en The event type for mouse up events, you can use its value directly: 'mouseup' !#zh å½“é¼ æ ‡ä»ŽæŒ‰ä¸‹çŠ¶æ€æ¾å¼€æ—¶è§¦å‘一次。 */ static MOUSE_UP: string; - /** !#en The event type for mouse wheel events, you can use its value directly: 'mousewheel' - !#zh å½“é¼ æ ‡æ»šè½®æ»šåŠ¨æ—¶ã€‚ */ - static MOUSE_WHEEL: string; - /** !#en The event type for position change events. - Performance note, this event will be triggered every time corresponding properties being changed, - if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. - !#zh 当节点ä½ç½®æ”¹å˜æ—¶è§¦å‘的事件。 - 性能è¦å‘Šï¼šè¿™ä¸ªäº‹ä»¶ä¼šåœ¨æ¯æ¬¡å¯¹åº”的属性被修改时触å‘,如果事件回调æŸè€—较高,有å¯èƒ½å¯¹æ€§èƒ½æœ‰å¾ˆå¤§çš„è´Ÿé¢å½±å“,请尽é‡é¿å…è¿™ç§æƒ…况。 */ - static POSITION_CHANGED: string; - /** !#en The event type for rotation change events. - Performance note, this event will be triggered every time corresponding properties being changed, - if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. - !#zh å½“èŠ‚ç‚¹æ—‹è½¬æ”¹å˜æ—¶è§¦å‘的事件。 - 性能è¦å‘Šï¼šè¿™ä¸ªäº‹ä»¶ä¼šåœ¨æ¯æ¬¡å¯¹åº”的属性被修改时触å‘,如果事件回调æŸè€—较高,有å¯èƒ½å¯¹æ€§èƒ½æœ‰å¾ˆå¤§çš„è´Ÿé¢å½±å“,请尽é‡é¿å…è¿™ç§æƒ…况。 */ - static ROTATION_CHANGED: string; - /** !#en The event type for scale change events. - Performance note, this event will be triggered every time corresponding properties being changed, - if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. - !#zh å½“èŠ‚ç‚¹ç¼©æ”¾æ”¹å˜æ—¶è§¦å‘的事件。 - 性能è¦å‘Šï¼šè¿™ä¸ªäº‹ä»¶ä¼šåœ¨æ¯æ¬¡å¯¹åº”的属性被修改时触å‘,如果事件回调æŸè€—较高,有å¯èƒ½å¯¹æ€§èƒ½æœ‰å¾ˆå¤§çš„è´Ÿé¢å½±å“,请尽é‡é¿å…è¿™ç§æƒ…况。 */ - static SCALE_CHANGED: string; - /** !#en The event type for size change events. - Performance note, this event will be triggered every time corresponding properties being changed, - if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. - !#zh å½“èŠ‚ç‚¹å°ºå¯¸æ”¹å˜æ—¶è§¦å‘的事件。 - 性能è¦å‘Šï¼šè¿™ä¸ªäº‹ä»¶ä¼šåœ¨æ¯æ¬¡å¯¹åº”的属性被修改时触å‘,如果事件回调æŸè€—较高,有å¯èƒ½å¯¹æ€§èƒ½æœ‰å¾ˆå¤§çš„è´Ÿé¢å½±å“,请尽é‡é¿å…è¿™ç§æƒ…况。 */ - static SIZE_CHANGED: string; - /** !#en The event type for anchor point change events. - Performance note, this event will be triggered every time corresponding properties being changed, - if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. - !#zh å½“èŠ‚ç‚¹é”šç‚¹æ”¹å˜æ—¶è§¦å‘的事件。 - 性能è¦å‘Šï¼šè¿™ä¸ªäº‹ä»¶ä¼šåœ¨æ¯æ¬¡å¯¹åº”的属性被修改时触å‘,如果事件回调æŸè€—较高,有å¯èƒ½å¯¹æ€§èƒ½æœ‰å¾ˆå¤§çš„è´Ÿé¢å½±å“,请尽é‡é¿å…è¿™ç§æƒ…况。 */ - static ANCHOR_CHANGED: string; - /** !#en The event type for color change events. - Performance note, this event will be triggered every time corresponding properties being changed, - if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. - !#zh å½“èŠ‚ç‚¹é¢œè‰²æ”¹å˜æ—¶è§¦å‘的事件。 - 性能è¦å‘Šï¼šè¿™ä¸ªäº‹ä»¶ä¼šåœ¨æ¯æ¬¡å¯¹åº”的属性被修改时触å‘,如果事件回调æŸè€—较高,有å¯èƒ½å¯¹æ€§èƒ½æœ‰å¾ˆå¤§çš„è´Ÿé¢å½±å“,请尽é‡é¿å…è¿™ç§æƒ…况。 */ - static COLOR_CHANGED: string; - /** !#en The event type for new child added events. - !#zh 当新的åèŠ‚ç‚¹è¢«æ·»åŠ æ—¶è§¦å‘的事件。 */ - static CHILD_ADDED: string; - /** !#en The event type for child removed events. - !#zh 当å节点被移除时触å‘的事件。 */ - static CHILD_REMOVED: string; - /** !#en The event type for children reorder events. - !#zh 当åèŠ‚ç‚¹é¡ºåºæ”¹å˜æ—¶è§¦å‘的事件。 */ - static CHILD_REORDER: string; - /** !#en The event type for node group changed events. - !#zh 当节点归属群组å‘生å˜åŒ–时触å‘的事件。 */ - static GROUP_CHANGED: string; - /** !#en The event type for node's sibling order changed. - !#zh 当节点在兄弟节点ä¸çš„顺åºå‘生å˜åŒ–时触å‘的事件。 */ - static SIBLING_ORDER_CHANGED: string; - } - } - - /**************************************************** - * Light - *****************************************************/ - - export namespace Light { - /** !#en The light source type - - !#zh å…‰æºç±»åž‹ */ - export enum Type { - DIRECTIONAL = 0, - POINT = 0, - SPOT = 0, - AMBIENT = 0, - } - } - - /**************************************************** - * Light - *****************************************************/ - - export namespace Light { - /** !#en The shadow type - - !#zh 阴影类型 */ - export enum ShadowType { - NONE = 0, - HARD = 0, - SOFT_PCF3X3 = 0, - SOFT_PCF5X5 = 0, - } - } - - /**************************************************** - * Collider - *****************************************************/ - - export namespace Collider { - /** !#en Defines a Box Collider . - !#zh 用æ¥å®šä¹‰åŒ…围盒碰撞体 */ - export class Box { - /** !#en Position offset - !#zh ä½ç½®åç§»é‡ */ - offset: Vec2; - /** !#en Box size - !#zh åŒ…å›´ç›’å¤§å° */ - size: Size; - } - } - - /**************************************************** - * Collider - *****************************************************/ - - export namespace Collider { - /** !#en Defines a Circle Collider . - !#zh 用æ¥å®šä¹‰åœ†å½¢ç¢°æ’žä½“ */ - export class Circle { - /** !#en Position offset - !#zh ä½ç½®åç§»é‡ */ - offset: Vec2; - /** !#en Circle radius - !#zh 圆形åŠå¾„ */ - radius: number; - } - } - - /**************************************************** - * Collider - *****************************************************/ - - export namespace Collider { - /** !#en Defines a Polygon Collider . - !#zh 用æ¥å®šä¹‰å¤šè¾¹å½¢ç¢°æ’žä½“ */ - export class Polygon { - /** !#en Position offset - !#zh ä½ç½®åç§»é‡ */ - offset: Vec2; - /** !#en Polygon points - !#zh 多边形顶点数组 */ - points: Vec2[]; - } - } - - /**************************************************** - * Prefab - *****************************************************/ - - export namespace Prefab { - /** !#zh - Prefab 创建实例所用的优化ç–略,é…åˆ {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}} 使用。 - !#en - An enumeration used with the {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}} - to specify how to optimize the instantiate operation. */ - export enum OptimizationPolicy { - AUTO = 0, - SINGLE_INSTANCE = 0, - MULTI_INSTANCE = 0, - } - } - - /**************************************************** - * RenderTexture - *****************************************************/ - - export namespace RenderTexture { - /** !#en The depth buffer and stencil buffer format for RenderTexture. - !#zh RenderTexture çš„æ·±åº¦ç¼“å†²ä»¥åŠæ¨¡æ¿ç¼“å†²æ ¼å¼ã€‚ */ - export enum DepthStencilFormat { - RB_FMT_D24S8 = 0, - RB_FMT_S8 = 0, - RB_FMT_D16 = 0, + /** !#en The event type for mouse wheel events, you can use its value directly: 'mousewheel' + !#zh å½“é¼ æ ‡æ»šè½®æ»šåŠ¨æ—¶ã€‚ */ + static MOUSE_WHEEL: string; + /** !#en The event type for position change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh 当节点ä½ç½®æ”¹å˜æ—¶è§¦å‘的事件。 + 性能è¦å‘Šï¼šè¿™ä¸ªäº‹ä»¶ä¼šåœ¨æ¯æ¬¡å¯¹åº”的属性被修改时触å‘,如果事件回调æŸè€—较高,有å¯èƒ½å¯¹æ€§èƒ½æœ‰å¾ˆå¤§çš„è´Ÿé¢å½±å“,请尽é‡é¿å…è¿™ç§æƒ…况。 */ + static POSITION_CHANGED: string; + /** !#en The event type for rotation change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh å½“èŠ‚ç‚¹æ—‹è½¬æ”¹å˜æ—¶è§¦å‘的事件。 + 性能è¦å‘Šï¼šè¿™ä¸ªäº‹ä»¶ä¼šåœ¨æ¯æ¬¡å¯¹åº”的属性被修改时触å‘,如果事件回调æŸè€—较高,有å¯èƒ½å¯¹æ€§èƒ½æœ‰å¾ˆå¤§çš„è´Ÿé¢å½±å“,请尽é‡é¿å…è¿™ç§æƒ…况。 */ + static ROTATION_CHANGED: string; + /** !#en The event type for scale change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh å½“èŠ‚ç‚¹ç¼©æ”¾æ”¹å˜æ—¶è§¦å‘的事件。 + 性能è¦å‘Šï¼šè¿™ä¸ªäº‹ä»¶ä¼šåœ¨æ¯æ¬¡å¯¹åº”的属性被修改时触å‘,如果事件回调æŸè€—较高,有å¯èƒ½å¯¹æ€§èƒ½æœ‰å¾ˆå¤§çš„è´Ÿé¢å½±å“,请尽é‡é¿å…è¿™ç§æƒ…况。 */ + static SCALE_CHANGED: string; + /** !#en The event type for size change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh å½“èŠ‚ç‚¹å°ºå¯¸æ”¹å˜æ—¶è§¦å‘的事件。 + 性能è¦å‘Šï¼šè¿™ä¸ªäº‹ä»¶ä¼šåœ¨æ¯æ¬¡å¯¹åº”的属性被修改时触å‘,如果事件回调æŸè€—较高,有å¯èƒ½å¯¹æ€§èƒ½æœ‰å¾ˆå¤§çš„è´Ÿé¢å½±å“,请尽é‡é¿å…è¿™ç§æƒ…况。 */ + static SIZE_CHANGED: string; + /** !#en The event type for anchor point change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh å½“èŠ‚ç‚¹é”šç‚¹æ”¹å˜æ—¶è§¦å‘的事件。 + 性能è¦å‘Šï¼šè¿™ä¸ªäº‹ä»¶ä¼šåœ¨æ¯æ¬¡å¯¹åº”的属性被修改时触å‘,如果事件回调æŸè€—较高,有å¯èƒ½å¯¹æ€§èƒ½æœ‰å¾ˆå¤§çš„è´Ÿé¢å½±å“,请尽é‡é¿å…è¿™ç§æƒ…况。 */ + static ANCHOR_CHANGED: string; + /** !#en The event type for color change events. + Performance note, this event will be triggered every time corresponding properties being changed, + if the event callback have heavy logic it may have great performance impact, try to avoid such scenario. + !#zh å½“èŠ‚ç‚¹é¢œè‰²æ”¹å˜æ—¶è§¦å‘的事件。 + 性能è¦å‘Šï¼šè¿™ä¸ªäº‹ä»¶ä¼šåœ¨æ¯æ¬¡å¯¹åº”的属性被修改时触å‘,如果事件回调æŸè€—较高,有å¯èƒ½å¯¹æ€§èƒ½æœ‰å¾ˆå¤§çš„è´Ÿé¢å½±å“,请尽é‡é¿å…è¿™ç§æƒ…况。 */ + static COLOR_CHANGED: string; + /** !#en The event type for new child added events. + !#zh 当新的åèŠ‚ç‚¹è¢«æ·»åŠ æ—¶è§¦å‘的事件。 */ + static CHILD_ADDED: string; + /** !#en The event type for child removed events. + !#zh 当å节点被移除时触å‘的事件。 */ + static CHILD_REMOVED: string; + /** !#en The event type for children reorder events. + !#zh 当åèŠ‚ç‚¹é¡ºåºæ”¹å˜æ—¶è§¦å‘的事件。 */ + static CHILD_REORDER: string; + /** !#en The event type for node group changed events. + !#zh 当节点归属群组å‘生å˜åŒ–时触å‘的事件。 */ + static GROUP_CHANGED: string; + /** !#en The event type for node's sibling order changed. + !#zh 当节点在兄弟节点ä¸çš„顺åºå‘生å˜åŒ–时触å‘的事件。 */ + static SIBLING_ORDER_CHANGED: string; } } /**************************************************** - * Texture2D + * VideoPlayer *****************************************************/ - export namespace Texture2D { - /** The texture pixel format, default value is RGBA8888, - you should note that textures loaded by normal image files (png, jpg) can only support RGBA8888 format, - other formats are supported by compressed file types or raw data. */ - export enum PixelFormat { - RGB565 = 0, - RGB5A1 = 0, - RGBA4444 = 0, - RGB888 = 0, - RGBA8888 = 0, - RGBA32F = 0, - A8 = 0, - I8 = 0, - AI88 = 0, - RGB_PVRTC_2BPPV1 = 0, - RGBA_PVRTC_2BPPV1 = 0, - RGB_A_PVRTC_2BPPV1 = 0, - RGB_PVRTC_4BPPV1 = 0, - RGBA_PVRTC_4BPPV1 = 0, - RGB_A_PVRTC_4BPPV1 = 0, - RGB_ETC1 = 0, - RGBA_ETC1 = 0, - RGB_ETC2 = 0, - RGBA_ETC2 = 0, + export namespace VideoPlayer { + /** !#en Video event type + !#zh 视频事件类型 */ + export enum EventType { + PLAYING = 0, + PAUSED = 0, + STOPPED = 0, + COMPLETED = 0, + META_LOADED = 0, + CLICKED = 0, + READY_TO_PLAY = 0, } } /**************************************************** - * Texture2D + * VideoPlayer *****************************************************/ - export namespace Texture2D { - /** The texture wrap mode */ - export enum WrapMode { - REPEAT = 0, - CLAMP_TO_EDGE = 0, - MIRRORED_REPEAT = 0, + export namespace VideoPlayer { + /** !#en Enum for video resouce type type. + !#zh è§†é¢‘æ¥æº */ + export enum ResourceType { + REMOTE = 0, + LOCAL = 0, } } /**************************************************** - * Texture2D + * ParticleSystem *****************************************************/ - export namespace Texture2D { - /** The texture filter mode */ - export enum Filter { - LINEAR = 0, - NEAREST = 0, + export namespace ParticleSystem { + /** !#en Enum for emitter modes + !#zh å‘å°„æ¨¡å¼ */ + export enum EmitterMode { + GRAVITY = 0, + RADIUS = 0, } } /**************************************************** - * Camera + * ParticleSystem *****************************************************/ - export namespace Camera { - /** !#en Values for Camera.clearFlags, determining what to clear when rendering a Camera. - !#zh æ‘„åƒæœºæ¸…é™¤æ ‡è®°ä½ï¼Œå†³å®šæ‘„åƒæœºæ¸²æŸ“æ—¶ä¼šæ¸…é™¤å“ªäº›çŠ¶æ€ */ - export enum ClearFlags { - COLOR = 0, - DEPTH = 0, - STENCIL = 0, + export namespace ParticleSystem { + /** !#en Enum for particles movement type. + !#zh ç²’åä½ç½®ç±»åž‹ */ + export enum PositionType { + FREE = 0, + RELATIVE = 0, + GROUPED = 0, } } - /**************************************************** - * Event - *****************************************************/ - - export namespace Event { - /** !#en The mouse event - !#zh é¼ æ ‡äº‹ä»¶ç±»åž‹ */ - export class EventMouse extends Event { - /** - !#en Sets scroll data. - !#zh è®¾ç½®é¼ æ ‡çš„æ»šåŠ¨æ•°æ®ã€‚ - @param scrollX scrollX - @param scrollY scrollY - */ - setScrollData(scrollX: number, scrollY: number): void; - /** - !#en Returns the x axis scroll value. - !#zh 获å–é¼ æ ‡æ»šåŠ¨çš„Xè½´è·ç¦»ï¼Œåªæœ‰æ»šåŠ¨æ—¶æ‰æœ‰æ•ˆã€‚ - */ - getScrollX(): number; - /** - !#en Returns the y axis scroll value. - !#zh èŽ·å–æ»šè½®æ»šåŠ¨çš„ Y è½´è·ç¦»ï¼Œåªæœ‰æ»šåŠ¨æ—¶æ‰æœ‰æ•ˆã€‚ - */ - getScrollY(): number; - /** - !#en Sets cursor location. - !#zh 设置当å‰é¼ æ ‡ä½ç½®ã€‚ - @param x x - @param y y - */ - setLocation(x: number, y: number): void; - /** - !#en Returns cursor location. - !#zh 获å–é¼ æ ‡ä½ç½®å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 - */ - getLocation(): Vec2; - /** - !#en Returns the current cursor location in screen coordinates. - !#zh 获å–当å‰äº‹ä»¶åœ¨æ¸¸æˆçª—å£å†…çš„åæ ‡ä½ç½®å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 - */ - getLocationInView(): Vec2; - /** - !#en Returns the previous touch location. - !#zh 获å–é¼ æ ‡ç‚¹å‡»åœ¨ä¸Šä¸€æ¬¡äº‹ä»¶æ—¶çš„ä½ç½®å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 - */ - getPreviousLocation(): Vec2; - /** - !#en Returns the delta distance from the previous location to current location. - !#zh 获å–é¼ æ ‡è·ç¦»ä¸Šä¸€æ¬¡äº‹ä»¶ç§»åŠ¨çš„è·ç¦»å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 - */ - getDelta(): Vec2; - /** - !#en Returns the X axis delta distance from the previous location to current location. - !#zh 获å–é¼ æ ‡è·ç¦»ä¸Šä¸€æ¬¡äº‹ä»¶ç§»åŠ¨çš„ X è½´è·ç¦»ã€‚ - */ - getDeltaX(): number; - /** - !#en Returns the Y axis delta distance from the previous location to current location. - !#zh 获å–é¼ æ ‡è·ç¦»ä¸Šä¸€æ¬¡äº‹ä»¶ç§»åŠ¨çš„ Y è½´è·ç¦»ã€‚ - */ - getDeltaY(): number; - /** - !#en Sets mouse button. - !#zh è®¾ç½®é¼ æ ‡æŒ‰é”®ã€‚ - @param button button - */ - setButton(button: number): void; - /** - !#en Returns mouse button. - !#zh 获å–é¼ æ ‡æŒ‰é”®ã€‚ - */ - getButton(): number; - /** - !#en Returns location X axis data. - !#zh 获å–é¼ æ ‡å½“å‰ä½ç½® X 轴。 - */ - getLocationX(): number; - /** - !#en Returns location Y axis data. - !#zh 获å–é¼ æ ‡å½“å‰ä½ç½® Y 轴。 - */ - getLocationY(): number; - /** !#en The none event code of mouse event. - !#zh æ— ã€‚ */ - static NONE: number; - /** !#en The event type code of mouse down event. - !#zh é¼ æ ‡æŒ‰ä¸‹äº‹ä»¶ã€‚ */ - static DOWN: number; - /** !#en The event type code of mouse up event. - !#zh é¼ æ ‡æŒ‰ä¸‹åŽé‡Šæ”¾äº‹ä»¶ã€‚ */ - static UP: number; - /** !#en The event type code of mouse move event. - !#zh é¼ æ ‡ç§»åŠ¨äº‹ä»¶ã€‚ */ - static MOVE: number; - /** !#en The event type code of mouse scroll event. - !#zh é¼ æ ‡æ»šè½®äº‹ä»¶ã€‚ */ - static SCROLL: number; - /** !#en The tag of Mouse left button. - !#zh é¼ æ ‡å·¦é”®çš„æ ‡ç¾ã€‚ */ - static BUTTON_LEFT: number; - /** !#en The tag of Mouse right button (The right button number is 2 on browser). - !#zh é¼ æ ‡å³é”®çš„æ ‡ç¾ã€‚ */ - static BUTTON_RIGHT: number; - /** !#en The tag of Mouse middle button (The right button number is 1 on browser). - !#zh é¼ æ ‡ä¸é”®çš„æ ‡ç¾ã€‚ */ - static BUTTON_MIDDLE: number; - /** !#en The tag of Mouse button 4. - !#zh é¼ æ ‡æŒ‰é”® 4 çš„æ ‡ç¾ã€‚ */ - static BUTTON_4: number; - /** !#en The tag of Mouse button 5. - !#zh é¼ æ ‡æŒ‰é”® 5 çš„æ ‡ç¾ã€‚ */ - static BUTTON_5: number; - /** !#en The tag of Mouse button 6. - !#zh é¼ æ ‡æŒ‰é”® 6 çš„æ ‡ç¾ã€‚ */ - static BUTTON_6: number; - /** !#en The tag of Mouse button 7. - !#zh é¼ æ ‡æŒ‰é”® 7 çš„æ ‡ç¾ã€‚ */ - static BUTTON_7: number; - /** !#en The tag of Mouse button 8. - !#zh é¼ æ ‡æŒ‰é”® 8 çš„æ ‡ç¾ã€‚ */ - static BUTTON_8: number; + /**************************************************** + * TiledMap + *****************************************************/ + + export namespace TiledMap { + /** !#en The orientation of tiled map. + !#zh Tiled Map 地图方å‘。 */ + export enum Orientation { + ORTHO = 0, + HEX = 0, + ISO = 0, } } /**************************************************** - * Event + * TiledMap *****************************************************/ - export namespace Event { - /** !#en The touch event - !#zh 触摸事件 */ - export class EventTouch extends Event { - /** - - @param touchArr The array of the touches - @param bubbles A boolean indicating whether the event bubbles up through the tree or not - */ - constructor(touchArr: any[], bubbles: boolean); - /** !#en The current touch object - !#zh 当å‰è§¦ç‚¹å¯¹è±¡ */ - touch: Touch; - /** - !#en Returns event code. - !#zh 获å–事件类型。 - */ - getEventCode(): number; - /** - !#en Returns touches of event. - !#zh 获å–触摸点的列表。 - */ - getTouches(): any[]; - /** - !#en Sets touch location. - !#zh 设置当å‰è§¦ç‚¹ä½ç½® - @param x x - @param y y - */ - setLocation(x: number, y: number): void; - /** - !#en Returns touch location. - !#zh 获å–触点ä½ç½®ã€‚ - */ - getLocation(): Vec2; - /** - !#en Returns the current touch location in screen coordinates. - !#zh 获å–当å‰è§¦ç‚¹åœ¨æ¸¸æˆçª—å£ä¸çš„ä½ç½®ã€‚ - */ - getLocationInView(): Vec2; - /** - !#en Returns the previous touch location. - !#zh 获å–触点在上一次事件时的ä½ç½®å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 - */ - getPreviousLocation(): Vec2; - /** - !#en Returns the start touch location. - !#zh 获å–触点è½ä¸‹æ—¶çš„ä½ç½®å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 - */ - getStartLocation(): Vec2; - /** - !#en Returns the id of cc.Touch. - !#zh è§¦ç‚¹çš„æ ‡è¯† ID,å¯ä»¥ç”¨æ¥åœ¨å¤šç‚¹è§¦æ‘¸ä¸è·Ÿè¸ªè§¦ç‚¹ã€‚ - */ - getID(): number; - /** - !#en Returns the delta distance from the previous location to current location. - !#zh 获å–触点è·ç¦»ä¸Šä¸€æ¬¡äº‹ä»¶ç§»åŠ¨çš„è·ç¦»å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 - */ - getDelta(): Vec2; - /** - !#en Returns the X axis delta distance from the previous location to current location. - !#zh 获å–触点è·ç¦»ä¸Šä¸€æ¬¡äº‹ä»¶ç§»åŠ¨çš„ x è½´è·ç¦»ã€‚ - */ - getDeltaX(): number; - /** - !#en Returns the Y axis delta distance from the previous location to current location. - !#zh 获å–触点è·ç¦»ä¸Šä¸€æ¬¡äº‹ä»¶ç§»åŠ¨çš„ y è½´è·ç¦»ã€‚ - */ - getDeltaY(): number; - /** - !#en Returns location X axis data. - !#zh 获å–当å‰è§¦ç‚¹ X è½´ä½ç½®ã€‚ - */ - getLocationX(): number; - /** - !#en Returns location Y axis data. - !#zh 获å–当å‰è§¦ç‚¹ Y è½´ä½ç½®ã€‚ - */ - getLocationY(): number; + export namespace TiledMap { + /** The property type of tiled map. */ + export enum Property { + NONE = 0, + MAP = 0, + LAYER = 0, + OBJECTGROUP = 0, + OBJECT = 0, + TILE = 0, } } /**************************************************** - * Event + * TiledMap *****************************************************/ - export namespace Event { - /** !#en The acceleration event - !#zh åŠ é€Ÿåº¦äº‹ä»¶ */ - export class EventAcceleration extends Event { + export namespace TiledMap { + /** The tile flags of tiled map. */ + export enum TileFlag { + HORIZONTAL = 0, + VERTICAL = 0, + DIAGONAL = 0, + FLIPPED_ALL = 0, + FLIPPED_MASK = 0, } } /**************************************************** - * Event + * TiledMap *****************************************************/ - export namespace Event { - /** !#en The keyboard event - !#zh 键盘事件 */ - export class EventKeyboard extends Event { - /** !#en - The keyCode read-only property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key. - This is usually the decimal ASCII (RFC 20) or Windows 1252 code corresponding to the key. - If the key can't be identified, this value is 0. - - !#zh - keyCode 是åªè¯»å±žæ€§å®ƒè¡¨ç¤ºä¸€ä¸ªç³»ç»Ÿå’Œä¾èµ–于实现的数å—代ç ,å¯ä»¥è¯†åˆ«æŒ‰é”®çš„æœªä¿®æ”¹å€¼ã€‚ - 这通常是å进制 ASCII (RFC20) 或者 Windows 1252 代ç ,所对应的密钥。 - å¦‚æžœæ— æ³•è¯†åˆ«è¯¥é”®ï¼Œåˆ™è¯¥å€¼ä¸º 0。 */ - keyCode: number; + export namespace TiledMap { + /** !#en The stagger axis of Hex tiled map. + !#zh å…边形地图的 stagger axis 值 */ + export enum StaggerAxis { + STAGGERAXIS_X = 0, + STAGGERAXIS_Y = 0, } } /**************************************************** - * geomUtils + * TiledMap *****************************************************/ - export namespace geomUtils { - /** Aabb */ - export class Aabb { - /** - create a new aabb - @param px X coordinates for aabb's original point - @param py Y coordinates for aabb's original point - @param pz Z coordinates for aabb's original point - @param w the half of aabb width - @param h the half of aabb height - @param l the half of aabb length - */ - create(px: number, py: number, pz: number, w: number, h: number, l: number): Aabb; - /** - clone a new aabb - @param a the source aabb - */ - clone(a: Aabb): Aabb; - /** - copy the values from one aabb to another - @param out the receiving aabb - @param a the source aabb - */ - copy(out: Aabb, a: Aabb): Aabb; - /** - create a new aabb from two corner points - @param out the receiving aabb - @param minPos lower corner position of the aabb - @param maxPos upper corner position of the aabb - */ - fromPoints(out: Aabb, minPos: Vec3, maxPos: Vec3): Aabb; - /** - Set the components of a aabb to the given values - @param out the receiving aabb - @param px X coordinates for aabb's original point - @param py Y coordinates for aabb's original point - @param pz Z coordinates for aabb's original point - @param w the half of aabb width - @param h the half of aabb height - @param l the half of aabb length - */ - set(out: Aabb, px: number, py: number, pz: number, w: number, h: number, l: number): Aabb; - center: Vec3; - halfExtents: Vec3; - _type: number; - /** - Get the bounding points of this shape - @param minPos minPos - @param maxPos maxPos - */ - getBoundary(minPos: Vec3, maxPos: Vec3): void; - /** - Transform this shape - @param m the transform matrix - @param pos the position part of the transform - @param rot the rotation part of the transform - @param scale the scale part of the transform - @param out the target shape - */ - transform(m: Mat4, pos: Vec3, rot: Quat, scale: Vec3, out?: Aabb): void; + export namespace TiledMap { + /** !#en The render order of tiled map. + !#zh åœ°å›¾çš„æ¸²æŸ“é¡ºåº */ + export enum RenderOrder { + STAGGERINDEX_ODD = 0, + STAGGERINDEX_EVEN = 0, + RightDown = 0, + RightUp = 0, + LeftDown = 0, + LeftUp = 0, } } /**************************************************** - * geomUtils + * TiledMap *****************************************************/ - export namespace geomUtils { - /** !#en Shape type. */ - export enum enums { - SHAPE_RAY = 0, - SHAPE_LINE = 0, - SHAPE_SPHERE = 0, - SHAPE_AABB = 0, - SHAPE_OBB = 0, - SHAPE_PLANE = 0, - SHAPE_TRIANGLE = 0, - SHAPE_FRUSTUM = 0, - SHAPE_FRUSTUM_ACCURATE = 0, + export namespace TiledMap { + /** !#en TiledMap Object Type + !#zh 地图物体类型 */ + export enum TMXObjectType { + RECT = 0, + ELLIPSE = 0, + POLYGON = 0, + POLYLINE = 0, + IMAGE = 0, + TEXT = 0, + } + } + + /**************************************************** + * WebView + *****************************************************/ + + export namespace WebView { + /** !#en WebView event type + !#zh 网页视图事件类型 */ + export enum EventType { + LOADED = 0, + LOADING = 0, + ERROR = 0, + } + } + + /**************************************************** + * Camera + *****************************************************/ + + export namespace Camera { + /** !#en Values for Camera.clearFlags, determining what to clear when rendering a Camera. + !#zh æ‘„åƒæœºæ¸…é™¤æ ‡è®°ä½ï¼Œå†³å®šæ‘„åƒæœºæ¸²æŸ“æ—¶ä¼šæ¸…é™¤å“ªäº›çŠ¶æ€ */ + export enum ClearFlags { + COLOR = 0, + DEPTH = 0, + STENCIL = 0, } } /**************************************************** - * geomUtils + * Light *****************************************************/ - export namespace geomUtils { - /** !#en frustum - !#zh 平截头体 */ - export class Frustum { - /** Set whether to use accurate intersection testing function on this frustum */ - accurate: boolean; - /** - create a new frustum - */ - static create(): Frustum; - /** - Clone a frustum - @param f f - */ - static clone(f: Frustum): Frustum; - /** - Copy the values from one frustum to another - @param out out - @param f f - */ - copy(out: Frustum, f: Frustum): Frustum; - planes: geomUtils.Plane[]; - planes: Vec3[]; - /** - !#en Update the frustum information according to the given transform matrix. - Note that the resulting planes are not normalized under normal mode. - @param m the view-projection matrix - @param inv the inverse view-projection matrix - */ - update(m: Mat4, inv: Mat4): void; - /** - !#en transform by matrix - @param mat mat - */ - transform(mat: Mat4): void; + export namespace Light { + /** !#en The light source type + + !#zh å…‰æºç±»åž‹ */ + export enum Type { + DIRECTIONAL = 0, + POINT = 0, + SPOT = 0, + AMBIENT = 0, } } /**************************************************** - * geomUtils + * Light *****************************************************/ - export namespace geomUtils { - /** undefined */ - export class intersect { - /** - !#en - Check whether ray intersect with nodes - !#zh - 检测射线是å¦ä¸Žç‰©ä½“有交集 - @param root If root is null, then traversal nodes from scene node - @param worldRay worldRay - @param handler handler - @param filter filter - */ - static ray_cast(root: Node, worldRay: geomUtils.Ray, handler: Function, filter: Function): any[]; - /** - !#en ray-plane intersect<br/> - !#zh 射线与平é¢çš„相交性检测。 - @param ray ray - @param plane plane - */ - static ray_plane(ray: geomUtils.Ray, plane: geomUtils.Plane): number; - /** - !#en line-plane intersect<br/> - !#zh 线段与平é¢çš„相交性检测。 - @param line line - @param plane plane - */ - static line_plane(line: geomUtils.Line, plane: geomUtils.Plane): number; - /** - !#en ray-triangle intersect<br/> - !#zh 射线与三角形的相交性检测。 - @param ray ray - @param triangle triangle - @param doubleSided doubleSided - */ - static ray_triangle(ray: geomUtils.Ray, triangle: geomUtils.Triangle, doubleSided: boolean): number; - /** - !#en line-triangle intersect<br/> - !#zh 线段与三角形的相交性检测。 - @param line line - @param triangle triangle - @param outPt optional, The intersection point - */ - static line_triangle(line: geomUtils.Line, triangle: geomUtils.Triangle, outPt: Vec3): number; - /** - !#en line-quad intersect<br/> - !#zh 线段与四边形的相交性检测。 - @param p A point on a line segment - @param q Another point on the line segment - @param a Quadrilateral point a - @param b Quadrilateral point b - @param c Quadrilateral point c - @param d Quadrilateral point d - @param outPt optional, The intersection point - */ - static line_quad(p: Vec3, q: Vec3, a: Vec3, b: Vec3, c: Vec3, d: Vec3, outPt: Vec3): number; - /** - !#en ray-sphere intersect<br/> - !#zh 射线和çƒçš„相交性检测。 - @param ray ray - @param sphere sphere - */ - static ray_sphere(ray: geomUtils.Ray, sphere: geomUtils.Sphere): number; - /** - !#en ray-aabb intersect<br/> - !#zh 射线和轴对é½åŒ…围盒的相交性检测。 - @param ray ray - @param aabb Align the axis around the box - */ - static ray_aabb(ray: geomUtils.Ray, aabb: Aabb): number; - /** - !#en ray-obb intersect<br/> - !#zh 射线和方å‘包围盒的相交性检测。 - @param ray ray - @param obb Direction box - */ - static ray_obb(ray: geomUtils.Ray, obb: geomUtils.Obb): number; - /** - !#en aabb-aabb intersect<br/> - !#zh 轴对é½åŒ…围盒和轴对é½åŒ…围盒的相交性检测。 - @param aabb1 Axis alignment surrounds box 1 - @param aabb2 Axis alignment surrounds box 2 - */ - static aabb_aabb(aabb1: Aabb, aabb2: Aabb): number; - /** - !#en aabb-obb intersect<br/> - !#zh 轴对é½åŒ…围盒和方å‘包围盒的相交性检测。 - @param aabb Align the axis around the box - @param obb Direction box - */ - static aabb_obb(aabb: Aabb, obb: geomUtils.Obb): number; - /** - !#en aabb-plane intersect<br/> - !#zh 轴对é½åŒ…围盒和平é¢çš„相交性检测。 - @param aabb Align the axis around the box - @param plane plane - */ - static aabb_plane(aabb: Aabb, plane: geomUtils.Plane): number; - /** - !#en aabb-frustum intersect, faster but has false positive corner cases<br/> - !#zh 轴对é½åŒ…围盒和锥å°ç›¸äº¤æ€§æ£€æµ‹ï¼Œé€Ÿåº¦å¿«ï¼Œä½†æœ‰é”™è¯¯æƒ…况。 - @param aabb Align the axis around the box - @param frustum frustum - */ - static aabb_frustum(aabb: Aabb, frustum: Frustum): number; - /** - !#en aabb-frustum intersect, handles most of the false positives correctly<br/> - !#zh 轴对é½åŒ…围盒和锥å°ç›¸äº¤æ€§æ£€æµ‹ï¼Œæ£ç¡®å¤„ç†å¤§å¤šæ•°é”™è¯¯æƒ…况。 - @param aabb Align the axis around the box - @param frustum frustum - */ - static aabb_frustum_accurate(aabb: Aabb, frustum: Frustum): number; - /** - !#en obb-point intersect<br/> - !#zh æ–¹å‘包围盒和点的相交性检测。 - @param obb Direction box - @param point point - */ - static obb_point(obb: geomUtils.Obb, point: geomUtils.Vec3): boolean; - /** - !#en obb-plane intersect<br/> - !#zh æ–¹å‘包围盒和平é¢çš„相交性检测。 - @param obb Direction box - @param plane plane - */ - static obb_plane(obb: geomUtils.Obb, plane: geomUtils.Plane): number; - /** - !#en obb-frustum intersect, faster but has false positive corner cases<br/> - !#zh æ–¹å‘包围盒和锥å°ç›¸äº¤æ€§æ£€æµ‹ï¼Œé€Ÿåº¦å¿«ï¼Œä½†æœ‰é”™è¯¯æƒ…况。 - @param obb Direction box - @param frustum frustum - */ - static obb_frustum(obb: geomUtils.Obb, frustum: Frustum): number; - /** - !#en obb-frustum intersect, handles most of the false positives correctly<br/> - !#zh æ–¹å‘包围盒和锥å°ç›¸äº¤æ€§æ£€æµ‹ï¼Œæ£ç¡®å¤„ç†å¤§å¤šæ•°é”™è¯¯æƒ…况。 - @param obb Direction box - @param frustum frustum - */ - static obb_frustum_accurate(obb: geomUtils.Obb, frustum: Frustum): number; - /** - !#en obb-obb intersect<br/> - !#zh æ–¹å‘包围盒和方å‘包围盒的相交性检测。 - @param obb1 Direction box1 - @param obb2 Direction box2 - */ - static obb_obb(obb1: geomUtils.Obb, obb2: geomUtils.Obb): number; - /** - !#en phere-plane intersect, not necessarily faster than obb-plane<br/> - due to the length calculation of the plane normal to factor out<br/> - the unnomalized plane distance<br/> - !#zh çƒä¸Žå¹³é¢çš„相交性检测。 - @param sphere sphere - @param plane plane - */ - static sphere_plane(sphere: geomUtils.Sphere, plane: geomUtils.Plane): number; - /** - !#en sphere-frustum intersect, faster but has false positive corner cases<br/> - !#zh çƒå’Œé”¥å°çš„相交性检测,速度快,但有错误情况。 - @param sphere sphere - @param frustum frustum - */ - static sphere_frustum(sphere: geomUtils.Sphere, frustum: Frustum): number; - /** - !#en sphere-frustum intersect, handles the false positives correctly<br/> - !#zh çƒå’Œé”¥å°çš„相交性检测,æ£ç¡®å¤„ç†å¤§å¤šæ•°é”™è¯¯æƒ…况。 - @param sphere sphere - @param frustum frustum - */ - static sphere_frustum_accurate(sphere: geomUtils.Sphere, frustum: Frustum): number; - /** - !#en sphere-sphere intersect<br/> - !#zh çƒå’Œçƒçš„相交性检测。 - @param sphere0 sphere0 - @param sphere1 sphere1 - */ - static sphere_sphere(sphere0: geomUtils.Sphere, sphere1: geomUtils.Sphere): boolean; - /** - !#en sphere-aabb intersect<br/> - !#zh çƒå’Œè½´å¯¹é½åŒ…围盒的相交性检测。 - @param sphere sphere - @param aabb aabb - */ - static sphere_aabb(sphere: geomUtils.Sphere, aabb: Aabb): boolean; - /** - !#en sphere-obb intersect<br/> - !#zh çƒå’Œæ–¹å‘包围盒的相交性检测。 - @param sphere sphere - @param obb obb - */ - static sphere_obb(sphere: geomUtils.Sphere, obb: geomUtils.Obb): boolean; - /** - !#en - The intersection detection of g1 and g2 can fill in the shape in the basic geometry. - !#zh - g1 å’Œ g2 的相交性检测,å¯å¡«å…¥åŸºç¡€å‡ 何ä¸çš„形状。 - @param g1 Geometry 1 - @param g2 Geometry 2 - @param outPt optional, Intersection point. (note: only partial shape detection with this return value) - */ - static resolve(g1: any, g2: any, outPt: any): void; + export namespace Light { + /** !#en The shadow type + + !#zh 阴影类型 */ + export enum ShadowType { + NONE = 0, + HARD = 0, + SOFT_PCF3X3 = 0, + SOFT_PCF5X5 = 0, } } /**************************************************** - * geomUtils + * Prefab *****************************************************/ - export namespace geomUtils { - /** !#en - line - !#zh - 直线 */ - export class Line { - /** - !#en - create a new line - !#zh - 创建一个新的 line。 - @param sx The x part of the starting point. - @param sy The y part of the starting point. - @param sz The z part of the starting point. - @param ex The x part of the end point. - @param ey The y part of the end point. - @param ez The z part of the end point. - */ - create(sx: number, sy: number, sz: number, ex: number, ey: number, ez: number): Line; - /** - !#en - Creates a new line initialized with values from an existing line - !#zh - 克隆一个新的 line。 - @param a The source of cloning. - */ - clone(a: Line): Line; - /** - !#en - Copy the values from one line to another - !#zh - å¤åˆ¶ä¸€ä¸ªçº¿çš„值到å¦ä¸€ä¸ªã€‚ - @param out The object that accepts the action. - @param a The source of the copy. - */ - copy(out: Line, a: Line): Line; - /** - !#en - create a line from two points - !#zh - 用两个点创建一个线。 - @param out The object that accepts the action. - @param start The starting point. - @param end At the end. - */ - fromPoints(out: Line, start: Vec3, end: Vec3): Line; - /** - !#en - Set the components of a Vec3 to the given values - !#zh - 将给定线的属性设置为给定值。 - @param out The object that accepts the action. - @param sx The x part of the starting point. - @param sy The y part of the starting point. - @param sz The z part of the starting point. - @param ex The x part of the end point. - @param ey The y part of the end point. - @param ez The z part of the end point. - */ - set(out: Line, sx: number, sy: number, sz: number, ex: number, ey: number, ez: number): Line; - /** - !#en - Calculate the length of the line. - !#zh - 计算线的长度。 - @param a The line to calculate. - */ - len(a: Line): number; - /** !#en - Start points. - !#zh - 起点。 */ - s: Vec3; - /** !#en - End points. - !#zh - 终点。 */ - e: Vec3; - /** - !#en - Calculate the length of the line. - !#zh - 计算线的长度。 - */ - length(): number; + export namespace Prefab { + /** !#zh + Prefab 创建实例所用的优化ç–略,é…åˆ {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}} 使用。 + !#en + An enumeration used with the {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}} + to specify how to optimize the instantiate operation. */ + export enum OptimizationPolicy { + AUTO = 0, + SINGLE_INSTANCE = 0, + MULTI_INSTANCE = 0, } } /**************************************************** - * geomUtils + * RenderTexture *****************************************************/ - export namespace geomUtils { - /** !#en obb - !#zh - åŸºç¡€å‡ ä½• æ–¹å‘包围盒。 */ - export class Obb { - /** !#zh - 获å–形状的类型。 */ - type: number; - /** - !#en - create a new obb - !#zh - 创建一个新的 obb 实例。 - @param cx X coordinates of the shape relative to the origin. - @param cy Y coordinates of the shape relative to the origin. - @param cz Z coordinates of the shape relative to the origin. - @param hw Obb is half the width. - @param hh Obb is half the height. - @param hl Obb is half the Length. - @param ox_1 Direction matrix parameter. - @param ox_2 Direction matrix parameter. - @param ox_3 Direction matrix parameter. - @param oy_1 Direction matrix parameter. - @param oy_2 Direction matrix parameter. - @param oy_3 Direction matrix parameter. - @param oz_1 Direction matrix parameter. - @param oz_2 Direction matrix parameter. - @param oz_3 Direction matrix parameter. - */ - create(cx: number, cy: number, cz: number, hw: number, hh: number, hl: number, ox_1: number, ox_2: number, ox_3: number, oy_1: number, oy_2: number, oy_3: number, oz_1: number, oz_2: number, oz_3: number): Obb; - /** - !#en - clone a new obb - !#zh - 克隆一个 obb。 - @param a The target of cloning. - */ - clone(a: Obb): Obb; - /** - !#en - copy the values from one obb to another - !#zh - 将从一个 obb 的值å¤åˆ¶åˆ°å¦ä¸€ä¸ª obb。 - @param out Obb that accepts the operation. - @param a Obb being copied. - */ - copy(out: Obb, a: Obb): Obb; + export namespace RenderTexture { + /** !#en The depth buffer and stencil buffer format for RenderTexture. + !#zh RenderTexture çš„æ·±åº¦ç¼“å†²ä»¥åŠæ¨¡æ¿ç¼“å†²æ ¼å¼ã€‚ */ + export enum DepthStencilFormat { + RB_FMT_D24S8 = 0, + RB_FMT_S8 = 0, + RB_FMT_D16 = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export namespace Texture2D { + /** The texture pixel format, default value is RGBA8888, + you should note that textures loaded by normal image files (png, jpg) can only support RGBA8888 format, + other formats are supported by compressed file types or raw data. */ + export enum PixelFormat { + RGB565 = 0, + RGB5A1 = 0, + RGBA4444 = 0, + RGB888 = 0, + RGBA8888 = 0, + RGBA32F = 0, + A8 = 0, + I8 = 0, + AI88 = 0, + RGB_PVRTC_2BPPV1 = 0, + RGBA_PVRTC_2BPPV1 = 0, + RGB_A_PVRTC_2BPPV1 = 0, + RGB_PVRTC_4BPPV1 = 0, + RGBA_PVRTC_4BPPV1 = 0, + RGB_A_PVRTC_4BPPV1 = 0, + RGB_ETC1 = 0, + RGBA_ETC1 = 0, + RGB_ETC2 = 0, + RGBA_ETC2 = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export namespace Texture2D { + /** The texture wrap mode */ + export enum WrapMode { + REPEAT = 0, + CLAMP_TO_EDGE = 0, + MIRRORED_REPEAT = 0, + } + } + + /**************************************************** + * Texture2D + *****************************************************/ + + export namespace Texture2D { + /** The texture filter mode */ + export enum Filter { + LINEAR = 0, + NEAREST = 0, + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export namespace Collider { + /** !#en Defines a Box Collider . + !#zh 用æ¥å®šä¹‰åŒ…围盒碰撞体 */ + export class Box { + /** !#en Position offset + !#zh ä½ç½®åç§»é‡ */ + offset: Vec2; + /** !#en Box size + !#zh åŒ…å›´ç›’å¤§å° */ + size: Size; + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export namespace Collider { + /** !#en Defines a Circle Collider . + !#zh 用æ¥å®šä¹‰åœ†å½¢ç¢°æ’žä½“ */ + export class Circle { + /** !#en Position offset + !#zh ä½ç½®åç§»é‡ */ + offset: Vec2; + /** !#en Circle radius + !#zh 圆形åŠå¾„ */ + radius: number; + } + } + + /**************************************************** + * Collider + *****************************************************/ + + export namespace Collider { + /** !#en Defines a Polygon Collider . + !#zh 用æ¥å®šä¹‰å¤šè¾¹å½¢ç¢°æ’žä½“ */ + export class Polygon { + /** !#en Position offset + !#zh ä½ç½®åç§»é‡ */ + offset: Vec2; + /** !#en Polygon points + !#zh 多边形顶点数组 */ + points: Vec2[]; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The mouse event + !#zh é¼ æ ‡äº‹ä»¶ç±»åž‹ */ + export class EventMouse extends Event { /** - !#en - create a new obb from two corner points - !#zh - 用两个点创建一个新的 obb。 - @param out Obb that accepts the operation. - @param minPos The smallest point of obb. - @param maxPos Obb's maximum point. + !#en Sets scroll data. + !#zh è®¾ç½®é¼ æ ‡çš„æ»šåŠ¨æ•°æ®ã€‚ + @param scrollX scrollX + @param scrollY scrollY */ - fromPoints(out: Obb, minPos: Vec3, maxPos: Vec3): Obb; + setScrollData(scrollX: number, scrollY: number): void; /** - !#en - Set the components of a obb to the given values - !#zh - 将给定 obb 的属性设置为给定的值。 - @param cx X coordinates of the shape relative to the origin. - @param cy Y coordinates of the shape relative to the origin. - @param cz Z coordinates of the shape relative to the origin. - @param hw Obb is half the width. - @param hh Obb is half the height. - @param hl Obb is half the Length. - @param ox_1 Direction matrix parameter. - @param ox_2 Direction matrix parameter. - @param ox_3 Direction matrix parameter. - @param oy_1 Direction matrix parameter. - @param oy_2 Direction matrix parameter. - @param oy_3 Direction matrix parameter. - @param oz_1 Direction matrix parameter. - @param oz_2 Direction matrix parameter. - @param oz_3 Direction matrix parameter. + !#en Returns the x axis scroll value. + !#zh 获å–é¼ æ ‡æ»šåŠ¨çš„Xè½´è·ç¦»ï¼Œåªæœ‰æ»šåŠ¨æ—¶æ‰æœ‰æ•ˆã€‚ */ - set(cx: number, cy: number, cz: number, hw: number, hh: number, hl: number, ox_1: number, ox_2: number, ox_3: number, oy_1: number, oy_2: number, oy_3: number, oz_1: number, oz_2: number, oz_3: number): Obb; - /** !#en - The center of the local coordinate. - !#zh - æœ¬åœ°åæ ‡çš„ä¸å¿ƒç‚¹ã€‚ */ - center: Vec3; - /** !#en - Half the length, width, and height. - !#zh - 长宽高的一åŠã€‚ */ - halfExtents: Vec3; - /** !#en - Direction matrix. - !#zh - æ–¹å‘矩阵。 */ - orientation: Mat3; + getScrollX(): number; /** - !#en - Get the bounding points of this shape - !#zh - èŽ·å– obb 的最å°ç‚¹å’Œæœ€å¤§ç‚¹ã€‚ - @param minPos minPos - @param maxPos maxPos + !#en Returns the y axis scroll value. + !#zh èŽ·å–æ»šè½®æ»šåŠ¨çš„ Y è½´è·ç¦»ï¼Œåªæœ‰æ»šåŠ¨æ—¶æ‰æœ‰æ•ˆã€‚ */ - getBoundary(minPos: Vec3, maxPos: Vec3): void; + getScrollY(): number; /** - !#en Transform this shape - !#zh - å°† out æ ¹æ®è¿™ä¸ª obb 的数æ®è¿›è¡Œå˜æ¢ã€‚ - @param m The transformation matrix. - @param pos The position part of the transformation. - @param rot The rotating part of the transformation. - @param scale The scaling part of the transformation. - @param out Target of transformation. + !#en Sets cursor location. + !#zh 设置当å‰é¼ æ ‡ä½ç½®ã€‚ + @param x x + @param y y */ - transform(m: Mat4, pos: Vec3, rot: Quat, scale: Vec3, out: Obb): void; + setLocation(x: number, y: number): void; /** - !#en - Transform out based on this obb data. - !#zh - å°† out æ ¹æ®è¿™ä¸ª obb 的数æ®è¿›è¡Œå˜æ¢ã€‚ - @param m The transformation matrix. - @param rot The rotating part of the transformation. - @param out Target of transformation. + !#en Returns cursor location. + !#zh 获å–é¼ æ ‡ä½ç½®å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 */ - translateAndRotate(m: Mat4, rot: Quat, out: Obb): void; + getLocation(): Vec2; /** - !#en - Scale out based on this obb data. - !#zh - å°† out æ ¹æ®è¿™ä¸ª obb 的数æ®è¿›è¡Œç¼©æ”¾ã€‚ - @param scale Scale value. - @param out Scaled target. + !#en Returns the current cursor location in screen coordinates. + !#zh 获å–当å‰äº‹ä»¶åœ¨æ¸¸æˆçª—å£å†…çš„åæ ‡ä½ç½®å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 */ - setScale(scale: Vec3, out: Obb): void; - } - } - - /**************************************************** - * geomUtils - *****************************************************/ - - export namespace geomUtils { - /** !#en - plane。 - !#zh - å¹³é¢ã€‚ */ - export class Plane { + getLocationInView(): Vec2; /** - !#en - create a new plane - !#zh - 创建一个新的 plane。 - @param nx The x part of the normal component. - @param ny The y part of the normal component. - @param nz The z part of the normal component. - @param d Distance from the origin. + !#en Returns the previous touch location. + !#zh 获å–é¼ æ ‡ç‚¹å‡»åœ¨ä¸Šä¸€æ¬¡äº‹ä»¶æ—¶çš„ä½ç½®å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 */ - create(nx: number, ny: number, nz: number, d: number): Plane; + getPreviousLocation(): Vec2; /** - !#en - clone a new plane - !#zh - 克隆一个新的 plane。 - @param p The source of cloning. + !#en Returns the delta distance from the previous location to current location. + !#zh 获å–é¼ æ ‡è·ç¦»ä¸Šä¸€æ¬¡äº‹ä»¶ç§»åŠ¨çš„è·ç¦»å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 */ - clone(p: Plane): Plane; + getDelta(): Vec2; /** - !#en - copy the values from one plane to another - !#zh - å¤åˆ¶ä¸€ä¸ªå¹³é¢çš„值到å¦ä¸€ä¸ªã€‚ - @param out The object that accepts the action. - @param p The source of the copy. + !#en Returns the X axis delta distance from the previous location to current location. + !#zh 获å–é¼ æ ‡è·ç¦»ä¸Šä¸€æ¬¡äº‹ä»¶ç§»åŠ¨çš„ X è½´è·ç¦»ã€‚ */ - copy(out: Plane, p: Plane): Plane; + getDeltaX(): number; /** - !#en - create a plane from three points - !#zh - 用三个点创建一个平é¢ã€‚ - @param out The object that accepts the action. - @param a Point a。 - @param b Point b。 - @param c Point c。 + !#en Returns the Y axis delta distance from the previous location to current location. + !#zh 获å–é¼ æ ‡è·ç¦»ä¸Šä¸€æ¬¡äº‹ä»¶ç§»åŠ¨çš„ Y è½´è·ç¦»ã€‚ */ - fromPoints(out: Plane, a: Vec3, b: Vec3, c: Vec3): Plane; + getDeltaY(): number; /** - !#en - Set the components of a plane to the given values - !#zh - 将给定平é¢çš„属性设置为给定值。 - @param out The object that accepts the action. - @param nx The x part of the normal component. - @param ny The y part of the normal component. - @param nz The z part of the normal component. - @param d Distance from the origin. + !#en Sets mouse button. + !#zh è®¾ç½®é¼ æ ‡æŒ‰é”®ã€‚ + @param button button */ - set(out: Plane, nx: number, ny: number, nz: number, d: number): Plane; + setButton(button: number): void; /** - !#en - create plane from normal and point - !#zh - ç”¨ä¸€æ¡æ³•线和一个点创建平é¢ã€‚ - @param out The object that accepts the action. - @param normal The normal of a plane. - @param point A point on the plane. + !#en Returns mouse button. + !#zh 获å–é¼ æ ‡æŒ‰é”®ã€‚ */ - fromNormalAndPoint(out: Plane, normal: Vec3, point: Vec3): Plane; + getButton(): number; /** - !#en - normalize a plane - !#zh - 归一化一个平é¢ã€‚ - @param out The object that accepts the action. - @param a Source data for operations. + !#en Returns location X axis data. + !#zh 获å–é¼ æ ‡å½“å‰ä½ç½® X 轴。 */ - normalize(out: Plane, a: Plane): Plane; - /** !#en - A normal vector. - !#zh - 法线å‘é‡ã€‚ */ - n: Vec3; - /** !#en - The distance from the origin to the plane. - !#zh - 原点到平é¢çš„è·ç¦»ã€‚ */ - d: number; + getLocationX(): number; /** - !#en - Transform a plane. - !#zh - å˜æ¢ä¸€ä¸ªå¹³é¢ã€‚ - @param mat mat + !#en Returns location Y axis data. + !#zh 获å–é¼ æ ‡å½“å‰ä½ç½® Y 轴。 */ - transform(mat: Mat4): void; + getLocationY(): number; + /** !#en The none event code of mouse event. + !#zh æ— ã€‚ */ + static NONE: number; + /** !#en The event type code of mouse down event. + !#zh é¼ æ ‡æŒ‰ä¸‹äº‹ä»¶ã€‚ */ + static DOWN: number; + /** !#en The event type code of mouse up event. + !#zh é¼ æ ‡æŒ‰ä¸‹åŽé‡Šæ”¾äº‹ä»¶ã€‚ */ + static UP: number; + /** !#en The event type code of mouse move event. + !#zh é¼ æ ‡ç§»åŠ¨äº‹ä»¶ã€‚ */ + static MOVE: number; + /** !#en The event type code of mouse scroll event. + !#zh é¼ æ ‡æ»šè½®äº‹ä»¶ã€‚ */ + static SCROLL: number; + /** !#en The tag of Mouse left button. + !#zh é¼ æ ‡å·¦é”®çš„æ ‡ç¾ã€‚ */ + static BUTTON_LEFT: number; + /** !#en The tag of Mouse right button (The right button number is 2 on browser). + !#zh é¼ æ ‡å³é”®çš„æ ‡ç¾ã€‚ */ + static BUTTON_RIGHT: number; + /** !#en The tag of Mouse middle button (The right button number is 1 on browser). + !#zh é¼ æ ‡ä¸é”®çš„æ ‡ç¾ã€‚ */ + static BUTTON_MIDDLE: number; + /** !#en The tag of Mouse button 4. + !#zh é¼ æ ‡æŒ‰é”® 4 çš„æ ‡ç¾ã€‚ */ + static BUTTON_4: number; + /** !#en The tag of Mouse button 5. + !#zh é¼ æ ‡æŒ‰é”® 5 çš„æ ‡ç¾ã€‚ */ + static BUTTON_5: number; + /** !#en The tag of Mouse button 6. + !#zh é¼ æ ‡æŒ‰é”® 6 çš„æ ‡ç¾ã€‚ */ + static BUTTON_6: number; + /** !#en The tag of Mouse button 7. + !#zh é¼ æ ‡æŒ‰é”® 7 çš„æ ‡ç¾ã€‚ */ + static BUTTON_7: number; + /** !#en The tag of Mouse button 8. + !#zh é¼ æ ‡æŒ‰é”® 8 çš„æ ‡ç¾ã€‚ */ + static BUTTON_8: number; } } /**************************************************** - * geomUtils + * Event *****************************************************/ - export namespace geomUtils { - /** !#en - ray - !#zh - 射线。 */ - export class Ray { - /** - !#en - create a new ray - !#zh - 创建一æ¡å°„线。 - @param ox The x part of the starting point. - @param oy The y part of the starting point. - @param oz The z part of the starting point. - @param dx X in the direction. - @param dy Y in the direction. - @param dz Z in the direction. - */ - create(ox: number, oy: number, oz: number, dx: number, dy: number, dz: number): Ray; + export namespace Event { + /** !#en The touch event + !#zh 触摸事件 */ + export class EventTouch extends Event { /** - !#en - Creates a new ray initialized with values from an existing ray - !#zh - 从一æ¡å°„çº¿å…‹éš†å‡ºä¸€æ¡æ–°çš„射线。 - @param a Clone target + + @param touchArr The array of the touches + @param bubbles A boolean indicating whether the event bubbles up through the tree or not */ - clone(a: Ray): Ray; + constructor(touchArr: any[], bubbles: boolean); + /** !#en The current touch object + !#zh 当å‰è§¦ç‚¹å¯¹è±¡ */ + touch: Touch; /** - !#en - Copy the values from one ray to another - !#zh - 将从一个 ray 的值å¤åˆ¶åˆ°å¦ä¸€ä¸ª ray。 - @param out Accept the ray of the operation. - @param a Copied ray. + !#en Returns event code. + !#zh 获å–事件类型。 */ - copy(out: Ray, a: Ray): Ray; + getEventCode(): number; /** - !#en - create a ray from two points - !#zh - 用两个点创建一æ¡å°„线。 - @param out Receive the operating ray. - @param origin Origin of ray - @param target A point on a ray. + !#en Returns touches of event. + !#zh 获å–触摸点的列表。 */ - fromPoints(out: Ray, origin: Vec3, target: Vec3): Ray; + getTouches(): any[]; /** - !#en - Set the components of a ray to the given values - !#zh - 将给定射线的属性设置为给定的值。 - @param out Receive the operating ray. - @param ox The x part of the starting point. - @param oy The y part of the starting point. - @param oz The z part of the starting point. - @param dx X in the direction. - @param dy Y in the direction. - @param dz Z in the direction. + !#en Sets touch location. + !#zh 设置当å‰è§¦ç‚¹ä½ç½® + @param x x + @param y y */ - set(out: Ray, ox: number, oy: number, oz: number, dx: number, dy: number, dz: number): Ray; - /** !#en - Start point. - !#zh - 起点。 */ - o: Vec3; - /** !#e - Direction - !#zh - æ–¹å‘。 */ - d: Vec3; + setLocation(x: number, y: number): void; /** - !#en Compute hit. - @param out out - @param distance distance + !#en Returns touch location. + !#zh 获å–触点ä½ç½®ã€‚ */ - computeHit(out: IVec3Like, distance: number): void; - } - } - - /**************************************************** - * geomUtils - *****************************************************/ - - export namespace geomUtils { - /** !#en - Sphere. - !#zh - 轴对é½çƒã€‚ */ - export class Sphere { + getLocation(): Vec2; /** - !#en - create a new sphere - !#zh - 创建一个新的 sphere 实例。 - @param cx X coordinates of the shape relative to the origin. - @param cy Y coordinates of the shape relative to the origin. - @param cz Z coordinates of the shape relative to the origin. - @param r Radius of sphere + !#en Returns the current touch location in screen coordinates. + !#zh 获å–当å‰è§¦ç‚¹åœ¨æ¸¸æˆçª—å£ä¸çš„ä½ç½®ã€‚ */ - create(cx: any, cy: any, cz: any, r: any): Sphere; + getLocationInView(): Vec2; /** - !#en - clone a new sphere - !#zh - 克隆一个新的 sphere 实例。 - @param p The target of cloning. + !#en Returns the previous touch location. + !#zh 获å–触点在上一次事件时的ä½ç½®å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 */ - clone(p: Sphere): Sphere; + getPreviousLocation(): Vec2; /** - !#en - copy the values from one sphere to another - !#zh - 将从一个 sphere 的值å¤åˆ¶åˆ°å¦ä¸€ä¸ª sphere。 - @param out Accept the sphere of operations. - @param a Sphere being copied. + !#en Returns the start touch location. + !#zh 获å–触点è½ä¸‹æ—¶çš„ä½ç½®å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 */ - copy(out: Sphere, a: Sphere): Sphere; + getStartLocation(): Vec2; /** - !#en - create a new bounding sphere from two corner points - !#zh - 从两个点创建一个新的 sphere。 - @param out Accept the sphere of operations. - @param minPos The smallest point of sphere. - @param maxPos The maximum point of sphere. + !#en Returns the id of cc.Touch. + !#zh è§¦ç‚¹çš„æ ‡è¯† ID,å¯ä»¥ç”¨æ¥åœ¨å¤šç‚¹è§¦æ‘¸ä¸è·Ÿè¸ªè§¦ç‚¹ã€‚ */ - fromPoints(out: any, minPos: any, maxPos: any): Sphere; + getID(): number; /** - !#en Set the components of a sphere to the given values - !#zh å°†çƒä½“的属性设置为给定的值。 - @param out Accept the sphere of operations. - @param cx X coordinates of the shape relative to the origin. - @param cy Y coordinates of the shape relative to the origin. - @param cz Z coordinates of the shape relative to the origin. - @param r Radius. + !#en Returns the delta distance from the previous location to current location. + !#zh 获å–触点è·ç¦»ä¸Šä¸€æ¬¡äº‹ä»¶ç§»åŠ¨çš„è·ç¦»å¯¹è±¡ï¼Œå¯¹è±¡åŒ…å« x å’Œ y 属性。 */ - set(out: Sphere, cx: any, cy: any, cz: any, r: number): Sphere; - /** !#en - The center of the local coordinate. - !#zh - æœ¬åœ°åæ ‡çš„ä¸å¿ƒç‚¹ã€‚ */ - center: Vec3; - /** !#zh - åŠå¾„。 */ - radius: number; + getDelta(): Vec2; /** - !#en - Clone. - !#zh - 获得克隆。 + !#en Returns the X axis delta distance from the previous location to current location. + !#zh 获å–触点è·ç¦»ä¸Šä¸€æ¬¡äº‹ä»¶ç§»åŠ¨çš„ x è½´è·ç¦»ã€‚ */ - clone(): void; + getDeltaX(): number; /** - !#en - Copy sphere - !#zh - æ‹·è´å¯¹è±¡ã€‚ - @param a Copy target. + !#en Returns the Y axis delta distance from the previous location to current location. + !#zh 获å–触点è·ç¦»ä¸Šä¸€æ¬¡äº‹ä»¶ç§»åŠ¨çš„ y è½´è·ç¦»ã€‚ */ - copy(a: any): void; + getDeltaY(): number; /** - !#en - Get the bounding points of this shape - !#zh - èŽ·å–æ¤å½¢çŠ¶çš„è¾¹ç•Œç‚¹ã€‚ - @param minPos minPos - @param maxPos maxPos + !#en Returns location X axis data. + !#zh 获å–当å‰è§¦ç‚¹ X è½´ä½ç½®ã€‚ */ - getBoundary(minPos: Vec3, maxPos: Vec3): void; + getLocationX(): number; /** - !#en - Transform this shape - !#zh - å°† out æ ¹æ®è¿™ä¸ª sphere 的数æ®è¿›è¡Œå˜æ¢ã€‚ - @param m The transformation matrix. - @param pos The position part of the transformation. - @param rot The rotating part of the transformation. - @param scale The scaling part of the transformation. - @param out The target of the transformation. + !#en Returns location Y axis data. + !#zh 获å–当å‰è§¦ç‚¹ Y è½´ä½ç½®ã€‚ */ - transform(m: any, pos: any, rot: any, scale: any, out: any): void; - /** - !#en - Scale out based on the sphere data. + getLocationY(): number; + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The acceleration event + !#zh åŠ é€Ÿåº¦äº‹ä»¶ */ + export class EventAcceleration extends Event { + } + } + + /**************************************************** + * Event + *****************************************************/ + + export namespace Event { + /** !#en The keyboard event + !#zh 键盘事件 */ + export class EventKeyboard extends Event { + /** !#en + The keyCode read-only property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key. + This is usually the decimal ASCII (RFC 20) or Windows 1252 code corresponding to the key. + If the key can't be identified, this value is 0. + !#zh - å°† out æ ¹æ®è¿™ä¸ª sphere 的数æ®è¿›è¡Œç¼©æ”¾ã€‚ - @param scale Scale value - @param out Scale target - */ - setScale(scale: any, out: any): void; + keyCode 是åªè¯»å±žæ€§å®ƒè¡¨ç¤ºä¸€ä¸ªç³»ç»Ÿå’Œä¾èµ–于实现的数å—代ç ,å¯ä»¥è¯†åˆ«æŒ‰é”®çš„æœªä¿®æ”¹å€¼ã€‚ + 这通常是å进制 ASCII (RFC20) 或者 Windows 1252 代ç ,所对应的密钥。 + å¦‚æžœæ— æ³•è¯†åˆ«è¯¥é”®ï¼Œåˆ™è¯¥å€¼ä¸º 0。 */ + keyCode: number; } } /**************************************************** - * geomUtils + * Event *****************************************************/ - export namespace geomUtils { - /** Triangle */ - export class Triangle { - /** - create a new triangle - @param ax ax - @param ay ay - @param az az - @param bx bx - @param by by - @param bz bz - @param cx cx - @param cy cy - @param cz cz - */ - create(ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): Triangle; + export namespace Event { + /** !#en The Custom event + !#zh 自定义事件 */ + export class EventCustom extends Event { /** - clone a new triangle - @param t the source plane + + @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit" + @param bubbles A boolean indicating whether the event bubbles up through the tree or not */ - clone(t: Triangle): Triangle; + constructor(type: string, bubbles: boolean); + /** !#en A reference to the detailed data of the event + !#zh äº‹ä»¶çš„è¯¦ç»†æ•°æ® */ + detail: any; /** - copy the values from one triangle to another - @param out the receiving triangle - @param t the source triangle + !#en Sets user data + !#zh è®¾ç½®ç”¨æˆ·æ•°æ® + @param data data */ - copy(out: Triangle, t: Triangle): Triangle; + setUserData(data: any): void; /** - Create a triangle from three points - @param out the receiving triangle - @param a a - @param b b - @param c c + !#en Gets user data + !#zh 获å–ç”¨æˆ·æ•°æ® */ - fromPoints(out: Triangle, a: Vec3, b: Vec3, c: Vec3): Triangle; + getUserData(): any; /** - Set the components of a triangle to the given values - @param out the receiving plane - @param ax X component of a - @param ay Y component of a - @param az Z component of a - @param bx X component of b - @param by Y component of b - @param bz Z component of b - @param cx X component of c - @param cy Y component of c - @param cz Z component of c + !#en Gets event name + !#zh 获å–事件åç§° */ - set(out: Triangle, ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): Plane; - a: Vec3; - b: Vec3; - c: Vec3; + getEventName(): string; } } /**************************************************** - * MeshRenderer + * SystemEvent *****************************************************/ - export namespace MeshRenderer { - /** !#en Shadow projection mode - - !#ch é˜´å½±æŠ•å°„æ–¹å¼ */ - export enum ShadowCastingMode { - OFF = 0, - ON = 0, + export namespace SystemEvent { + /** !#en The event type supported by SystemEvent + !#zh SystemEvent 支æŒçš„事件类型 */ + export class EventType { + /** !#en The event type for press the key down event, you can use its value directly: 'keydown' + !#zh 当按下按键时触å‘的事件 */ + static KEY_DOWN: string; + /** !#en The event type for press the key up event, you can use its value directly: 'keyup' + !#zh 当æ¾å¼€æŒ‰é”®æ—¶è§¦å‘的事件 */ + static KEY_UP: string; + /** !#en The event type for press the devicemotion event, you can use its value directly: 'devicemotion' + !#zh é‡åŠ›æ„Ÿåº” */ + static DEVICEMOTION: string; } } @@ -18984,212 +18216,1061 @@ declare namespace cc { } /**************************************************** - * Scrollbar + * Scrollbar + *****************************************************/ + + export namespace Scrollbar { + /** Enum for Scrollbar direction */ + export enum Direction { + HORIZONTAL = 0, + VERTICAL = 0, + } + } + + /**************************************************** + * ScrollView + *****************************************************/ + + export namespace ScrollView { + /** !#en Enum for ScrollView event type. + !#zh 滚动视图事件类型 */ + export enum EventType { + SCROLL_TO_TOP = 0, + SCROLL_TO_BOTTOM = 0, + SCROLL_TO_LEFT = 0, + SCROLL_TO_RIGHT = 0, + SCROLLING = 0, + BOUNCE_TOP = 0, + BOUNCE_BOTTOM = 0, + BOUNCE_LEFT = 0, + BOUNCE_RIGHT = 0, + SCROLL_ENDED = 0, + TOUCH_UP = 0, + AUTOSCROLL_ENDED_WITH_THRESHOLD = 0, + SCROLL_BEGAN = 0, + } + } + + /**************************************************** + * Slider + *****************************************************/ + + export namespace Slider { + /** !#en The Slider Direction + !#zh æ»‘åŠ¨å™¨æ–¹å‘ */ + export enum Direction { + Horizontal = 0, + Vertical = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Enum for sprite type. + !#zh Sprite 类型 */ + export enum Type { + SIMPLE = 0, + SLICED = 0, + TILED = 0, + FILLED = 0, + MESH = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Enum for fill type. + !#zh 填充类型 */ + export enum FillType { + HORIZONTAL = 0, + VERTICAL = 0, + RADIAL = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Sprite Size can track trimmed size, raw size or none. + !#zh ç²¾çµå°ºå¯¸è°ƒæ•´æ¨¡å¼ */ + export enum SizeMode { + CUSTOM = 0, + TRIMMED = 0, + RAW = 0, + } + } + + /**************************************************** + * Sprite + *****************************************************/ + + export namespace Sprite { + /** !#en Sprite state can choice the normal or grayscale. + !#zh ç²¾çµé¢œè‰²é€šé“模å¼ã€‚ */ + export enum State { + NORMAL = 0, + GRAY = 0, + } + } + + /**************************************************** + * Widget + *****************************************************/ + + export namespace Widget { + /** !#en Enum for Widget's alignment mode, indicating when the widget should refresh. + !#zh Widget çš„å¯¹é½æ¨¡å¼ï¼Œè¡¨ç¤º Widget 应该何时刷新。 */ + export enum AlignMode { + ONCE = 0, + ON_WINDOW_RESIZE = 0, + ALWAYS = 0, + } + } + + /**************************************************** + * geomUtils + *****************************************************/ + + export namespace geomUtils { + /** Aabb */ + export class Aabb { + /** + create a new aabb + @param px X coordinates for aabb's original point + @param py Y coordinates for aabb's original point + @param pz Z coordinates for aabb's original point + @param w the half of aabb width + @param h the half of aabb height + @param l the half of aabb length + */ + create(px: number, py: number, pz: number, w: number, h: number, l: number): Aabb; + /** + clone a new aabb + @param a the source aabb + */ + clone(a: Aabb): Aabb; + /** + copy the values from one aabb to another + @param out the receiving aabb + @param a the source aabb + */ + copy(out: Aabb, a: Aabb): Aabb; + /** + create a new aabb from two corner points + @param out the receiving aabb + @param minPos lower corner position of the aabb + @param maxPos upper corner position of the aabb + */ + fromPoints(out: Aabb, minPos: Vec3, maxPos: Vec3): Aabb; + /** + Set the components of a aabb to the given values + @param out the receiving aabb + @param px X coordinates for aabb's original point + @param py Y coordinates for aabb's original point + @param pz Z coordinates for aabb's original point + @param w the half of aabb width + @param h the half of aabb height + @param l the half of aabb length + */ + set(out: Aabb, px: number, py: number, pz: number, w: number, h: number, l: number): Aabb; + center: Vec3; + halfExtents: Vec3; + _type: number; + /** + Get the bounding points of this shape + @param minPos minPos + @param maxPos maxPos + */ + getBoundary(minPos: Vec3, maxPos: Vec3): void; + /** + Transform this shape + @param m the transform matrix + @param pos the position part of the transform + @param rot the rotation part of the transform + @param scale the scale part of the transform + @param out the target shape + */ + transform(m: Mat4, pos: Vec3, rot: Quat, scale: Vec3, out?: Aabb): void; + } + } + + /**************************************************** + * geomUtils *****************************************************/ - export namespace Scrollbar { - /** Enum for Scrollbar direction */ - export enum Direction { - HORIZONTAL = 0, - VERTICAL = 0, + export namespace geomUtils { + /** !#en Shape type. */ + export enum enums { + SHAPE_RAY = 0, + SHAPE_LINE = 0, + SHAPE_SPHERE = 0, + SHAPE_AABB = 0, + SHAPE_OBB = 0, + SHAPE_PLANE = 0, + SHAPE_TRIANGLE = 0, + SHAPE_FRUSTUM = 0, + SHAPE_FRUSTUM_ACCURATE = 0, } } /**************************************************** - * ScrollView + * geomUtils *****************************************************/ - export namespace ScrollView { - /** !#en Enum for ScrollView event type. - !#zh 滚动视图事件类型 */ - export enum EventType { - SCROLL_TO_TOP = 0, - SCROLL_TO_BOTTOM = 0, - SCROLL_TO_LEFT = 0, - SCROLL_TO_RIGHT = 0, - SCROLLING = 0, - BOUNCE_TOP = 0, - BOUNCE_BOTTOM = 0, - BOUNCE_LEFT = 0, - BOUNCE_RIGHT = 0, - SCROLL_ENDED = 0, - TOUCH_UP = 0, - AUTOSCROLL_ENDED_WITH_THRESHOLD = 0, - SCROLL_BEGAN = 0, + export namespace geomUtils { + /** !#en frustum + !#zh 平截头体 */ + export class Frustum { + /** Set whether to use accurate intersection testing function on this frustum */ + accurate: boolean; + /** + create a new frustum + */ + static create(): Frustum; + /** + Clone a frustum + @param f f + */ + static clone(f: Frustum): Frustum; + /** + Copy the values from one frustum to another + @param out out + @param f f + */ + copy(out: Frustum, f: Frustum): Frustum; + planes: geomUtils.Plane[]; + planes: Vec3[]; + /** + !#en Update the frustum information according to the given transform matrix. + Note that the resulting planes are not normalized under normal mode. + @param m the view-projection matrix + @param inv the inverse view-projection matrix + */ + update(m: Mat4, inv: Mat4): void; + /** + !#en transform by matrix + @param mat mat + */ + transform(mat: Mat4): void; } } /**************************************************** - * Slider + * geomUtils *****************************************************/ - export namespace Slider { - /** !#en The Slider Direction - !#zh æ»‘åŠ¨å™¨æ–¹å‘ */ - export enum Direction { - Horizontal = 0, - Vertical = 0, + export namespace geomUtils { + /** undefined */ + export class intersect { + /** + !#en + Check whether ray intersect with nodes + !#zh + 检测射线是å¦ä¸Žç‰©ä½“有交集 + @param root If root is null, then traversal nodes from scene node + @param worldRay worldRay + @param handler handler + @param filter filter + */ + static ray_cast(root: Node, worldRay: geomUtils.Ray, handler: Function, filter: Function): any[]; + /** + !#en ray-plane intersect<br/> + !#zh 射线与平é¢çš„相交性检测。 + @param ray ray + @param plane plane + */ + static ray_plane(ray: geomUtils.Ray, plane: geomUtils.Plane): number; + /** + !#en line-plane intersect<br/> + !#zh 线段与平é¢çš„相交性检测。 + @param line line + @param plane plane + */ + static line_plane(line: geomUtils.Line, plane: geomUtils.Plane): number; + /** + !#en ray-triangle intersect<br/> + !#zh 射线与三角形的相交性检测。 + @param ray ray + @param triangle triangle + @param doubleSided doubleSided + */ + static ray_triangle(ray: geomUtils.Ray, triangle: geomUtils.Triangle, doubleSided: boolean): number; + /** + !#en line-triangle intersect<br/> + !#zh 线段与三角形的相交性检测。 + @param line line + @param triangle triangle + @param outPt optional, The intersection point + */ + static line_triangle(line: geomUtils.Line, triangle: geomUtils.Triangle, outPt: Vec3): number; + /** + !#en line-quad intersect<br/> + !#zh 线段与四边形的相交性检测。 + @param p A point on a line segment + @param q Another point on the line segment + @param a Quadrilateral point a + @param b Quadrilateral point b + @param c Quadrilateral point c + @param d Quadrilateral point d + @param outPt optional, The intersection point + */ + static line_quad(p: Vec3, q: Vec3, a: Vec3, b: Vec3, c: Vec3, d: Vec3, outPt: Vec3): number; + /** + !#en ray-sphere intersect<br/> + !#zh 射线和çƒçš„相交性检测。 + @param ray ray + @param sphere sphere + */ + static ray_sphere(ray: geomUtils.Ray, sphere: geomUtils.Sphere): number; + /** + !#en ray-aabb intersect<br/> + !#zh 射线和轴对é½åŒ…围盒的相交性检测。 + @param ray ray + @param aabb Align the axis around the box + */ + static ray_aabb(ray: geomUtils.Ray, aabb: Aabb): number; + /** + !#en ray-obb intersect<br/> + !#zh 射线和方å‘包围盒的相交性检测。 + @param ray ray + @param obb Direction box + */ + static ray_obb(ray: geomUtils.Ray, obb: geomUtils.Obb): number; + /** + !#en aabb-aabb intersect<br/> + !#zh 轴对é½åŒ…围盒和轴对é½åŒ…围盒的相交性检测。 + @param aabb1 Axis alignment surrounds box 1 + @param aabb2 Axis alignment surrounds box 2 + */ + static aabb_aabb(aabb1: Aabb, aabb2: Aabb): number; + /** + !#en aabb-obb intersect<br/> + !#zh 轴对é½åŒ…围盒和方å‘包围盒的相交性检测。 + @param aabb Align the axis around the box + @param obb Direction box + */ + static aabb_obb(aabb: Aabb, obb: geomUtils.Obb): number; + /** + !#en aabb-plane intersect<br/> + !#zh 轴对é½åŒ…围盒和平é¢çš„相交性检测。 + @param aabb Align the axis around the box + @param plane plane + */ + static aabb_plane(aabb: Aabb, plane: geomUtils.Plane): number; + /** + !#en aabb-frustum intersect, faster but has false positive corner cases<br/> + !#zh 轴对é½åŒ…围盒和锥å°ç›¸äº¤æ€§æ£€æµ‹ï¼Œé€Ÿåº¦å¿«ï¼Œä½†æœ‰é”™è¯¯æƒ…况。 + @param aabb Align the axis around the box + @param frustum frustum + */ + static aabb_frustum(aabb: Aabb, frustum: Frustum): number; + /** + !#en aabb-frustum intersect, handles most of the false positives correctly<br/> + !#zh 轴对é½åŒ…围盒和锥å°ç›¸äº¤æ€§æ£€æµ‹ï¼Œæ£ç¡®å¤„ç†å¤§å¤šæ•°é”™è¯¯æƒ…况。 + @param aabb Align the axis around the box + @param frustum frustum + */ + static aabb_frustum_accurate(aabb: Aabb, frustum: Frustum): number; + /** + !#en obb-point intersect<br/> + !#zh æ–¹å‘包围盒和点的相交性检测。 + @param obb Direction box + @param point point + */ + static obb_point(obb: geomUtils.Obb, point: geomUtils.Vec3): boolean; + /** + !#en obb-plane intersect<br/> + !#zh æ–¹å‘包围盒和平é¢çš„相交性检测。 + @param obb Direction box + @param plane plane + */ + static obb_plane(obb: geomUtils.Obb, plane: geomUtils.Plane): number; + /** + !#en obb-frustum intersect, faster but has false positive corner cases<br/> + !#zh æ–¹å‘包围盒和锥å°ç›¸äº¤æ€§æ£€æµ‹ï¼Œé€Ÿåº¦å¿«ï¼Œä½†æœ‰é”™è¯¯æƒ…况。 + @param obb Direction box + @param frustum frustum + */ + static obb_frustum(obb: geomUtils.Obb, frustum: Frustum): number; + /** + !#en obb-frustum intersect, handles most of the false positives correctly<br/> + !#zh æ–¹å‘包围盒和锥å°ç›¸äº¤æ€§æ£€æµ‹ï¼Œæ£ç¡®å¤„ç†å¤§å¤šæ•°é”™è¯¯æƒ…况。 + @param obb Direction box + @param frustum frustum + */ + static obb_frustum_accurate(obb: geomUtils.Obb, frustum: Frustum): number; + /** + !#en obb-obb intersect<br/> + !#zh æ–¹å‘包围盒和方å‘包围盒的相交性检测。 + @param obb1 Direction box1 + @param obb2 Direction box2 + */ + static obb_obb(obb1: geomUtils.Obb, obb2: geomUtils.Obb): number; + /** + !#en phere-plane intersect, not necessarily faster than obb-plane<br/> + due to the length calculation of the plane normal to factor out<br/> + the unnomalized plane distance<br/> + !#zh çƒä¸Žå¹³é¢çš„相交性检测。 + @param sphere sphere + @param plane plane + */ + static sphere_plane(sphere: geomUtils.Sphere, plane: geomUtils.Plane): number; + /** + !#en sphere-frustum intersect, faster but has false positive corner cases<br/> + !#zh çƒå’Œé”¥å°çš„相交性检测,速度快,但有错误情况。 + @param sphere sphere + @param frustum frustum + */ + static sphere_frustum(sphere: geomUtils.Sphere, frustum: Frustum): number; + /** + !#en sphere-frustum intersect, handles the false positives correctly<br/> + !#zh çƒå’Œé”¥å°çš„相交性检测,æ£ç¡®å¤„ç†å¤§å¤šæ•°é”™è¯¯æƒ…况。 + @param sphere sphere + @param frustum frustum + */ + static sphere_frustum_accurate(sphere: geomUtils.Sphere, frustum: Frustum): number; + /** + !#en sphere-sphere intersect<br/> + !#zh çƒå’Œçƒçš„相交性检测。 + @param sphere0 sphere0 + @param sphere1 sphere1 + */ + static sphere_sphere(sphere0: geomUtils.Sphere, sphere1: geomUtils.Sphere): boolean; + /** + !#en sphere-aabb intersect<br/> + !#zh çƒå’Œè½´å¯¹é½åŒ…围盒的相交性检测。 + @param sphere sphere + @param aabb aabb + */ + static sphere_aabb(sphere: geomUtils.Sphere, aabb: Aabb): boolean; + /** + !#en sphere-obb intersect<br/> + !#zh çƒå’Œæ–¹å‘包围盒的相交性检测。 + @param sphere sphere + @param obb obb + */ + static sphere_obb(sphere: geomUtils.Sphere, obb: geomUtils.Obb): boolean; + /** + !#en + The intersection detection of g1 and g2 can fill in the shape in the basic geometry. + !#zh + g1 å’Œ g2 的相交性检测,å¯å¡«å…¥åŸºç¡€å‡ 何ä¸çš„形状。 + @param g1 Geometry 1 + @param g2 Geometry 2 + @param outPt optional, Intersection point. (note: only partial shape detection with this return value) + */ + static resolve(g1: any, g2: any, outPt: any): void; } } /**************************************************** - * Sprite + * geomUtils *****************************************************/ - export namespace Sprite { - /** !#en Enum for sprite type. - !#zh Sprite 类型 */ - export enum Type { - SIMPLE = 0, - SLICED = 0, - TILED = 0, - FILLED = 0, - MESH = 0, + export namespace geomUtils { + /** !#en + line + !#zh + 直线 */ + export class Line { + /** + !#en + create a new line + !#zh + 创建一个新的 line。 + @param sx The x part of the starting point. + @param sy The y part of the starting point. + @param sz The z part of the starting point. + @param ex The x part of the end point. + @param ey The y part of the end point. + @param ez The z part of the end point. + */ + create(sx: number, sy: number, sz: number, ex: number, ey: number, ez: number): Line; + /** + !#en + Creates a new line initialized with values from an existing line + !#zh + 克隆一个新的 line。 + @param a The source of cloning. + */ + clone(a: Line): Line; + /** + !#en + Copy the values from one line to another + !#zh + å¤åˆ¶ä¸€ä¸ªçº¿çš„值到å¦ä¸€ä¸ªã€‚ + @param out The object that accepts the action. + @param a The source of the copy. + */ + copy(out: Line, a: Line): Line; + /** + !#en + create a line from two points + !#zh + 用两个点创建一个线。 + @param out The object that accepts the action. + @param start The starting point. + @param end At the end. + */ + fromPoints(out: Line, start: Vec3, end: Vec3): Line; + /** + !#en + Set the components of a Vec3 to the given values + !#zh + 将给定线的属性设置为给定值。 + @param out The object that accepts the action. + @param sx The x part of the starting point. + @param sy The y part of the starting point. + @param sz The z part of the starting point. + @param ex The x part of the end point. + @param ey The y part of the end point. + @param ez The z part of the end point. + */ + set(out: Line, sx: number, sy: number, sz: number, ex: number, ey: number, ez: number): Line; + /** + !#en + Calculate the length of the line. + !#zh + 计算线的长度。 + @param a The line to calculate. + */ + len(a: Line): number; + /** !#en + Start points. + !#zh + 起点。 */ + s: Vec3; + /** !#en + End points. + !#zh + 终点。 */ + e: Vec3; + /** + !#en + Calculate the length of the line. + !#zh + 计算线的长度。 + */ + length(): number; } } /**************************************************** - * Sprite + * geomUtils *****************************************************/ - export namespace Sprite { - /** !#en Enum for fill type. - !#zh 填充类型 */ - export enum FillType { - HORIZONTAL = 0, - VERTICAL = 0, - RADIAL = 0, + export namespace geomUtils { + /** !#en obb + !#zh + åŸºç¡€å‡ ä½• æ–¹å‘包围盒。 */ + export class Obb { + /** !#zh + 获å–形状的类型。 */ + type: number; + /** + !#en + create a new obb + !#zh + 创建一个新的 obb 实例。 + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param hw Obb is half the width. + @param hh Obb is half the height. + @param hl Obb is half the Length. + @param ox_1 Direction matrix parameter. + @param ox_2 Direction matrix parameter. + @param ox_3 Direction matrix parameter. + @param oy_1 Direction matrix parameter. + @param oy_2 Direction matrix parameter. + @param oy_3 Direction matrix parameter. + @param oz_1 Direction matrix parameter. + @param oz_2 Direction matrix parameter. + @param oz_3 Direction matrix parameter. + */ + create(cx: number, cy: number, cz: number, hw: number, hh: number, hl: number, ox_1: number, ox_2: number, ox_3: number, oy_1: number, oy_2: number, oy_3: number, oz_1: number, oz_2: number, oz_3: number): Obb; + /** + !#en + clone a new obb + !#zh + 克隆一个 obb。 + @param a The target of cloning. + */ + clone(a: Obb): Obb; + /** + !#en + copy the values from one obb to another + !#zh + 将从一个 obb 的值å¤åˆ¶åˆ°å¦ä¸€ä¸ª obb。 + @param out Obb that accepts the operation. + @param a Obb being copied. + */ + copy(out: Obb, a: Obb): Obb; + /** + !#en + create a new obb from two corner points + !#zh + 用两个点创建一个新的 obb。 + @param out Obb that accepts the operation. + @param minPos The smallest point of obb. + @param maxPos Obb's maximum point. + */ + fromPoints(out: Obb, minPos: Vec3, maxPos: Vec3): Obb; + /** + !#en + Set the components of a obb to the given values + !#zh + 将给定 obb 的属性设置为给定的值。 + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param hw Obb is half the width. + @param hh Obb is half the height. + @param hl Obb is half the Length. + @param ox_1 Direction matrix parameter. + @param ox_2 Direction matrix parameter. + @param ox_3 Direction matrix parameter. + @param oy_1 Direction matrix parameter. + @param oy_2 Direction matrix parameter. + @param oy_3 Direction matrix parameter. + @param oz_1 Direction matrix parameter. + @param oz_2 Direction matrix parameter. + @param oz_3 Direction matrix parameter. + */ + set(cx: number, cy: number, cz: number, hw: number, hh: number, hl: number, ox_1: number, ox_2: number, ox_3: number, oy_1: number, oy_2: number, oy_3: number, oz_1: number, oz_2: number, oz_3: number): Obb; + /** !#en + The center of the local coordinate. + !#zh + æœ¬åœ°åæ ‡çš„ä¸å¿ƒç‚¹ã€‚ */ + center: Vec3; + /** !#en + Half the length, width, and height. + !#zh + 长宽高的一åŠã€‚ */ + halfExtents: Vec3; + /** !#en + Direction matrix. + !#zh + æ–¹å‘矩阵。 */ + orientation: Mat3; + /** + !#en + Get the bounding points of this shape + !#zh + èŽ·å– obb 的最å°ç‚¹å’Œæœ€å¤§ç‚¹ã€‚ + @param minPos minPos + @param maxPos maxPos + */ + getBoundary(minPos: Vec3, maxPos: Vec3): void; + /** + !#en Transform this shape + !#zh + å°† out æ ¹æ®è¿™ä¸ª obb 的数æ®è¿›è¡Œå˜æ¢ã€‚ + @param m The transformation matrix. + @param pos The position part of the transformation. + @param rot The rotating part of the transformation. + @param scale The scaling part of the transformation. + @param out Target of transformation. + */ + transform(m: Mat4, pos: Vec3, rot: Quat, scale: Vec3, out: Obb): void; + /** + !#en + Transform out based on this obb data. + !#zh + å°† out æ ¹æ®è¿™ä¸ª obb 的数æ®è¿›è¡Œå˜æ¢ã€‚ + @param m The transformation matrix. + @param rot The rotating part of the transformation. + @param out Target of transformation. + */ + translateAndRotate(m: Mat4, rot: Quat, out: Obb): void; + /** + !#en + Scale out based on this obb data. + !#zh + å°† out æ ¹æ®è¿™ä¸ª obb 的数æ®è¿›è¡Œç¼©æ”¾ã€‚ + @param scale Scale value. + @param out Scaled target. + */ + setScale(scale: Vec3, out: Obb): void; } } /**************************************************** - * Sprite + * geomUtils *****************************************************/ - export namespace Sprite { - /** !#en Sprite Size can track trimmed size, raw size or none. - !#zh ç²¾çµå°ºå¯¸è°ƒæ•´æ¨¡å¼ */ - export enum SizeMode { - CUSTOM = 0, - TRIMMED = 0, - RAW = 0, + export namespace geomUtils { + /** !#en + plane。 + !#zh + å¹³é¢ã€‚ */ + export class Plane { + /** + !#en + create a new plane + !#zh + 创建一个新的 plane。 + @param nx The x part of the normal component. + @param ny The y part of the normal component. + @param nz The z part of the normal component. + @param d Distance from the origin. + */ + create(nx: number, ny: number, nz: number, d: number): Plane; + /** + !#en + clone a new plane + !#zh + 克隆一个新的 plane。 + @param p The source of cloning. + */ + clone(p: Plane): Plane; + /** + !#en + copy the values from one plane to another + !#zh + å¤åˆ¶ä¸€ä¸ªå¹³é¢çš„值到å¦ä¸€ä¸ªã€‚ + @param out The object that accepts the action. + @param p The source of the copy. + */ + copy(out: Plane, p: Plane): Plane; + /** + !#en + create a plane from three points + !#zh + 用三个点创建一个平é¢ã€‚ + @param out The object that accepts the action. + @param a Point a。 + @param b Point b。 + @param c Point c。 + */ + fromPoints(out: Plane, a: Vec3, b: Vec3, c: Vec3): Plane; + /** + !#en + Set the components of a plane to the given values + !#zh + 将给定平é¢çš„属性设置为给定值。 + @param out The object that accepts the action. + @param nx The x part of the normal component. + @param ny The y part of the normal component. + @param nz The z part of the normal component. + @param d Distance from the origin. + */ + set(out: Plane, nx: number, ny: number, nz: number, d: number): Plane; + /** + !#en + create plane from normal and point + !#zh + ç”¨ä¸€æ¡æ³•线和一个点创建平é¢ã€‚ + @param out The object that accepts the action. + @param normal The normal of a plane. + @param point A point on the plane. + */ + fromNormalAndPoint(out: Plane, normal: Vec3, point: Vec3): Plane; + /** + !#en + normalize a plane + !#zh + 归一化一个平é¢ã€‚ + @param out The object that accepts the action. + @param a Source data for operations. + */ + normalize(out: Plane, a: Plane): Plane; + /** !#en + A normal vector. + !#zh + 法线å‘é‡ã€‚ */ + n: Vec3; + /** !#en + The distance from the origin to the plane. + !#zh + 原点到平é¢çš„è·ç¦»ã€‚ */ + d: number; + /** + !#en + Transform a plane. + !#zh + å˜æ¢ä¸€ä¸ªå¹³é¢ã€‚ + @param mat mat + */ + transform(mat: Mat4): void; } } /**************************************************** - * Sprite + * geomUtils *****************************************************/ - export namespace Sprite { - /** !#en Sprite state can choice the normal or grayscale. - !#zh ç²¾çµé¢œè‰²é€šé“模å¼ã€‚ */ - export enum State { - NORMAL = 0, - GRAY = 0, + export namespace geomUtils { + /** !#en + ray + !#zh + 射线。 */ + export class Ray { + /** + !#en + create a new ray + !#zh + 创建一æ¡å°„线。 + @param ox The x part of the starting point. + @param oy The y part of the starting point. + @param oz The z part of the starting point. + @param dx X in the direction. + @param dy Y in the direction. + @param dz Z in the direction. + */ + create(ox: number, oy: number, oz: number, dx: number, dy: number, dz: number): Ray; + /** + !#en + Creates a new ray initialized with values from an existing ray + !#zh + 从一æ¡å°„çº¿å…‹éš†å‡ºä¸€æ¡æ–°çš„射线。 + @param a Clone target + */ + clone(a: Ray): Ray; + /** + !#en + Copy the values from one ray to another + !#zh + 将从一个 ray 的值å¤åˆ¶åˆ°å¦ä¸€ä¸ª ray。 + @param out Accept the ray of the operation. + @param a Copied ray. + */ + copy(out: Ray, a: Ray): Ray; + /** + !#en + create a ray from two points + !#zh + 用两个点创建一æ¡å°„线。 + @param out Receive the operating ray. + @param origin Origin of ray + @param target A point on a ray. + */ + fromPoints(out: Ray, origin: Vec3, target: Vec3): Ray; + /** + !#en + Set the components of a ray to the given values + !#zh + 将给定射线的属性设置为给定的值。 + @param out Receive the operating ray. + @param ox The x part of the starting point. + @param oy The y part of the starting point. + @param oz The z part of the starting point. + @param dx X in the direction. + @param dy Y in the direction. + @param dz Z in the direction. + */ + set(out: Ray, ox: number, oy: number, oz: number, dx: number, dy: number, dz: number): Ray; + /** !#en + Start point. + !#zh + 起点。 */ + o: Vec3; + /** !#e + Direction + !#zh + æ–¹å‘。 */ + d: Vec3; + /** + !#en Compute hit. + @param out out + @param distance distance + */ + computeHit(out: IVec3Like, distance: number): void; } } /**************************************************** - * Widget + * geomUtils *****************************************************/ - export namespace Widget { - /** !#en Enum for Widget's alignment mode, indicating when the widget should refresh. - !#zh Widget çš„å¯¹é½æ¨¡å¼ï¼Œè¡¨ç¤º Widget 应该何时刷新。 */ - export enum AlignMode { - ONCE = 0, - ON_WINDOW_RESIZE = 0, - ALWAYS = 0, + export namespace geomUtils { + /** !#en + Sphere. + !#zh + 轴对é½çƒã€‚ */ + export class Sphere { + /** + !#en + create a new sphere + !#zh + 创建一个新的 sphere 实例。 + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param r Radius of sphere + */ + create(cx: any, cy: any, cz: any, r: any): Sphere; + /** + !#en + clone a new sphere + !#zh + 克隆一个新的 sphere 实例。 + @param p The target of cloning. + */ + clone(p: Sphere): Sphere; + /** + !#en + copy the values from one sphere to another + !#zh + 将从一个 sphere 的值å¤åˆ¶åˆ°å¦ä¸€ä¸ª sphere。 + @param out Accept the sphere of operations. + @param a Sphere being copied. + */ + copy(out: Sphere, a: Sphere): Sphere; + /** + !#en + create a new bounding sphere from two corner points + !#zh + 从两个点创建一个新的 sphere。 + @param out Accept the sphere of operations. + @param minPos The smallest point of sphere. + @param maxPos The maximum point of sphere. + */ + fromPoints(out: any, minPos: any, maxPos: any): Sphere; + /** + !#en Set the components of a sphere to the given values + !#zh å°†çƒä½“的属性设置为给定的值。 + @param out Accept the sphere of operations. + @param cx X coordinates of the shape relative to the origin. + @param cy Y coordinates of the shape relative to the origin. + @param cz Z coordinates of the shape relative to the origin. + @param r Radius. + */ + set(out: Sphere, cx: any, cy: any, cz: any, r: number): Sphere; + /** !#en + The center of the local coordinate. + !#zh + æœ¬åœ°åæ ‡çš„ä¸å¿ƒç‚¹ã€‚ */ + center: Vec3; + /** !#zh + åŠå¾„。 */ + radius: number; + /** + !#en + Clone. + !#zh + 获得克隆。 + */ + clone(): void; + /** + !#en + Copy sphere + !#zh + æ‹·è´å¯¹è±¡ã€‚ + @param a Copy target. + */ + copy(a: any): void; + /** + !#en + Get the bounding points of this shape + !#zh + èŽ·å–æ¤å½¢çŠ¶çš„è¾¹ç•Œç‚¹ã€‚ + @param minPos minPos + @param maxPos maxPos + */ + getBoundary(minPos: Vec3, maxPos: Vec3): void; + /** + !#en + Transform this shape + !#zh + å°† out æ ¹æ®è¿™ä¸ª sphere 的数æ®è¿›è¡Œå˜æ¢ã€‚ + @param m The transformation matrix. + @param pos The position part of the transformation. + @param rot The rotating part of the transformation. + @param scale The scaling part of the transformation. + @param out The target of the transformation. + */ + transform(m: any, pos: any, rot: any, scale: any, out: any): void; + /** + !#en + Scale out based on the sphere data. + !#zh + å°† out æ ¹æ®è¿™ä¸ª sphere 的数æ®è¿›è¡Œç¼©æ”¾ã€‚ + @param scale Scale value + @param out Scale target + */ + setScale(scale: any, out: any): void; } } /**************************************************** - * Event + * geomUtils *****************************************************/ - export namespace Event { - /** !#en The Custom event - !#zh 自定义事件 */ - export class EventCustom extends Event { + export namespace geomUtils { + /** Triangle */ + export class Triangle { /** - - @param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit" - @param bubbles A boolean indicating whether the event bubbles up through the tree or not + create a new triangle + @param ax ax + @param ay ay + @param az az + @param bx bx + @param by by + @param bz bz + @param cx cx + @param cy cy + @param cz cz */ - constructor(type: string, bubbles: boolean); - /** !#en A reference to the detailed data of the event - !#zh äº‹ä»¶çš„è¯¦ç»†æ•°æ® */ - detail: any; + create(ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): Triangle; /** - !#en Sets user data - !#zh è®¾ç½®ç”¨æˆ·æ•°æ® - @param data data + clone a new triangle + @param t the source plane */ - setUserData(data: any): void; + clone(t: Triangle): Triangle; /** - !#en Gets user data - !#zh 获å–ç”¨æˆ·æ•°æ® + copy the values from one triangle to another + @param out the receiving triangle + @param t the source triangle */ - getUserData(): any; + copy(out: Triangle, t: Triangle): Triangle; /** - !#en Gets event name - !#zh 获å–事件åç§° + Create a triangle from three points + @param out the receiving triangle + @param a a + @param b b + @param c c */ - getEventName(): string; + fromPoints(out: Triangle, a: Vec3, b: Vec3, c: Vec3): Triangle; + /** + Set the components of a triangle to the given values + @param out the receiving plane + @param ax X component of a + @param ay Y component of a + @param az Z component of a + @param bx X component of b + @param by Y component of b + @param bz Z component of b + @param cx X component of c + @param cy Y component of c + @param cz Z component of c + */ + set(out: Triangle, ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): Plane; + a: Vec3; + b: Vec3; + c: Vec3; } } /**************************************************** - * SystemEvent + * MeshRenderer *****************************************************/ - export namespace SystemEvent { - /** !#en The event type supported by SystemEvent - !#zh SystemEvent 支æŒçš„事件类型 */ - export class EventType { - /** !#en The event type for press the key down event, you can use its value directly: 'keydown' - !#zh 当按下按键时触å‘的事件 */ - static KEY_DOWN: string; - /** !#en The event type for press the key up event, you can use its value directly: 'keyup' - !#zh 当æ¾å¼€æŒ‰é”®æ—¶è§¦å‘的事件 */ - static KEY_UP: string; - /** !#en The event type for press the devicemotion event, you can use its value directly: 'devicemotion' - !#zh é‡åŠ›æ„Ÿåº” */ - static DEVICEMOTION: string; - } - } + export namespace MeshRenderer { + /** !#en Shadow projection mode - /**************************************************** - * PhysicsManager - *****************************************************/ - - export namespace PhysicsManager { - /** !#en - The draw bits for drawing physics debug information.<br> - example:<br> - ```js - cc.director.getPhysicsManager().debugDrawFlags = - // cc.PhysicsManager.DrawBits.e_aabbBit | - // cc.PhysicsManager.DrawBits.e_pairBit | - // cc.PhysicsManager.DrawBits.e_centerOfMassBit | - cc.PhysicsManager.DrawBits.e_jointBit | - cc.PhysicsManager.DrawBits.e_shapeBit; - ``` - !#zh - 指定物ç†ç³»ç»Ÿéœ€è¦ç»˜åˆ¶å“ªäº›è°ƒè¯•ä¿¡æ¯ã€‚<br> - example:<br> - ```js - cc.director.getPhysicsManager().debugDrawFlags = - // cc.PhysicsManager.DrawBits.e_aabbBit | - // cc.PhysicsManager.DrawBits.e_pairBit | - // cc.PhysicsManager.DrawBits.e_centerOfMassBit | - cc.PhysicsManager.DrawBits.e_jointBit | - cc.PhysicsManager.DrawBits.e_shapeBit; - ``` */ - export enum DrawBits { - e_aabbBit = 0, - e_jointBit = 0, - e_shapeBit = 0, + !#ch é˜´å½±æŠ•å°„æ–¹å¼ */ + export enum ShadowCastingMode { + OFF = 0, + ON = 0, } } @@ -19408,6 +19489,60 @@ declare namespace cc { } } + /**************************************************** + * PhysicsManager + *****************************************************/ + + export namespace PhysicsManager { + /** !#en + The draw bits for drawing physics debug information.<br> + example:<br> + ```js + cc.director.getPhysicsManager().debugDrawFlags = + // cc.PhysicsManager.DrawBits.e_aabbBit | + // cc.PhysicsManager.DrawBits.e_pairBit | + // cc.PhysicsManager.DrawBits.e_centerOfMassBit | + cc.PhysicsManager.DrawBits.e_jointBit | + cc.PhysicsManager.DrawBits.e_shapeBit; + ``` + !#zh + 指定物ç†ç³»ç»Ÿéœ€è¦ç»˜åˆ¶å“ªäº›è°ƒè¯•ä¿¡æ¯ã€‚<br> + example:<br> + ```js + cc.director.getPhysicsManager().debugDrawFlags = + // cc.PhysicsManager.DrawBits.e_aabbBit | + // cc.PhysicsManager.DrawBits.e_pairBit | + // cc.PhysicsManager.DrawBits.e_centerOfMassBit | + cc.PhysicsManager.DrawBits.e_jointBit | + cc.PhysicsManager.DrawBits.e_shapeBit; + ``` */ + export enum DrawBits { + e_aabbBit = 0, + e_jointBit = 0, + e_shapeBit = 0, + } + } + + /**************************************************** + * AnimationCurve + *****************************************************/ + + export namespace AnimationCurve { + /** !#en The wrap mode + !#zh å¾ªçŽ¯æ¨¡å¼ */ + export enum WrapMode { + Default = 0, + Once = 0, + Loop = 0, + PingPong = 0, + ClampForever = 0, + time = 0, + value = 0, + inTangent = 0, + outTangent = 0, + } + } + /**************************************************** * ParticleSystem3DAssembler *****************************************************/ @@ -19627,14 +19762,6 @@ properties and constants of Spine are defined in this namespace Spine 的全局的命å空间, 与 Spine 相关的所有的类,函数,属性,常é‡éƒ½åœ¨è¿™ä¸ªå‘½å空间ä¸å®šä¹‰ã€‚ */ declare namespace sp { - /** !#en The event type of spine skeleton animation. - !#zh 骨骼动画事件类型。 */ - export enum AnimationEventType { - START = 0, - END = 0, - COMPLETE = 0, - EVENT = 0, - } /** !#en The skeleton of Spine <br/> <br/> @@ -20034,6 +20161,14 @@ declare namespace sp { */ getRuntimeData(quiet?: boolean): sp.spine.SkeletonData; } + /** !#en The event type of spine skeleton animation. + !#zh 骨骼动画事件类型。 */ + export enum AnimationEventType { + START = 0, + END = 0, + COMPLETE = 0, + EVENT = 0, + } /** !#en The delegate of spine vertex effect !#zh @@ -20164,15 +20299,15 @@ declare namespace dragonBones { /** !#en The Armature Display of DragonBones <br/> <br/> - (Armature Display has a reference to a DragonBonesAsset and stores the state for ArmatureDisplay instance, + Armature Display has a reference to a DragonBonesAsset and stores the state for ArmatureDisplay instance, which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible. <br/> - Multiple Armature Display can use the same DragonBonesAsset which includes all animations, skins, and attachments.) <br/> + Multiple Armature Display can use the same DragonBonesAsset which includes all animations, skins, and attachments. <br/> !#zh DragonBones 骨骼动画 <br/> <br/> - (Armature Display 具有对骨骼数æ®çš„引用并且å˜å‚¨äº†éª¨éª¼å®žä¾‹çš„状æ€ï¼Œ + Armature Display 具有对骨骼数æ®çš„引用并且å˜å‚¨äº†éª¨éª¼å®žä¾‹çš„状æ€ï¼Œ 它由当å‰çš„骨骼动作,slot 颜色,和å¯è§çš„ slot attachments 组æˆã€‚<br/> - 多个 Armature Display å¯ä»¥ä½¿ç”¨ç›¸åŒçš„骨骼数æ®ï¼Œå…¶ä¸åŒ…括所有的动画,皮肤和 attachments。)<br/> */ + 多个 Armature Display å¯ä»¥ä½¿ç”¨ç›¸åŒçš„骨骼数æ®ï¼Œå…¶ä¸åŒ…括所有的动画,皮肤和 attachments。<br/> */ export class ArmatureDisplay extends cc.RenderComponent { /** !#en The DragonBones data contains the armatures information (bind pose bones, slots, draw order, @@ -20632,12 +20767,14 @@ declare namespace cc.AssetManager { bundle2.load('imgs/cocos', cc.SpriteFrame, null, (err, spriteFrame) => console.log(err)); ``` */ - load<T extends cc.Asset>(paths: string|string[], type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: T|Array<T>) => void): void; - load<T extends cc.Asset>(paths: string|string[], onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: T|Array<T>) => void): void; - load<T extends cc.Asset>(paths: string|string[], type: typeof cc.Asset, onComplete: (error: Error, assets: T|Array<T>) => void): void; - load<T extends cc.Asset>(paths: string|string[], onComplete: (error: Error, assets: T|Array<T>) => void): void; - load<T extends cc.Asset>(paths: string|string[], type: typeof cc.Asset): void; - load<T extends cc.Asset>(paths: string|string[]): void; + load<T extends cc.Asset>(paths: string, type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: T) => void): void; + load<T extends cc.Asset>(paths: string[], type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array<T>) => void): void; + load<T extends cc.Asset>(paths: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: T) => void): void; + load<T extends cc.Asset>(paths: string[], onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array<T>) => void): void; + load<T extends cc.Asset>(paths: string, type: typeof cc.Asset, onComplete?: (error: Error, assets: T) => void): void; + load<T extends cc.Asset>(paths: string[], type: typeof cc.Asset, onComplete?: (error: Error, assets: Array<T>) => void): void; + load<T extends cc.Asset>(paths: string, onComplete?: (error: Error, assets: T) => void): void; + load<T extends cc.Asset>(paths: string[], onComplete?: (error: Error, assets: Array<T>) => void): void; /** !#en Preload the asset within this bundle by the path which is relative to bundle's path. @@ -20772,8 +20909,8 @@ declare namespace cc.AssetManager { loadScene(sceneName: string, options: Record<string, any>, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void; loadScene(sceneName: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void; loadScene(sceneName: string, options: Record<string, any>, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void; - loadScene(sceneName: string, options: Record<string, any>): void; loadScene(sceneName: string, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void; + loadScene(sceneName: string, options: Record<string, any>): void; loadScene(sceneName: string): void; /** !#en @@ -20798,8 +20935,8 @@ declare namespace cc.AssetManager { preloadScene(sceneName: string, options: Record<string, any>, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error) => void): void; preloadScene(sceneName: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error) => void): void; preloadScene(sceneName: string, options: Record<string, any>, onComplete: (error: Error) => void): void; - preloadScene(sceneName: string, options: Record<string, any>): void; preloadScene(sceneName: string, onComplete: (error: Error) => void): void; + preloadScene(sceneName: string, options: Record<string, any>): void; preloadScene(sceneName: string): void; /** !#en @@ -20818,7 +20955,7 @@ declare namespace cc.AssetManager { bundle1.get('music/hit', cc.AudioClip); ``` */ - get (path: string, type?: typeof cc.Asset): cc.Asset; + get<T extends cc.Asset> (path: string, type?: typeof cc.Asset): T; /** !#en Release the asset loaded by {{#crossLink "Bundle/load:method"}}{{/crossLink}} or {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} and it's dependencies. @@ -20878,17 +21015,23 @@ declare namespace cc.AssetManager { 是å¦åœ¨å˜å‚¨ç©ºé—´æ»¡äº†åŽè‡ªåŠ¨æ¸…ç†ç¼“å˜ï¼Œæ¤å±žæ€§åªåœ¨å°æ¸¸æˆå¹³å°æœ‰æ•ˆ */ autoClear: boolean; /** !#en - The interval between caching resources, this property only works on mini-game platforms + The interval between caching resources, this property only works on mini-game platforms, unit: ms !#zh - 缓å˜èµ„æºçš„间隔时间,æ¤å±žæ€§åªåœ¨å°æ¸¸æˆå¹³å°æœ‰æ•ˆ */ + 缓å˜èµ„æºçš„间隔时间,æ¤å±žæ€§åªåœ¨å°æ¸¸æˆå¹³å°æœ‰æ•ˆï¼Œå•ä½ï¼šms */ cacheInterval: number; /** !#en - The interval between deleting resources, when you use `cleanLRU`, the resources will be deleted as this interval + The interval between deleting resources, when you use `cleanLRU`, the resources will be deleted as this interval, unit: ms !#zh - 清ç†èµ„æºçš„é—´éš”æ—¶é—´ï¼Œå½“ä½ ä½¿ç”¨ `cleanLRU` 时,资æºå°†ä»¥æ¤é—´éš”è¢«åˆ é™¤ */ + 清ç†èµ„æºçš„é—´éš”æ—¶é—´ï¼Œå½“ä½ ä½¿ç”¨ `cleanLRU` 时,资æºå°†ä»¥æ¤é—´éš”è¢«åˆ é™¤ï¼Œå•ä½ï¼šms */ deleteInterval: number; + /** !#en + List of all cached files + + !#zh + æ‰€æœ‰ç¼“å˜æ–‡ä»¶åˆ—表 */ + cachedFiles: Cache<{ bundle: string, url: string, lastTime: number }>; /** !#en Get cached path with origin url @@ -21134,6 +21277,12 @@ declare namespace cc.AssetManager { 4. èµ„æº 5. 脚本 */ export class Downloader { + /** !#en + The address of remote server + + !#zh + 远程æœåŠ¡å™¨åœ°å€ */ + remoteServerAddress: string; /** !#en The maximum number of concurrent when downloading @@ -21160,77 +21309,6 @@ declare namespace cc.AssetManager { retryInterval: number; /** !#en - Use Image element to download image - - !#zh - 使用 Image å…ƒç´ æ¥ä¸‹è½½å›¾ç‰‡ - @param url Url of the image - @param options Some optional paramters - @param onComplete Callback when image loaded or failed - - @example - ```js - downloadDomImage('http://example.com/test.jpg', null, (err, img) => console.log(err)); - ``` - */ - downloadDomImage(url: string, options?: Record<string, any> , onComplete?: (err: Error, img: HTMLImageElement) => void): HTMLImageElement; - downloadDomImage(url: string, onComplete?: (err: Error, img: HTMLImageElement) => void): HTMLImageElement; - /** - !#en - Use audio element to download audio - - !#zh - 使用 Audio å…ƒç´ æ¥ä¸‹è½½éŸ³é¢‘ - @param url Url of the audio - @param options Some optional paramters - @param onComplete Callback invoked when audio loaded or failed - - @example - ```js - downloadDomAudio('http://example.com/test.mp3', null, (err, audio) => console.log(err)); - ``` - */ - downloadDomAudio(url: string, options?: Record<string, any>, onComplete?: (err: Error, audio: HTMLAudioElement) => void): HTMLAudioElement; - downloadDomAudio(url: string, onComplete?: (err: Error, audio: HTMLAudioElement) => void): HTMLAudioElement; - /** - !#en - Use XMLHttpRequest to download file - - !#zh - 使用 XMLHttpRequest æ¥ä¸‹è½½æ–‡ä»¶ - @param url Url of the file - @param options Some optional paramters - @param onFileProgress Callback continuously during download is processing - @param onComplete Callback when file loaded or failed - - @example - ```js - downloadFile('http://example.com/test.bin', {responseType: 'arraybuffer'}, null, (err, arrayBuffer) => console.log(err)); - ``` - */ - downloadFile(url: string, options?: Record<string, any>, onFileProgress?: (loaded: Number, total: Number) => void, onComplete?: (err: Error, response: any) => void): XMLHttpRequest; - downloadFile(url: string, onFileProgress?: (loaded: Number, total: Number) => void, onComplete?: (err: Error, response: any) => void): XMLHttpRequest; - downloadFile(url: string, options?: Record<string, any>, onComplete?: (err: Error, response: any) => void): XMLHttpRequest; - downloadFile(url: string, onComplete?: (err: Error, response: any) => void): XMLHttpRequest; - /** - !#en - Load script - - !#zh - åŠ è½½è„šæœ¬ - @param url Url of the script - @param options Some optional paramters - @param onComplete Callback when script loaded or failed - - @example - ```js - downloadScript('http://localhost:8080/index.js', null, (err) => console.log(err)); - ``` - */ - downloadScript(url: string, options?: Record<string, any>, onComplete?: (err: Error) => void): void;; - downloadScript(url: string, onComplete?: (err: Error) => void): void;; - /** - !#en Register custom handler if you want to change default behavior or extend downloader to download other format file !#zh @@ -21295,7 +21373,7 @@ declare namespace cc.AssetManager { @example ```js - var url = 'res/import/fc/fc991dd7-0033-4b80-9d41-c8a86a702e59.json'; + var url = 'assets/main/import/fc/fc991dd7-0033-4b80-9d41-c8a86a702e59.json'; var uuid = getUuidFromURL(url); // fc991dd7-0033-4b80-9d41-c8a86a702e59 ``` */ @@ -21311,21 +21389,16 @@ declare namespace cc.AssetManager { @example ```js + // json path, 'assets/main/import/fc/fc991dd7-0033-4b80-9d41-c8a86a702e59.json'; var url = getUrlWithUuid('fcmR3XADNLgJ1ByKhqcC5Z', {isNative: false}); + + // png path, 'assets/main/native/fc/fc991dd7-0033-4b80-9d41-c8a86a702e59.png'; + var url = getUrlWithUuid('fcmR3XADNLgJ1ByKhqcC5Z', {isNative: true, nativeExt: '.png'}); ``` */ getUrlWithUuid(uuid: string, options?: Record<string, any>): string; /** !#en - Check if the type of data is cc.Scene or cc.Prefab - - !#zh - 检测数æ®çš„ç±»åž‹æ˜¯å¦æ˜¯ Scene 或者 Prefab - @param json serialized data - */ - isSceneObj(json: any): boolean; - /** - !#en Check if the type of asset is scene !#zh @@ -21344,6 +21417,89 @@ declare namespace cc.AssetManager { normalize(url: string): string; } /** !#en + Handle the packed asset, include unpacking, loading, cache and so on. It is a singleton. All member can be accessed with `cc.assetManager.packManager` + + !#zh + å¤„ç†æ‰“包资æºï¼ŒåŒ…æ‹¬æ‹†åŒ…ï¼ŒåŠ è½½ï¼Œç¼“å˜ç‰ç‰ï¼Œè¿™æ˜¯ä¸€ä¸ªå•例, 所有æˆå‘˜èƒ½é€šè¿‡ `cc.assetManager.packManager` 访问 */ + export class PackManager { + /** + !#en + Unpack the json, revert to what it was before packing + + !#zh + 拆解 json 包,æ¢å¤ä¸ºæ‰“包之å‰çš„内容 + @param pack The pack + @param json The content of pack + @param options Some optional parameters + @param onComplete Callback when finish unpacking + + @example + ```js + downloader.downloadFile('pack.json', {responseType: 'json'}, null, (err, file) => { + packManager.unpackJson(['a', 'b'], file, null, (err, data) => console.log(err)); + }); + ``` + */ + unpackJson(pack: string[], json: any, options: Record<string, any>, onComplete?: (err: Error, content: any) => void): void; + /** + !#en + Register custom handler if you want to change default behavior or extend packManager to unpack other format pack + + !#zh + å½“ä½ æƒ³ä¿®æ”¹é»˜è®¤è¡Œä¸ºæˆ–è€…æ‹“å±• packManager æ¥æ‹†åˆ†å…¶ä»–æ ¼å¼çš„包时å¯ä»¥æ³¨å†Œè‡ªå®šä¹‰çš„ handler + @param type Extension likes '.bin' or map likes {'.bin': binHandler, '.ab': abHandler} + @param handler handler + + @example + ```js + packManager.register('.bin', (packUuid, file, options, onComplete) => onComplete(null, null)); + packManager.register({'.bin': (packUuid, file, options, onComplete) => onComplete(null, null), '.ab': (packUuid, file, options, onComplete) => onComplete(null, null)}); + ``` + */ + register(type: string, handler: (packUuid: string, data: any, options: Record<string, any>, onComplete: (err: Error, content: any) => void) => void): void; + register(map: Record<string, (packUuid: string, data: any, options: Record<string, any>, onComplete: (err: Error, content: any) => void) => void>): void; + /** + !#en + Use corresponding handler to unpack package + + !#zh + 用对应的 handler æ¥è¿›è¡Œè§£åŒ… + @param pack The uuid of packed assets + @param data The packed data + @param type The type indicates that which handler should be used to download, such as '.jpg' + @param options Some optional parameter + @param onComplete callback when finishing unpacking + + @example + ```js + downloader.downloadFile('pack.json', {responseType: 'json'}, null, (err, file) => { + packManager.unpack(['2fawq123d', '1zsweq23f'], file, '.json', null, (err, data) => console.log(err)); + }); + ``` + */ + unpack(pack: string[], data: any, type: string, options: Record<string, any>, onComplete?: (err: Error, data: any) => void): void; + /** + !#en + Download request item, If item is not in any package, download as usual. Otherwise, download the corresponding package and unpack it. + And then retrieve the corresponding content form it. + + !#zh + 下载请求对象,如果请求对象ä¸åœ¨ä»»ä½•包内,则æ£å¸¸ä¸‹è½½ï¼Œå¦åˆ™ä¸‹è½½å¯¹åº”çš„ package 并进行拆解,并å–回包内对应的内容 + @param item Some item you want to download + @param options Some optional parameters + @param onComplete Callback when finished + + @example + ```js + var requestItem = cc.AssetManager.RequestItem.create(); + requestItem.uuid = 'fcmR3XADNLgJ1ByKhqcC5Z'; + requestItem.info = config.getAssetInfo('fcmR3XADNLgJ1ByKhqcC5Z'); + packManager.load(requestItem, null, (err, data) => console.log(err)); + ``` + */ + load(item: RequestItem, options: Record<string, any>, onComplete: (err: Error, data: any) => void): void; + } + /** !#en Parse the downloaded file, it's a singleton, all member can be accessed with `cc.assetManager.parser` !#zh @@ -21351,160 +21507,190 @@ declare namespace cc.AssetManager { export class Parser { /** !#en - Parse image file + Register custom handler if you want to change default behavior or extend parser to parse other format file !#zh - è§£æžå›¾ç‰‡æ–‡ä»¶ - @param file The downloaded file - @param options Some optional paramters - @param onComplete callback when finish parsing. + å½“ä½ æƒ³ä¿®æ”¹é»˜è®¤è¡Œä¸ºæˆ–è€…æ‹“å±• parser æ¥è§£æžå…¶ä»–æ ¼å¼æ–‡ä»¶æ—¶å¯ä»¥æ³¨å†Œè‡ªå®šä¹‰çš„handler + @param type Extension likes '.jpg' or map likes {'.jpg': jpgHandler, '.png': pngHandler} + @param handler The corresponding handler @example ```js - downloader.downloadFile('test.jpg', {responseType: 'blob'}, null, (err, file) => { - parser.parseImage(file, null, (err, img) => console.log(err)); - }); + parser.register('.tga', (file, options, onComplete) => onComplete(null, null)); + parser.register({'.tga': (file, options, onComplete) => onComplete(null, null), '.ext': (file, options, onComplete) => onComplete(null, null)}); ``` */ - parseImage(file: Blob, options: Record<string, any>, onComplete?: (err: Error, img: ImageBitmap|HTMLImageElement) => void): void; + register(type: string, handler: (file: any, options: Record<string, any>, onComplete: (err: Error, data: any) => void) => void): void; + register(map: Record<string, (file: any, options: Record<string, any>, onComplete: (err: Error, data: any) => void) => void>): void; /** !#en - Parse audio file + Use corresponding handler to parse file !#zh - è§£æžéŸ³é¢‘文件 - @param file The downloaded file - @param options Some optional paramters - @param onComplete Callback when finish parsing. + 使用对应的handleræ¥è§£æžæ–‡ä»¶ + @param id The id of file + @param file File + @param type The corresponding type of file, likes '.jpg'. + @param options Some optional paramters will be transferred to the corresponding handler. + @param onComplete callback when finishing downloading @example ```js - downloader.downloadFile('test.mp3', {responseType: 'arraybuffer'}, null, (err, file) => { - parser.parseAudio(file, null, (err, audio) => console.log(err)); + downloader.downloadFile('test.jpg', {responseType: 'blob'}, null, (err, file) => { + parser.parse('test.jpg', file, '.jpg', null, (err, img) => console.log(err)); }); ``` */ - parseAudio(file: ArrayBuffer|HTMLAudioElement, options: Record<string, any>, onComplete?: (err: Error, audio: AudioBuffer|HTMLAudioElement) => void): void; + parse(id: string, file: any, type: string, options: Record<string, any>, onComplete: (err: Error, content: any) => void): void; + } + /** !#en + Pipeline can execute the task for some effect. + + !#zh + 管线能执行任务达到æŸä¸ªæ•ˆæžœ */ + export class Pipeline { + /** !#en + The id of pipeline + + !#zh + 管线的 id */ + id: number; + /** !#en + The name of pipeline + + !#zh + 管线的åå— */ + name: string; + /** !#en + All pipes of pipeline + + !#zh + æ‰€æœ‰çš„ç®¡é“ */ + pipes: Function[]; /** !#en - Parse pvr file + Create a new pipeline !#zh - è§£æžåŽ‹ç¼©çº¹ç†æ ¼å¼ pvr 文件 - @param file The downloaded file - @param options Some optional paramters - @param onComplete Callback when finish parsing. + 创建一个管线 + @param name The name of pipeline + @param funcs The array of pipe, every pipe must be function which take two parameters, the first is a `Task` flowed in pipeline, the second is complete callback @example ```js - downloader.downloadFile('test.pvr', {responseType: 'arraybuffer'}, null, (err, file) => { - parser.parsePVRTex(file, null, (err, pvrAsset) => console.log(err)); - }); + var pipeline = new Pipeline('download', [ + (task, done) => { + var url = task.input; + cc.assetManager.downloader.downloadFile(url, null, null, (err, result) => { + task.output = result; + done(err); + }); + }, + (task, done) => { + var text = task.input; + var json = JSON.stringify(text); + task.output = json; + done(); + } + ]); ``` */ - parsePVRTex(file: ArrayBuffer|ArrayBufferView, options: Record<string, any>, onComplete: (err: Error, pvrAsset: {_data: Uint8Array, _compressed: boolean, width: number, height: number}) => void): void; + constructor(name: string, funcs: Array<(task: Task, done?: (err: Error) => void) => void>); /** !#en - Parse pkm file + At specific point insert a new pipe to pipeline !#zh - è§£æžåŽ‹ç¼©çº¹ç†æ ¼å¼ pkm 文件 - @param file The downloaded file - @param options Some optional paramters - @param onComplete Callback when finish parsing. + 在æŸä¸ªç‰¹å®šçš„点为管线æ’入一个新的 pipe + @param func The new pipe + @param index The specific point you want to insert at. @example ```js - downloader.downloadFile('test.pkm', {responseType: 'arraybuffer'}, null, (err, file) => { - parser.parsePKMTex(file, null, (err, etcAsset) => console.log(err)); - }); + var pipeline = new Pipeline('test', []); + pipeline.insert((task, done) => { + // do something + done(); + }, 0); ``` */ - parsePKMTex(file: ArrayBuffer|ArrayBufferView, options: Record<string, any>, onComplete: (err: Error, etcAsset: {_data: Uint8Array, _compressed: boolean, width: number, height: number}) => void): void; + insert(func: (task: Task, callback?: (err: Error) => void) => void, index: number): Pipeline; /** !#en - Parse plist file + Append a new pipe to the pipeline !#zh - è§£æž plist 文件 - @param file The downloaded file - @param options Some optional paramters - @param onComplete Callback when finish parsing + æ·»åŠ ä¸€ä¸ªç®¡é“åˆ°ç®¡çº¿ä¸ + @param func The new pipe @example ```js - downloader.downloadFile('test.plist', {responseType: 'text'}, null, (err, file) => { - parser.parsePlist(file, null, (err, data) => console.log(err)); + var pipeline = new Pipeline('test', []); + pipeline.append((task, done) => { + // do something + done(); }); ``` */ - parsePlist(file: string, options: Record<string, any>, onComplete?: (err: Error, data: any) => void): void; + append(func: (task: Task, callback?: (err: Error) => void) => void): Pipeline; /** !#en - Deserialize asset file + Remove pipe which at specific point !#zh - ååºåˆ—åŒ–èµ„æºæ–‡ä»¶ - @param file The serialized json - @param options Some optional paramters - @param onComplete Callback when finish parsing + 移除特定ä½ç½®çš„ç®¡é“ + @param index The specific point @example ```js - downloader.downloadFile('test.json', {responseType: 'json'}, null, (err, file) => { - parser.parseImport(file, null, (err, data) => console.log(err)); + var pipeline = new Pipeline('test', (task, done) => { + // do something + done(); }); + pipeline.remove(0); ``` */ - parseImport (file: any, options: Record<string, any>, onComplete?: (err: Error, asset: cc.Asset) => void): void; + remove(index: number): Pipeline; /** !#en - Register custom handler if you want to change default behavior or extend parser to parse other format file + Execute task synchronously !#zh - å½“ä½ æƒ³ä¿®æ”¹é»˜è®¤è¡Œä¸ºæˆ–è€…æ‹“å±• parser æ¥è§£æžå…¶ä»–æ ¼å¼æ–‡ä»¶æ—¶å¯ä»¥æ³¨å†Œè‡ªå®šä¹‰çš„handler - @param type Extension likes '.jpg' or map likes {'.jpg': jpgHandler, '.png': pngHandler} - @param handler The corresponding handler + åŒæ¥æ‰§è¡Œä»»åŠ¡ + @param task The task will be executed @example ```js - parser.register('.tga', (file, options, onComplete) => onComplete(null, null)); - parser.register({'.tga': (file, options, onComplete) => onComplete(null, null), '.ext': (file, options, onComplete) => onComplete(null, null)}); + var pipeline = new Pipeline('sync', [(task) => { + let input = task.input; + task.output = doSomething(task.input); + }]); + + var task = new Task({input: 'test'}); + console.log(pipeline.sync(task)); ``` */ - register(type: string, handler: (file: any, options: Record<string, any>, onComplete: (err: Error, data: any) => void) => void): void; - register(map: Record<string, (file: any, options: Record<string, any>, onComplete: (err: Error, data: any) => void) => void>): void; + sync(task: Task): any; /** !#en - Use corresponding handler to parse file + Execute task asynchronously !#zh - 使用对应的handleræ¥è§£æžæ–‡ä»¶ - @param id The id of file - @param file File - @param type The corresponding type of file, likes '.jpg'. - @param options Some optional paramters will be transferred to the corresponding handler. - @param onComplete callback when finishing downloading + å¼‚æ¥æ‰§è¡Œä»»åŠ¡ + @param task The task will be executed @example ```js - downloader.downloadFile('test.jpg', {responseType: 'blob'}, null, (err, file) => { - parser.parse('test.jpg', file, '.jpg', null, (err, img) => console.log(err)); - }); + var pipeline = new Pipeline('sync', [(task, done) => { + let input = task.input; + task.output = doSomething(task.input); + done(); + }]); + var task = new Task({input: 'test', onComplete: (err, result) => console.log(result)}); + pipeline.async(task); ``` */ - parse(id: string, file: any, type: string, options: Record<string, any>, onComplete: (err: Error, content: any) => void): void; - } - /** !#en - The builtin bundles - - !#zh - 内置 bundle */ - export enum BuiltinBundleName { - RESOURCES = 0, - INTERNAL = 0, - MAIN = 0, - START_SCENE = 0, + async(task: Task): void; } /** !#en A collection of information about a request @@ -21581,375 +21767,154 @@ declare namespace cc.AssetManager { !#zh 回收 requestItem 用于å¤ç”¨ */ - recycle(): void; - /** - !#en - Create a new request item from pool - - !#zh - ä»Žå¯¹è±¡æ± ä¸åˆ›å»º requestItem - */ - static create(): RequestItem; - } - /** !#en - Task is used to run in the pipeline for some effect - - !#zh - 任务用于在管线ä¸è¿è¡Œä»¥è¾¾æˆæŸç§æ•ˆæžœ */ - export class Task { - /** !#en - The id of task - - !#zh - 任务id */ - id: number; - /** !#en - The callback when task is completed - - !#zh - 完æˆå›žè°ƒ */ - onComplete: Function; - /** !#en - The callback of progression - - !#zh - 进度回调 */ - onProgress: Function; - /** !#en - The callback when something goes wrong - - !#zh - 错误回调 */ - onError: Function; - /** !#en - The source of task - - !#zh - ä»»åŠ¡çš„æº */ - source: any; - /** !#en - The output of task - - !#zh - 任务的输出 */ - output: any; - /** !#en - The input of task - - !#zh - 任务的输入 */ - input: any; - /** !#en - The progression of task - - !#zh - 任务的进度 */ - progress: any; - /** !#en - Custom options - - !#zh - è‡ªå®šä¹‰å‚æ•° */ - options: any; - /** - !#en - Create a new Task - - !#zh - 创建一个任务 - @param options Some optional paramters - */ - constructor(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record<string, any>}); - /** - !#en - Set paramters of this task - - !#zh - è®¾ç½®ä»»åŠ¡çš„å‚æ•° - @param options Some optional paramters - - @example - ```js - var task = new Task(); - task.set({input: ['test'], onComplete: (err, result) => console.log(err), onProgress: (finish, total) => console.log(finish / total)}); - ``` - */ - set(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record<string, any>}): void; - /** - !#en - Dispatch event - - !#zh - å‘布事件 - @param event The event name - @param param1 Parameter 1 - @param param2 Parameter 2 - @param param3 Parameter 3 - @param param4 Parameter 4 - - @example - ```js - var task = Task.create(); - Task.onComplete = (msg) => console.log(msg); - Task.dispatch('complete', 'hello world'); - ``` - */ - dispatch(event: string, param1?: any, param2?: any, param3?: any, param4?: any): void; - /** - !#en - Recycle this for reuse - - !#zh - 回收 task 用于å¤ç”¨ - */ - recycle(): void; - /** !#en - Whether or not this task is completed - - !#zh - æ¤ä»»åŠ¡æ˜¯å¦å·²ç»å®Œæˆ */ - isFinish: boolean; - /** - !#en - Create a new task from pool - - !#zh - ä»Žå¯¹è±¡æ± ä¸åˆ›å»º task - @param options Some optional paramters - */ - static create(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record<string, any>}): Task; - } - /** !#en - Handle the packed asset, include unpacking, loading, cache and so on. It is a singleton. All member can be accessed with `cc.assetManager.packManager` - - !#zh - å¤„ç†æ‰“包资æºï¼ŒåŒ…æ‹¬æ‹†åŒ…ï¼ŒåŠ è½½ï¼Œç¼“å˜ç‰ç‰ï¼Œè¿™æ˜¯ä¸€ä¸ªå•例, 所有æˆå‘˜èƒ½é€šè¿‡ `cc.assetManager.packManager` 访问 */ - export class PackManager { - /** - !#en - Unpack the json, revert to what it was before packing - - !#zh - 拆解 json 包,æ¢å¤ä¸ºæ‰“包之å‰çš„内容 - @param pack The pack - @param json The content of pack - @param options Some optional parameters - @param onComplete Callback when finish unpacking - - @example - ```js - downloader.downloadFile('pack.json', {responseType: 'json'}, null, (err, file) => { - packManager.unpackJson(['a', 'b'], file, null, (err, data) => console.log(err)); - }); - ``` - */ - unpackJson(pack: string[], json: any, options: Record<string, any>, onComplete?: (err: Error, content: any) => void): void; - /** - !#en - Register custom handler if you want to change default behavior or extend packManager to unpack other format pack - - !#zh - å½“ä½ æƒ³ä¿®æ”¹é»˜è®¤è¡Œä¸ºæˆ–è€…æ‹“å±• packManager æ¥æ‹†åˆ†å…¶ä»–æ ¼å¼çš„包时å¯ä»¥æ³¨å†Œè‡ªå®šä¹‰çš„ handler - @param type Extension likes '.bin' or map likes {'.bin': binHandler, '.ab': abHandler} - @param handler handler - - @example - ```js - packManager.register('.bin', (packUuid, file, options, onComplete) => onComplete(null, null)); - packManager.register({'.bin': (packUuid, file, options, onComplete) => onComplete(null, null), '.ab': (packUuid, file, options, onComplete) => onComplete(null, null)}); - ``` - */ - register(type: string, handler: (packUuid: string, data: any, options: Record<string, any>, onComplete: (err: Error, content: any) => void) => void): void; - register(map: Record<string, (packUuid: string, data: any, options: Record<string, any>, onComplete: (err: Error, content: any) => void) => void>): void; - /** - !#en - Use corresponding handler to unpack package - - !#zh - 用对应的 handler æ¥è¿›è¡Œè§£åŒ… - @param pack The uuid of packed assets - @param data The packed data - @param type The type indicates that which handler should be used to download, such as '.jpg' - @param options Some optional parameter - @param onComplete callback when finishing unpacking - - @example - ```js - downloader.downloadFile('pack.json', {responseType: 'json'}, null, (err, file) => { - packManager.unpack(['2fawq123d', '1zsweq23f'], file, '.json', null, (err, data) => console.log(err)); - }); - ``` - */ - unpack(pack: string[], data: any, type: string, options: Record<string, any>, onComplete?: (err: Error, data: any) => void): void; - /** - !#en - Download request item, If item is not in any package, download as usual. Otherwise, download the corresponding package and unpack it. - And then retrieve the corresponding content form it. - - !#zh - 下载请求对象,如果请求对象ä¸åœ¨ä»»ä½•包内,则æ£å¸¸ä¸‹è½½ï¼Œå¦åˆ™ä¸‹è½½å¯¹åº”çš„ package 并进行拆解,并å–回包内对应的内容 - @param item Some item you want to download - @param options Some optional parameters - @param onComplete Callback when finished - - @example - ```js - var requestItem = cc.AssetManager.RequestItem.create(); - requestItem.uuid = 'fcmR3XADNLgJ1ByKhqcC5Z'; - requestItem.info = config.getAssetInfo('fcmR3XADNLgJ1ByKhqcC5Z'); - packManager.load(requestItem, null, (err, data) => console.log(err)); - ``` + recycle(): void; + /** + !#en + Create a new request item from pool + + !#zh + ä»Žå¯¹è±¡æ± ä¸åˆ›å»º requestItem */ - load(item: RequestItem, options: Record<string, any>, onComplete: (err: Error, data: any) => void): void; + static create(): RequestItem; } /** !#en - Pipeline can execute the task for some effect. + The builtin bundles !#zh - 管线能执行任务达到æŸä¸ªæ•ˆæžœ */ - export class Pipeline { + 内置 bundle */ + export enum BuiltinBundleName { + RESOURCES = 0, + INTERNAL = 0, + MAIN = 0, + START_SCENE = 0, + } + /** !#en + Task is used to run in the pipeline for some effect + + !#zh + 任务用于在管线ä¸è¿è¡Œä»¥è¾¾æˆæŸç§æ•ˆæžœ */ + export class Task { /** !#en - The id of pipeline + The id of task !#zh - 管线的 id */ + 任务id */ id: number; /** !#en - The name of pipeline + The callback when task is completed !#zh - 管线的åå— */ - name: string; + 完æˆå›žè°ƒ */ + onComplete: Function; /** !#en - All pipes of pipeline + The callback of progression !#zh - æ‰€æœ‰çš„ç®¡é“ */ - pipes: Function[]; - /** - !#en - Create a new pipeline + 进度回调 */ + onProgress: Function; + /** !#en + The callback when something goes wrong !#zh - 创建一个管线 - @param name The name of pipeline - @param funcs The array of pipe, every pipe must be function which take two parameters, the first is a `Task` flowed in pipeline, the second is complete callback + 错误回调 */ + onError: Function; + /** !#en + The source of task - @example - ```js - var pipeline = new Pipeline('download', [ - (task, done) => { - var url = task.input; - cc.assetManager.downloader.downloadFile(url, null, null, (err, result) => { - task.output = result; - done(err); - }); - }, - (task, done) => { - var text = task.input; - var json = JSON.stringify(text); - task.output = json; - done(); - } - ]); - ``` - */ - constructor(name: string, funcs: Array<(task: Task, done?: (err: Error) => void) => void>); + !#zh + ä»»åŠ¡çš„æº */ + source: any; + /** !#en + The output of task + + !#zh + 任务的输出 */ + output: any; + /** !#en + The input of task + + !#zh + 任务的输入 */ + input: any; + /** !#en + The progression of task + + !#zh + 任务的进度 */ + progress: any; + /** !#en + Custom options + + !#zh + è‡ªå®šä¹‰å‚æ•° */ + options: any; /** !#en - At specific point insert a new pipe to pipeline + Create a new Task !#zh - 在æŸä¸ªç‰¹å®šçš„点为管线æ’入一个新的 pipe - @param func The new pipe - @param index The specific point you want to insert at. - - @example - ```js - var pipeline = new Pipeline('test', []); - pipeline.insert((task, done) => { - // do something - done(); - }, 0); - ``` + 创建一个任务 + @param options Some optional paramters */ - insert(func: (task: Task, callback?: (err: Error) => void) => void, index: number): Pipeline; + constructor(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record<string, any>}); /** !#en - Append a new pipe to the pipeline + Set paramters of this task !#zh - æ·»åŠ ä¸€ä¸ªç®¡é“åˆ°ç®¡çº¿ä¸ - @param func The new pipe + è®¾ç½®ä»»åŠ¡çš„å‚æ•° + @param options Some optional paramters @example ```js - var pipeline = new Pipeline('test', []); - pipeline.append((task, done) => { - // do something - done(); - }); + var task = new Task(); + task.set({input: ['test'], onComplete: (err, result) => console.log(err), onProgress: (finish, total) => console.log(finish / total)}); ``` */ - append(func: (task: Task, callback?: (err: Error) => void) => void): Pipeline; + set(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record<string, any>}): void; /** !#en - Remove pipe which at specific point + Dispatch event !#zh - 移除特定ä½ç½®çš„ç®¡é“ - @param index The specific point + å‘布事件 + @param event The event name + @param param1 Parameter 1 + @param param2 Parameter 2 + @param param3 Parameter 3 + @param param4 Parameter 4 @example ```js - var pipeline = new Pipeline('test', (task, done) => { - // do something - done(); - }); - pipeline.remove(0); + var task = Task.create(); + Task.onComplete = (msg) => console.log(msg); + Task.dispatch('complete', 'hello world'); ``` */ - remove(index: number): Pipeline; + dispatch(event: string, param1?: any, param2?: any, param3?: any, param4?: any): void; /** !#en - Execute task synchronously + Recycle this for reuse !#zh - åŒæ¥æ‰§è¡Œä»»åŠ¡ - @param task The task will be executed - - @example - ```js - var pipeline = new Pipeline('sync', [(task) => { - let input = task.input; - task.output = doSomething(task.input); - }]); - - var task = new Task({input: 'test'}); - console.log(pipeline.sync(task)); - ``` + 回收 task 用于å¤ç”¨ */ - sync(task: Task): any; + recycle(): void; + /** !#en + Whether or not this task is completed + + !#zh + æ¤ä»»åŠ¡æ˜¯å¦å·²ç»å®Œæˆ */ + isFinish: boolean; /** !#en - Execute task asynchronously + Create a new task from pool !#zh - å¼‚æ¥æ‰§è¡Œä»»åŠ¡ - @param task The task will be executed - - @example - ```js - var pipeline = new Pipeline('sync', [(task, done) => { - let input = task.input; - task.output = doSomething(task.input); - done(); - }]); - var task = new Task({input: 'test', onComplete: (err, result) => console.log(result)}); - pipeline.async(task); - ``` + ä»Žå¯¹è±¡æ± ä¸åˆ›å»º task + @param options Some optional paramters */ - async(task: Task): void; + static create(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record<string, any>}): Task; } } @@ -22683,6 +22648,9 @@ declare namespace cc.primitive { declare let CC_JSB: boolean declare let CC_NATIVERENDERER: boolean declare let CC_EDITOR: boolean +declare let CC_PREVIEW: boolean +declare let CC_TEST: boolean +declare let CC_DEBUG: boolean declare let cc: { // polyfills: { @@ -22691,6 +22659,8 @@ declare let cc: { [x: string]: any; } +declare let Editor: any; + // https://medium.com/dailyjs/typescript-create-a-condition-based-subset-types-9d902cea5b8c type FlagExcludedType<Base, Type> = { [Key in keyof Base]: Base[Key] extends Type ? never : Key }; type AllowedNames<Base, Type> = FlagExcludedType<Base, Type>[keyof Base]; @@ -22716,147 +22686,6 @@ declare interface Object { assign(target: {}, source: {}); } -/** - * @module cc.AssetManager - */ - -declare namespace cc.AssetManager { - /** - * !#en - * Cache manager is a module which controls all caches downloaded from server in non-web platform, it is a singleton - * All member can be accessed with `cc.assetManager.cacheManager`. - * - * !#zh - * 缓å˜ç®¡ç†å™¨æ˜¯ä¸€ä¸ªæ¨¡å—ï¼Œåœ¨éž WEB å¹³å°ä¸Šï¼Œç”¨äºŽç®¡ç†æ‰€æœ‰ä»ŽæœåŠ¡å™¨ä¸Šä¸‹è½½ä¸‹æ¥çš„缓å˜ï¼Œè¿™æ˜¯ä¸€ä¸ªå•例,所有æˆå‘˜èƒ½é€šè¿‡ `cc.assetManager.cacheManager` 访问。 - * - * @class CacheManager - */ - class CacheManager { - /** - * !#en - * The name of cacheDir - * - * !#zh - * 缓å˜ç›®å½•çš„åç§° - * - * @property cacheDir - * @type {String} - * @default 'gamecaches' - */ - public cacheDir: String; - - /** - * !#en - * Whether or not cache asset into user's storage space, this property only works on mini-game platforms - * - * !#zh - * 是å¦ç¼“å˜èµ„æºåˆ°ç”¨æˆ·å˜å‚¨ç©ºé—´ï¼Œæ¤å±žæ€§åªåœ¨å°æ¸¸æˆå¹³å°æœ‰æ•ˆ - * - * @property cacheEnabled - * @type {Boolean} - * @default true - */ - public cacheEnabled: Boolean; - - /** - * !#en - * Whether or not auto clear cache when storage ran out, this property only works on mini-game platforms - * - * !#zh - * 是å¦åœ¨å˜å‚¨ç©ºé—´æ»¡äº†åŽè‡ªåŠ¨æ¸…ç†ç¼“å˜ï¼Œæ¤å±žæ€§åªåœ¨å°æ¸¸æˆå¹³å°æœ‰æ•ˆ - * - * @property autoClear - * @type {Boolean} - * @default true - */ - public autoClear: Boolean; - - /** - * !#en - * The interval between caching resources, this property only works on mini-game platforms - * - * !#zh - * 缓å˜èµ„æºçš„间隔时间,æ¤å±žæ€§åªåœ¨å°æ¸¸æˆå¹³å°æœ‰æ•ˆ - * - * @property cacheInterval - * @type {Number} - * @default 500 - */ - public cacheInterval: Number; - - /** - * !#en - * The interval between deleting resources, when you use `cleanLRU`, the resources will be deleted as this interval - * - * !#zh - * 清ç†èµ„æºçš„é—´éš”æ—¶é—´ï¼Œå½“ä½ ä½¿ç”¨ `cleanLRU` 时,资æºå°†ä»¥æ¤é—´éš”è¢«åˆ é™¤ - * - * @property deleteInterval - * @type {Number} - * @default 500 - */ - public deleteInterval: Number; - - /** - * !#en - * Get cached path with origin url - * - * !#zh - * 通过原始 url 获å–缓å˜åŽçš„路径 - * - * @method getCache - * @param {string} originUrl - * @returns {String} The cached path - */ - public getCache (originUrl: string): string; - - /** - * !#en - * Get temporary path with origin url, this method only works on mini-game platforms - * - * !#zh - * 通过原始 url 获å–ä¸´æ—¶æ–‡ä»¶çš„è·¯å¾„ï¼Œæ¤æ–¹æ³•åªåœ¨å°æ¸¸æˆå¹³å°æœ‰æ•ˆ - * - * @method getTemp - * @param {string} originUrl - * @returns {String} The temp path - */ - public getTemp (originUrl: string): string; - - /** - * !#en - * Clear all caches, please use with caution, If necessary, we recommend using it before the game is launched - * - * !#zh - * 清空所有缓å˜ï¼Œè¯·è°¨æ…Žä½¿ç”¨ï¼Œå¦‚果必è¦çš„è¯ï¼Œæˆ‘们建议在游æˆå¯åЍ之å‰ä½¿ç”¨ - * - * @method clearCache - */ - public clearCache (): void; - - /** - * !#en - * Clear part of caches with LRU strategy - * - * !#zh - * 使用 LRU ç–ç•¥æ¸…ç©ºéƒ¨åˆ†ç¼“å˜ - * - * @method clearLRU - */ - public clearLRU (): void; - - /** - * !#en - * Remove cache with origin url - * - * !#zh - * 通过原始 url ç§»é™¤ç¼“å˜ - * - * @method removeCache - */ - public removeCache (originUrl: string): void; - } -} type FloatArray = Float64Array | Float32Array; diff --git a/tsconfig.json b/tsconfig.json index 80809c6..93c0b22 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,6 @@ "experimentalDecorators": true, "skipLibCheck": true, "outDir": "temp/vscode-dist", - "allowJs": true, "forceConsistentCasingInFileNames": true }, "exclude": [ -- 2.21.0