diff --git a/assets/Script/res/ResLeakChecker.ts b/assets/Script/res/ResLeakChecker.ts
index 1ae6cdc..8d10431 100644
--- a/assets/Script/res/ResLeakChecker.ts
+++ b/assets/Script/res/ResLeakChecker.ts
@@ -12,6 +12,8 @@
* 2020-1-20 by 宝爷
*/
+import { ResUtil } from "./ResUtil";
+
export type FilterCallback = (url: string) => boolean;
export class ResLeakChecker {
@@ -19,37 +21,6 @@ export class ResLeakChecker {
private _checking: boolean = false;
private _log: Map
+ ATTENTION: USE cc.director INSTEAD OF cc.Director.
+ cc.director also synchronizes timers with the refresh rate of the display.
+ 注意:用 cc.director 代替 cc.Director。
+ cc.director 也同步定时器与显示器的刷新速率。
+
- ATTENTION: USE cc.director INSTEAD OF cc.Director.
- cc.director also synchronizes timers with the refresh rate of the display.
- 注意:用 cc.director 代替 cc.Director。
- cc.director 也同步定时器与显示器的刷新速率。
- 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. cc.TMXTilesetInfo contains the information about the tilesets like: cc.TMXMapInfo contains the information about the map like: And it also contains: This information is obtained from the TMX file. 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. cc.TMXTilesetInfo contains the information about the tilesets like: cc.TMXMapInfo contains the information about the map like: And it also contains: This information is obtained from the TMX file.
+ Gets current target of the event
- Gets current target of the event
@@ -1163,15 +1166,19 @@ declare namespace cc {
@param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
*/
export function log(msg: string|any, ...subst: any[]): void;
- /** !#en This is a Game instance.
- !#zh 这是一个 Game 类的实例,包含游戏主体信息并负责驱动游戏的游戏对象。。 */
- export var game: Game;
/** !#en Director
!#zh 导演类。 */
export var director: Director;
- /** !#en This is a Easing instance.
- !#zh 这是一个 Easing 类实例。 */
- export var easing: Easing;
+ /** !#en This is a Game instance.
+ !#zh 这是一个 Game 类的实例,包含游戏主体信息并负责驱动游戏的游戏对象。。 */
+ export var game: Game;
+ export var assetManager: AssetManager;
+ /** !#en
+ cc.resources is a bundle and controls all asset under assets/resources
+
+ !#zh
+ cc.resources 是一个 bundle,用于管理所有在 assets/resources 下的资源 */
+ export var resources: AssetManager.Bundle;
/**
!#en
Rotates a Node object to a certain angle by modifying its quternion property.
@@ -1206,13 +1213,6 @@ declare namespace cc {
```
*/
export function rotate3DBy(duration: number, deltaAngleX: number|Vec3, deltaAngleY?: number, deltaAngleZ?: number): ActionInterval;
- export var assetManager: AssetManager;
- /** !#en
- cc.resources is a bundle and controls all asset under assets/resources
-
- !#zh
- cc.resources 是一个 bundle,用于管理所有在 assets/resources 下的资源 */
- export var resources: AssetManager.Bundle;
/** !#en The System event singleton for global usage
!#zh 系统事件单例,方便全局使用 */
export var systemEvent: SystemEvent;
@@ -1475,6 +1475,15 @@ declare namespace cc {
export function instantiate(original: Prefab): Node;
export function instantiate
+ 主要用来播放音频,播放的时候会返回一个 audioID,之后都可以通过这个 audioID 来操作这个音频对象。
+ 不使用的时候,请使用 cc.audioEngine.uncache(filePath); 进行资源释放
+ 注意:
+ 在 Android 系统浏览器上,不同浏览器,不同版本的效果不尽相同。
+ 比如说:大多数浏览器都需要用户物理交互才可以开始播放音效,有一些不支持 WebAudio,
+ 有一些不支持多音轨播放。总之如果对音乐依赖比较强,请做尽可能多的测试。 */
+ export class audioEngine {
+ /**
+ !#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);
+ });
+ ```
+ */
+ static play(clip: AudioClip, loop: boolean, volume: number): number;
+ /**
+ !#en Set audio loop.
+ !#zh 设置音频是否循环。
+ @param audioID audio id.
+ @param loop Whether cycle.
+
+ @example
+ ```js
+ cc.audioEngine.setLoop(id, true);
+ ```
+ */
+ static setLoop(audioID: number, loop: boolean): void;
+ /**
+ !#en Get audio cycle state.
+ !#zh 获取音频的循环状态。
+ @param audioID audio id.
+
+ @example
+ ```js
+ cc.audioEngine.isLoop(id);
+ ```
+ */
+ static isLoop(audioID: number): boolean;
+ /**
+ !#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);
+ ```
+ */
+ static setVolume(audioID: number, volume: number): 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);
+ ```
+ */
+ static getVolume(audioID: number): number;
+ /**
+ !#en Set current time
+ !#zh 设置当前的音频时间。
+ @param audioID audio id.
+ @param sec current time.
+
+ @example
+ ```js
+ cc.audioEngine.setCurrentTime(id, 2);
+ ```
+ */
+ static setCurrentTime(audioID: number, sec: number): boolean;
+ /**
+ !#en Get current time
+ !#zh 获取当前的音频播放时间。
+ @param audioID audio id.
+
+ @example
+ ```js
+ var time = cc.audioEngine.getCurrentTime(id);
+ ```
+ */
+ static getCurrentTime(audioID: number): number;
+ /**
+ !#en Get audio duration
+ !#zh 获取音频总时长。
+ @param audioID audio id.
+
+ @example
+ ```js
+ var time = cc.audioEngine.getDuration(id);
+ ```
+ */
+ static getDuration(audioID: number): number;
+ /**
+ !#en Get audio state
+ !#zh 获取音频状态。
+ @param audioID audio id.
+
+ @example
+ ```js
+ var state = cc.audioEngine.getState(id);
+ ```
+ */
+ static getState(audioID: number): audioEngine.AudioState;
+ /**
+ !#en Set Audio finish callback
+ !#zh 设置一个音频结束后的回调
+ @param audioID audio id.
+ @param callback loaded callback.
+
+ @example
+ ```js
+ cc.audioEngine.setFinishCallback(id, function () {});
+ ```
+ */
+ static setFinishCallback(audioID: number, callback: Function): void;
+ /**
+ !#en Pause playing audio.
+ !#zh 暂停正在播放音频。
+ @param audioID The return value of function play.
+
+ @example
+ ```js
+ cc.audioEngine.pause(audioID);
+ ```
+ */
+ static pause(audioID: number): void;
+ /**
+ !#en Pause all playing audio
+ !#zh 暂停现在正在播放的所有音频。
+
+ @example
+ ```js
+ cc.audioEngine.pauseAll();
+ ```
+ */
+ static pauseAll(): void;
+ /**
+ !#en Resume playing audio.
+ !#zh 恢复播放指定的音频。
+ @param audioID The return value of function play.
+
+ @example
+ ```js
+ cc.audioEngine.resume(audioID);
+ ```
+ */
+ static resume(audioID: number): void;
+ /**
+ !#en Resume all playing audio.
+ !#zh 恢复播放所有之前暂停的所有音频。
+
+ @example
+ ```js
+ cc.audioEngine.resumeAll();
+ ```
+ */
+ static resumeAll(): void;
+ /**
+ !#en Stop playing audio.
+ !#zh 停止播放指定音频。
+ @param audioID The return value of function play.
+
+ @example
+ ```js
+ cc.audioEngine.stop(audioID);
+ ```
+ */
+ static stop(audioID: number): void;
+ /**
+ !#en Stop all playing audio.
+ !#zh 停止正在播放的所有音频。
+
+ @example
+ ```js
+ cc.audioEngine.stopAll();
+ ```
+ */
+ static stopAll(): void;
+ /**
+ !#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);
+ ```
+ */
+ static setMaxAudioInstance(num: number): void;
+ /**
+ !#en Getting audio can produce several examples.
+ !#zh 获取一个音频可以设置几个实例
+
+ @example
+ ```js
+ cc.audioEngine.getMaxAudioInstance();
+ ```
+ */
+ static getMaxAudioInstance(): number;
+ /**
+ !#en Unload the preloaded audio from internal buffer.
+ !#zh 卸载预加载的音频。
+ @param clip clip
+
+ @example
+ ```js
+ cc.audioEngine.uncache(filePath);
+ ```
+ */
+ static uncache(clip: AudioClip): void;
+ /**
+ !#en Unload all audio from internal buffer.
+ !#zh 卸载所有音频。
+
+ @example
+ ```js
+ cc.audioEngine.uncacheAll();
+ ```
+ */
+ static uncacheAll(): void;
+ /**
+ !#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);
+ });
+ ```
+ */
+ static playMusic(clip: AudioClip, loop: boolean): number;
+ /**
+ !#en Stop background music.
+ !#zh 停止播放背景音乐。
+
+ @example
+ ```js
+ cc.audioEngine.stopMusic();
+ ```
+ */
+ static stopMusic(): void;
+ /**
+ !#en Pause the background music.
+ !#zh 暂停播放背景音乐。
+
+ @example
+ ```js
+ cc.audioEngine.pauseMusic();
+ ```
+ */
+ static pauseMusic(): void;
+ /**
+ !#en Resume playing background music.
+ !#zh 恢复播放背景音乐。
+
+ @example
+ ```js
+ cc.audioEngine.resumeMusic();
+ ```
+ */
+ static resumeMusic(): void;
+ /**
+ !#en Get the volume(0.0 ~ 1.0).
+ !#zh 获取音量(0.0 ~ 1.0)。
+
+ @example
+ ```js
+ var volume = cc.audioEngine.getMusicVolume();
+ ```
+ */
+ static getMusicVolume(): number;
+ /**
+ !#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);
+ ```
+ */
+ static setMusicVolume(volume: number): void;
+ /**
+ !#en Background music playing state
+ !#zh 背景音乐是否正在播放
+
+ @example
+ ```js
+ cc.audioEngine.isMusicPlaying();
+ ```
+ */
+ static isMusicPlaying(): boolean;
+ /**
+ !#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);
+ });
+ ```
+ */
+ static playEffect(clip: AudioClip, loop: boolean): number;
+ /**
+ !#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);
+ ```
+ */
+ 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 Base class cc.Action for action classes.
!#zh Action 类是所有动作类型的基类。 */
export class Action {
@@ -2291,412 +2698,337 @@ declare namespace cc {
*/
reverseTime(action?: Action|Tween
- 主要用来播放音频,播放的时候会返回一个 audioID,之后都可以通过这个 audioID 来操作这个音频对象。
- 不使用的时候,请使用 cc.audioEngine.uncache(filePath); 进行资源释放
- 注意:
- 在 Android 系统浏览器上,不同浏览器,不同版本的效果不尽相同。
- 比如说:大多数浏览器都需要用户物理交互才可以开始播放音效,有一些不支持 WebAudio,
- 有一些不支持多音轨播放。总之如果对音乐依赖比较强,请做尽可能多的测试。 */
- export class audioEngine {
+ AnimationState 完全控制动画播放过程。
+ 大多数情况下 动画组件 是足够和易于使用的。如果您需要更多的动画控制接口,请使用 AnimationState。 */
+ export class AnimationState extends Playable {
/**
- !#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);
- });
- ```
- */
- static play(clip: AudioClip, loop: boolean, volume: number): number;
- /**
- !#en Set audio loop.
- !#zh 设置音频是否循环。
- @param audioID audio id.
- @param loop Whether cycle.
-
- @example
- ```js
- cc.audioEngine.setLoop(id, true);
- ```
- */
- static setLoop(audioID: number, loop: boolean): void;
- /**
- !#en Get audio cycle state.
- !#zh 获取音频的循环状态。
- @param audioID audio id.
-
- @example
- ```js
- cc.audioEngine.isLoop(id);
- ```
- */
- static isLoop(audioID: number): boolean;
- /**
- !#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);
- ```
- */
- static setVolume(audioID: number, volume: number): 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);
- ```
- */
- static getVolume(audioID: number): number;
- /**
- !#en Set current time
- !#zh 设置当前的音频时间。
- @param audioID audio id.
- @param sec current time.
-
- @example
- ```js
- cc.audioEngine.setCurrentTime(id, 2);
- ```
- */
- static setCurrentTime(audioID: number, sec: number): boolean;
- /**
- !#en Get current time
- !#zh 获取当前的音频播放时间。
- @param audioID audio id.
-
- @example
- ```js
- var time = cc.audioEngine.getCurrentTime(id);
- ```
- */
- static getCurrentTime(audioID: number): number;
- /**
- !#en Get audio duration
- !#zh 获取音频总时长。
- @param audioID audio id.
-
- @example
- ```js
- var time = cc.audioEngine.getDuration(id);
- ```
- */
- static getDuration(audioID: number): number;
- /**
- !#en Get audio state
- !#zh 获取音频状态。
- @param audioID audio id.
-
- @example
- ```js
- var state = cc.audioEngine.getState(id);
- ```
- */
- static getState(audioID: number): audioEngine.AudioState;
- /**
- !#en Set Audio finish callback
- !#zh 设置一个音频结束后的回调
- @param audioID audio id.
- @param callback loaded callback.
-
- @example
- ```js
- cc.audioEngine.setFinishCallback(id, function () {});
- ```
- */
- static setFinishCallback(audioID: number, callback: Function): void;
- /**
- !#en Pause playing audio.
- !#zh 暂停正在播放音频。
- @param audioID The return value of function play.
-
- @example
- ```js
- cc.audioEngine.pause(audioID);
- ```
- */
- static pause(audioID: number): void;
- /**
- !#en Pause all playing audio
- !#zh 暂停现在正在播放的所有音频。
-
- @example
- ```js
- cc.audioEngine.pauseAll();
- ```
- */
- static pauseAll(): void;
- /**
- !#en Resume playing audio.
- !#zh 恢复播放指定的音频。
- @param audioID The return value of function play.
-
- @example
- ```js
- cc.audioEngine.resume(audioID);
- ```
- */
- static resume(audioID: number): void;
- /**
- !#en Resume all playing audio.
- !#zh 恢复播放所有之前暂停的所有音频。
-
- @example
- ```js
- cc.audioEngine.resumeAll();
- ```
- */
- static resumeAll(): void;
- /**
- !#en Stop playing audio.
- !#zh 停止播放指定音频。
- @param audioID The return value of function play.
-
- @example
- ```js
- cc.audioEngine.stop(audioID);
- ```
- */
- static stop(audioID: number): void;
- /**
- !#en Stop all playing audio.
- !#zh 停止正在播放的所有音频。
-
- @example
- ```js
- cc.audioEngine.stopAll();
- ```
- */
- static stopAll(): void;
- /**
- !#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);
- ```
- */
- static setMaxAudioInstance(num: number): void;
- /**
- !#en Getting audio can produce several examples.
- !#zh 获取一个音频可以设置几个实例
-
- @example
- ```js
- cc.audioEngine.getMaxAudioInstance();
- ```
- */
- static getMaxAudioInstance(): number;
- /**
- !#en Unload the preloaded audio from internal buffer.
- !#zh 卸载预加载的音频。
@param clip clip
-
- @example
- ```js
- cc.audioEngine.uncache(filePath);
- ```
+ @param name name
*/
- static uncache(clip: AudioClip): void;
+ 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.
+ Demonstratio: https://easings.net/
+ !#zh
+ 缓动函数类,为 {{#crossLink "Tween"}}{{/crossLink}} 提供缓动效果函数。
+ 函数效果演示: https://easings.net/ */
+ export class Easing {
/**
- !#en Unload all audio from internal buffer.
- !#zh 卸载所有音频。
-
- @example
- ```js
- cc.audioEngine.uncacheAll();
- ```
+ !#en Easing in with quadratic formula. From slow to fast.
+ !#zh 平方曲线缓入函数。运动由慢到快。
+ @param t The current time as a percentage of the total time.
*/
- static uncacheAll(): void;
+ quadIn(t: number): number;
/**
- !#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 Easing out with quadratic formula. From fast to slow.
+ !#zh 平方曲线缓出函数。运动由快到慢。
+ @param t The current time as a percentage of the total time.
*/
- static playMusic(clip: AudioClip, loop: boolean): number;
+ quadOut(t: number): number;
/**
- !#en Stop background music.
- !#zh 停止播放背景音乐。
-
- @example
- ```js
- cc.audioEngine.stopMusic();
- ```
+ !#en Easing in and out with quadratic formula. From slow to fast, then back to slow.
+ !#zh 平方曲线缓入缓出函数。运动由慢到快再到慢。
+ @param t The current time as a percentage of the total time.
*/
- static stopMusic(): void;
+ quadInOut(t: number): number;
/**
- !#en Pause the background music.
- !#zh 暂停播放背景音乐。
-
- @example
- ```js
- cc.audioEngine.pauseMusic();
- ```
+ !#en Easing in with cubic formula. From slow to fast.
+ !#zh 立方曲线缓入函数。运动由慢到快。
+ @param t The current time as a percentage of the total time.
*/
- static pauseMusic(): void;
+ cubicIn(t: number): number;
/**
- !#en Resume playing background music.
- !#zh 恢复播放背景音乐。
-
- @example
- ```js
- cc.audioEngine.resumeMusic();
- ```
+ !#en Easing out with cubic formula. From slow to fast.
+ !#zh 立方曲线缓出函数。运动由快到慢。
+ @param t The current time as a percentage of the total time.
*/
- static resumeMusic(): void;
+ cubicOut(t: number): number;
/**
- !#en Get the volume(0.0 ~ 1.0).
- !#zh 获取音量(0.0 ~ 1.0)。
-
- @example
- ```js
- var volume = cc.audioEngine.getMusicVolume();
- ```
+ !#en Easing in and out with cubic formula. From slow to fast, then back to slow.
+ !#zh 立方曲线缓入缓出函数。运动由慢到快再到慢。
+ @param t The current time as a percentage of the total time.
*/
- static getMusicVolume(): number;
+ cubicInOut(t: number): number;
/**
- !#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 Easing in with quartic formula. From slow to fast.
+ !#zh 四次方曲线缓入函数。运动由慢到快。
+ @param t The current time as a percentage of the total time.
*/
- static setMusicVolume(volume: number): void;
+ quartIn(t: number): number;
/**
- !#en Background music playing state
- !#zh 背景音乐是否正在播放
-
- @example
- ```js
- cc.audioEngine.isMusicPlaying();
- ```
+ !#en Easing out with quartic formula. From fast to slow.
+ !#zh 四次方曲线缓出函数。运动由快到慢。
+ @param t The current time as a percentage of the total time.
*/
- static isMusicPlaying(): boolean;
+ quartOut(t: number): number;
/**
- !#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 Easing in and out with quartic formula. From slow to fast, then back to slow.
+ !#zh 四次方曲线缓入缓出函数。运动由慢到快再到慢。
+ @param t The current time as a percentage of the total time.
*/
- static playEffect(clip: AudioClip, loop: boolean): number;
+ quartInOut(t: number): number;
/**
- !#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 Easing in with quintic formula. From slow to fast.
+ !#zh 五次方曲线缓入函数。运动由慢到快。
+ @param t The current time as a percentage of the total time.
*/
- static setEffectsVolume(volume: number): void;
+ quintIn(t: number): number;
/**
- !#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();
- ```
+ !#en Easing out with quintic formula. From fast to slow.
+ !#zh 五次方曲线缓出函数。运动由快到慢。
+ @param t The current time as a percentage of the total time.
*/
- static getEffectsVolume(): number;
+ quintOut(t: number): number;
/**
- !#en Pause effect audio.
- !#zh 暂停播放音效。
- @param audioID audio id.
-
- @example
- ```js
- cc.audioEngine.pauseEffect(audioID);
- ```
+ !#en Easing in and out with quintic formula. From slow to fast, then back to slow.
+ !#zh 五次方曲线缓入缓出函数。运动由慢到快再到慢。
+ @param t The current time as a percentage of the total time.
*/
- static pauseEffect(audioID: number): void;
+ quintInOut(t: number): number;
/**
- !#en Stop playing all the sound effects.
- !#zh 暂停播放所有音效。
-
- @example
- ```js
- cc.audioEngine.pauseAllEffects();
- ```
+ !#en Easing in and out with sine formula. From slow to fast.
+ !#zh 正弦曲线缓入函数。运动由慢到快。
+ @param t The current time as a percentage of the total time.
*/
- static pauseAllEffects(): void;
+ sineIn(t: number): number;
/**
- !#en Resume effect audio.
- !#zh 恢复播放音效音频。
- @param audioID The return value of function play.
-
- @example
- ```js
- cc.audioEngine.resumeEffect(audioID);
- ```
+ !#en Easing in and out with sine formula. From fast to slow.
+ !#zh 正弦曲线缓出函数。运动由快到慢。
+ @param t The current time as a percentage of the total time.
*/
- static resumeEffect(audioID: number): void;
+ sineOut(t: number): number;
/**
- !#en Resume all effect audio.
- !#zh 恢复播放所有之前暂停的音效。
-
- @example
- ```js
- cc.audioEngine.resumeAllEffects();
- ```
+ !#en Easing in and out with sine formula. From slow to fast, then back to slow.
+ !#zh 正弦曲线缓入缓出函数。运动由慢到快再到慢。
+ @param t The current time as a percentage of the total time.
*/
- static resumeAllEffects(): void;
+ sineInOut(t: number): number;
/**
- !#en Stop playing the effect audio.
- !#zh 停止播放音效。
- @param audioID audio id.
-
- @example
- ```js
- cc.audioEngine.stopEffect(id);
- ```
+ !#en Easing in and out with exponential formula. From slow to fast.
+ !#zh 指数曲线缓入函数。运动由慢到快。
+ @param t The current time as a percentage of the total time.
*/
- static stopEffect(audioID: number): void;
+ expoIn(t: number): number;
/**
- !#en Stop playing all the effects.
- !#zh 停止播放所有音效。
-
- @example
- ```js
- cc.audioEngine.stopAllEffects();
- ```
+ !#en Easing in and out with exponential formula. From fast to slow.
+ !#zh 指数曲线缓出函数。运动由快到慢。
+ @param t The current time as a percentage of the total time.
*/
- static stopAllEffects(): void;
+ expoOut(t: number): number;
+ /**
+ !#en Easing in and out with exponential formula. From slow to fast.
+ !#zh 指数曲线缓入和缓出函数。运动由慢到很快再到慢。
+ @param t The current time as a percentage of the total time, then back to slow.
+ */
+ expoInOut(t: number): number;
+ /**
+ !#en Easing in and out with circular formula. From slow to fast.
+ !#zh 循环公式缓入函数。运动由慢到快。
+ @param t The current time as a percentage of the total time.
+ */
+ circIn(t: number): number;
+ /**
+ !#en Easing in and out with circular formula. From fast to slow.
+ !#zh 循环公式缓出函数。运动由快到慢。
+ @param t The current time as a percentage of the total time.
+ */
+ circOut(t: number): number;
+ /**
+ !#en Easing in and out with circular formula. From slow to fast.
+ !#zh 指数曲线缓入缓出函数。运动由慢到很快再到慢。
+ @param t The current time as a percentage of the total time, then back to slow.
+ */
+ circInOut(t: number): number;
+ /**
+ !#en Easing in action with a spring oscillating effect.
+ !#zh 弹簧回震效果的缓入函数。
+ @param t The current time as a percentage of the total time.
+ */
+ elasticIn(t: number): number;
+ /**
+ !#en Easing out action with a spring oscillating effect.
+ !#zh 弹簧回震效果的缓出函数。
+ @param t The current time as a percentage of the total time.
+ */
+ elasticOut(t: number): number;
+ /**
+ !#en Easing in and out action with a spring oscillating effect.
+ !#zh 弹簧回震效果的缓入缓出函数。
+ @param t The current time as a percentage of the total time.
+ */
+ elasticInOut(t: number): number;
+ /**
+ !#en Easing in action with "back up" behavior.
+ !#zh 回退效果的缓入函数。
+ @param t The current time as a percentage of the total time.
+ */
+ backIn(t: number): number;
+ /**
+ !#en Easing out action with "back up" behavior.
+ !#zh 回退效果的缓出函数。
+ @param t The current time as a percentage of the total time.
+ */
+ backOut(t: number): number;
+ /**
+ !#en Easing in and out action with "back up" behavior.
+ !#zh 回退效果的缓入缓出函数。
+ @param t The current time as a percentage of the total time.
+ */
+ backInOut(t: number): number;
+ /**
+ !#en Easing in action with bouncing effect.
+ !#zh 弹跳效果的缓入函数。
+ @param t The current time as a percentage of the total time.
+ */
+ bounceIn(t: number): number;
+ /**
+ !#en Easing out action with bouncing effect.
+ !#zh 弹跳效果的缓出函数。
+ @param t The current time as a percentage of the total time.
+ */
+ bounceOut(t: number): number;
+ /**
+ !#en Easing in and out action with bouncing effect.
+ !#zh 弹跳效果的缓入缓出函数。
+ @param t The current time as a percentage of the total time.
+ */
+ bounceInOut(t: number): number;
+ /**
+ !#en Target will run action with smooth effect.
+ !#zh 平滑效果函数。
+ @param t The current time as a percentage of the total time.
+ */
+ smooth(t: number): number;
+ /**
+ !#en Target will run action with fade effect.
+ !#zh 渐褪效果函数。
+ @param t The current time as a percentage of the total time.
+ */
+ fade(t: number): number;
+ }
+ /** undefined */
+ export class Playable {
+ /** !#en Is playing or paused in play mode?
+ !#zh 当前是否正在播放。 */
+ isPlaying: boolean;
+ /** !#en Is currently paused? This can be true even if in edit mode(isPlaying == false).
+ !#zh 当前是否正在暂停 */
+ isPaused: boolean;
+ /**
+ !#en Play this animation.
+ !#zh 播放动画。
+ */
+ play(): void;
+ /**
+ !#en Stop this animation.
+ !#zh 停止动画播放。
+ */
+ stop(): void;
+ /**
+ !#en Pause this animation.
+ !#zh 暂停动画。
+ */
+ pause(): void;
+ /**
+ !#en Resume this animation.
+ !#zh 重新播放动画。
+ */
+ resume(): void;
+ /**
+ !#en Perform a single frame step.
+ !#zh 执行一帧动画。
+ */
+ step(): void;
+ }
+ /** !#en Specifies how time is treated when it is outside of the keyframe range of an Animation.
+ !#zh 动画使用的循环模式。 */
+ export enum WrapMode {
+ Default = 0,
+ Normal = 0,
+ Reverse = 0,
+ Loop = 0,
+ LoopReverse = 0,
+ PingPong = 0,
+ PingPongReverse = 0,
}
/** !#en An object to boot the game.
!#zh 包含游戏主体信息并负责驱动游戏的游戏对象。 */
@@ -2720,6 +3052,301 @@ declare namespace cc {
*/
static setDisplayStats(displayStats: boolean): void;
}
+ /** !#en
+
+ cc.director is a singleton object which manage your game's logic flow.
+ Since the cc.director is a singleton, you don't need to call any constructor or create functions,
+ the standard way to use it is by calling:
+ - cc.director.methodName();
+
+ It creates and handle the main Window and manages how and when to execute the Scenes.
+
+ The cc.director is also responsible for:
+ - initializing the OpenGL context
+ - setting the OpenGL pixel format (default on is RGB565)
+ - setting the OpenGL buffer depth (default on is 0-bit)
+ - setting the color for clear screen (default one is BLACK)
+ - setting the projection (default one is 3D)
+ - setting the orientation (default one is Portrait)
+
+
+ The cc.director also sets the default OpenGL context:
+ - GL_TEXTURE_2D is enabled
+ - GL_VERTEX_ARRAY is enabled
+ - GL_COLOR_ARRAY is enabled
+ - GL_TEXTURE_COORD_ARRAY is enabled
+
+ Features and Limitations:
+ - Scheduled timers & drawing are synchronizes with the refresh rate of the display
+ - Only supports animation intervals of 1/60 1/30 & 1/15
+
+ cc.director 一个管理你的游戏的逻辑流程的单例对象。
+ 由于 cc.director 是一个单例,你不需要调用任何构造函数或创建函数,
+ 使用它的标准方法是通过调用:
+ - cc.director.methodName();
+
+ 它创建和处理主窗口并且管理什么时候执行场景。
+
+ cc.director 还负责:
+ - 初始化 OpenGL 环境。
+ - 设置OpenGL像素格式。(默认是 RGB565)
+ - 设置OpenGL缓冲区深度 (默认是 0-bit)
+ - 设置空白场景的颜色 (默认是 黑色)
+ - 设置投影 (默认是 3D)
+ - 设置方向 (默认是 Portrait)
+
+ cc.director 设置了 OpenGL 默认环境
+ - GL_TEXTURE_2D 启用。
+ - GL_VERTEX_ARRAY 启用。
+ - GL_COLOR_ARRAY 启用。
+ - GL_TEXTURE_COORD_ARRAY 启用。
+
+ 特点和局限性:
+ - 将计时器 & 渲染与显示器的刷新频率同步。
+ - 只支持动画的间隔 1/60 1/30 & 1/15。
+
+ Useful to convert (multi) touches coordinates to the current layout (portrait or landscape)
+ Implementation can be found in CCDirectorWebGL.
+ !#zh 将触摸点的屏幕坐标转换为 WebGL View 下的坐标。
+ @param uiPoint uiPoint
+ */
+ convertToGL(uiPoint: Vec2): Vec2;
+ /**
+ !#en
+ Converts an OpenGL coordinate to a view coordinate
+ Useful to convert node points to window points for calls such as glScissor
+ 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
+ */
+ end(): void;
+ /**
+ !#en
+ Returns the size of the WebGL view in points.
+ It takes into account any possible rotation (device orientation) of the window.
+ !#zh 获取视图的大小,以点为单位。
+ */
+ getWinSize(): Size;
+ /**
+ !#en
+ Returns the size of the OpenGL view in pixels.
+ It takes into account any possible rotation (device orientation) of the window.
+ 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())
+ */
+ getWinSizeInPixels(): Size;
+ /**
+ !#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}}。
+ */
+ pause(): void;
+ /**
+ !#en
+ Run a scene. Replaces the running scene with a new one or enter the first scene.
+ 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.
+ */
+ runSceneImmediate(scene: Scene|SceneAsset, onBeforeLoadScene?: Function, onLaunched?: Function): void;
+ /**
+ !#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.
+ */
+ runScene(scene: Scene|SceneAsset, onBeforeLoadScene?: Function, onLaunched?: Function): 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.
+ */
+ loadScene(sceneName: string, onLaunched?: Function): boolean;
+ /**
+ !#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.
+ */
+ preloadScene(sceneName: string, onProgress?: (completedCount: number, totalCount: number, item: any) => void, onLoaded?: (error: Error) => void): void;
+ /**
+ !#en Resume game logic execution after pause, if the current scene is not paused, nothing will happen.
+ !#zh 恢复暂停场景的游戏逻辑,如果当前场景没有暂停将没任何事情发生。
+ */
+ resume(): void;
+ /**
+ !#en
+ Enables or disables WebGL depth test.
+ Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js
+ !#zh 启用/禁用深度测试(在 Canvas 渲染模式下不会生效)。
+ @param on on
+ */
+ setDepthTest(on: boolean): void;
+ /**
+ !#en
+ Set color for clear screen.
+ (Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js)
+ !#zh
+ 设置场景的默认擦除颜色。
+ 支持全透明,但不支持透明度为中间值。要支持全透明需手工开启 cc.macro.ENABLE_TRANSPARENT_CANVAS。
+ @param clearColor clearColor
+ */
+ setClearColor(clearColor: Color): void;
+ /**
+ !#en Returns current logic Scene.
+ !#zh 获取当前逻辑场景。
+
+ @example
+ ```js
+ // This will help you to get the Canvas node in scene
+ cc.director.getScene().getChildByName('Canvas');
+ ```
+ */
+ 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 Sets the cc.ActionManager associated with this director.
+ !#zh 设置和 director 相关联的 cc.ActionManager(动作管理器)。
+ @param actionManager actionManager
+ */
+ setActionManager(actionManager: ActionManager): void;
+ /**
+ !#en Returns the cc.CollisionManager associated with this director.
+ !#zh 获取和 director 相关联的 cc.CollisionManager (碰撞管理器)。
+ */
+ getCollisionManager(): CollisionManager;
+ /**
+ !#en Returns the cc.PhysicsManager associated with this director.
+ !#zh 返回与 director 相关联的 cc.PhysicsManager (物理管理器)。
+ */
+ getPhysicsManager(): PhysicsManager;
+ /**
+ !#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 {
@@ -3772,312 +4399,6 @@ declare namespace cc {
isOpacityModifyRGB(): boolean;
}
/** !#en
-
- cc.director is a singleton object which manage your game's logic flow.
- Since the cc.director is a singleton, you don't need to call any constructor or create functions,
- the standard way to use it is by calling:
- - cc.director.methodName();
-
- It creates and handle the main Window and manages how and when to execute the Scenes.
-
- The cc.director is also responsible for:
- - initializing the OpenGL context
- - setting the OpenGL pixel format (default on is RGB565)
- - setting the OpenGL buffer depth (default on is 0-bit)
- - setting the color for clear screen (default one is BLACK)
- - setting the projection (default one is 3D)
- - setting the orientation (default one is Portrait)
-
-
- The cc.director also sets the default OpenGL context:
- - GL_TEXTURE_2D is enabled
- - GL_VERTEX_ARRAY is enabled
- - GL_COLOR_ARRAY is enabled
- - GL_TEXTURE_COORD_ARRAY is enabled
-
- Features and Limitations:
- - Scheduled timers & drawing are synchronizes with the refresh rate of the display
- - Only supports animation intervals of 1/60 1/30 & 1/15
-
- cc.director 一个管理你的游戏的逻辑流程的单例对象。
- 由于 cc.director 是一个单例,你不需要调用任何构造函数或创建函数,
- 使用它的标准方法是通过调用:
- - cc.director.methodName();
-
- 它创建和处理主窗口并且管理什么时候执行场景。
-
- cc.director 还负责:
- - 初始化 OpenGL 环境。
- - 设置OpenGL像素格式。(默认是 RGB565)
- - 设置OpenGL缓冲区深度 (默认是 0-bit)
- - 设置空白场景的颜色 (默认是 黑色)
- - 设置投影 (默认是 3D)
- - 设置方向 (默认是 Portrait)
-
- cc.director 设置了 OpenGL 默认环境
- - GL_TEXTURE_2D 启用。
- - GL_VERTEX_ARRAY 启用。
- - GL_COLOR_ARRAY 启用。
- - GL_TEXTURE_COORD_ARRAY 启用。
-
- 特点和局限性:
- - 将计时器 & 渲染与显示器的刷新频率同步。
- - 只支持动画的间隔 1/60 1/30 & 1/15。
-
- Useful to convert (multi) touches coordinates to the current layout (portrait or landscape)
- Implementation can be found in CCDirectorWebGL.
- !#zh 将触摸点的屏幕坐标转换为 WebGL View 下的坐标。
- @param uiPoint uiPoint
- */
- convertToGL(uiPoint: Vec2): Vec2;
- /**
- !#en
- Converts an OpenGL coordinate to a view coordinate
- Useful to convert node points to window points for calls such as glScissor
- 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
- */
- end(): void;
- /**
- !#en
- Returns the size of the WebGL view in points.
- It takes into account any possible rotation (device orientation) of the window.
- !#zh 获取视图的大小,以点为单位。
- */
- getWinSize(): Size;
- /**
- !#en
- Returns the size of the OpenGL view in pixels.
- It takes into account any possible rotation (device orientation) of the window.
- 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())
- */
- getWinSizeInPixels(): Size;
- /**
- !#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}}。
- */
- pause(): void;
- /**
- !#en
- Run a scene. Replaces the running scene with a new one or enter the first scene.
- 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.
- */
- runSceneImmediate(scene: Scene|SceneAsset, onBeforeLoadScene?: Function, onLaunched?: Function): void;
- /**
- !#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.
- */
- runScene(scene: Scene|SceneAsset, onBeforeLoadScene?: Function, onLaunched?: Function): 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.
- */
- loadScene(sceneName: string, onLaunched?: Function): boolean;
- /**
- !#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.
- */
- preloadScene(sceneName: string, onProgress?: (completedCount: number, totalCount: number, item: any) => void, onLoaded?: (error: Error) => void): void;
- /**
- !#en Resume game logic execution after pause, if the current scene is not paused, nothing will happen.
- !#zh 恢复暂停场景的游戏逻辑,如果当前场景没有暂停将没任何事情发生。
- */
- resume(): void;
- /**
- !#en
- Enables or disables WebGL depth test.
- Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js
- !#zh 启用/禁用深度测试(在 Canvas 渲染模式下不会生效)。
- @param on on
- */
- setDepthTest(on: boolean): void;
- /**
- !#en
- Set color for clear screen.
- (Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js)
- !#zh
- 设置场景的默认擦除颜色。
- 支持全透明,但不支持透明度为中间值。要支持全透明需手工开启 cc.macro.ENABLE_TRANSPARENT_CANVAS。
- @param clearColor clearColor
- */
- setClearColor(clearColor: Color): void;
- /**
- !#en Returns current logic Scene.
- !#zh 获取当前逻辑场景。
-
- @example
- ```js
- // This will help you to get the Canvas node in scene
- cc.director.getScene().getChildByName('Canvas');
- ```
- */
- 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 Sets the cc.ActionManager associated with this director.
- !#zh 设置和 director 相关联的 cc.ActionManager(动作管理器)。
- @param actionManager actionManager
- */
- setActionManager(actionManager: ActionManager): void;
- /**
- !#en Returns the cc.CollisionManager associated with this director.
- !#zh 获取和 director 相关联的 cc.CollisionManager (碰撞管理器)。
- */
- getCollisionManager(): CollisionManager;
- /**
- !#en Returns the cc.PhysicsManager associated with this director.
- !#zh 返回与 director 相关联的 cc.PhysicsManager (物理管理器)。
- */
- getPhysicsManager(): PhysicsManager;
- /**
- !#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
- cc.Scene is a subclass of cc.Node that is used only as an abstract concept.
- cc.Scene and cc.Node are almost identical with the difference that users can not modify cc.Scene manually.
- !#zh
- cc.Scene 是 cc.Node 的子类,仅作为一个抽象的概念。
- 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.
The PrivateNode is hidden in editor, and completely transparent to users.
It's normally used as Node's private content created by components in parent node.
@@ -4103,6 +4424,17 @@ declare namespace cc {
constructor(name?: string);
}
/** !#en
+ cc.Scene is a subclass of cc.Node that is used only as an abstract concept.
+ cc.Scene and cc.Node are almost identical with the difference that users can not modify cc.Scene manually.
+ !#zh
+ cc.Scene 是 cc.Node 的子类,仅作为一个抽象的概念。
+ 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.
You should not use NSTimer. Instead use this class.
@@ -4322,337 +4654,466 @@ declare namespace cc {
!#zh 用户调度最低优先级。 */
static PRIORITY_NON_SYSTEM: number;
}
- /** !#en Class for animation data handling.
- !#zh 动画剪辑,用于存储动画数据。 */
- export class AnimationClip extends Asset {
- /** !#en Duration of this animation.
- !#zh 动画的持续时间。 */
+ /** Class for particle asset handling. */
+ export class ParticleAsset extends Asset {
+ }
+ /** Particle System base class.
+ Attributes of a Particle System:
+ - emmision rate of the particles
+ - Gravity Mode (Mode A):
+ - gravity
+ - direction
+ - speed +- variance
+ - tangential acceleration +- variance
+ - radial acceleration +- variance
+ - Radius Mode (Mode B):
+ - startRadius +- variance
+ - endRadius +- variance
+ - rotate +- variance
+ - Properties common to all modes:
+ - life +- life variance
+ - start spin +- variance
+ - end spin +- variance
+ - start size +- variance
+ - end size +- variance
+ - start color +- variance
+ - end color +- variance
+ - life +- variance
+ - blending function
+ - texture
+
+ cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).
+ 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d,
+ cocos2d uses a another approach, but the results are almost identical.
+ cocos2d supports all the variables used by Particle Designer plus a bit more:
+ - spinning particles (supported when using ParticleSystem)
+ - tangential acceleration (Gravity mode)
+ - radial acceleration (Gravity mode)
+ - radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only)
+ It is possible to customize any of the above mentioned properties in runtime. Example:
*/
+ 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 FrameRate of this animation.
- !#zh 动画的帧速率。 */
- sample: number;
- /** !#en Speed of this animation.
- !#zh 动画的播放速度。 */
+ /** !#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 WrapMode of this animation.
- !#zh 动画的循环模式。 */
- wrapMode: WrapMode;
- /** !#en Curve data.
- !#zh 曲线数据。 */
- curveData: any;
- /** !#en Event data.
- !#zh 事件数据。 */
- events: {frame: number, func: string, params: string[]}[];
+ /** !#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 Crate clip with a set of sprite frames
- !#zh 使用一组序列帧图片来创建动画剪辑
- @param spriteFrames spriteFrames
- @param sample sample
+ !#en Stop emitting particles. Running particles will continue to run until they die.
+ !#zh 停止发射器发射粒子,发射出去的粒子将继续运行,直至粒子生命结束。
@example
```js
- var clip = cc.AnimationClip.createWithSpriteFrames(spriteFrames, 10);
+ // stop particle system.
+ myParticleSystem.stopSystem();
```
*/
- 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 完全控制动画播放过程。
- 大多数情况下 动画组件 是足够和易于使用的。如果您需要更多的动画控制接口,请使用 AnimationState。 */
- export class AnimationState extends Playable {
+ stopSystem(): void;
/**
+ !#en Kill all living particles.
+ !#zh 杀死所有存在的粒子,然后重新启动粒子发射器。
- @param clip clip
- @param name name
+ @example
+ ```js
+ // play particle system.
+ myParticleSystem.resetSystem();
+ ```
*/
- 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
+ resetSystem(): void;
+ /**
+ !#en Whether or not the system is full.
+ !#zh 发射器中粒子是否大于等于设置的总粒子数量。
+ */
+ isFull(): boolean;
+ /**
+ !#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
+ */
+ 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.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).
+ Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.
+ Please refer to the official documentation for more details.
!#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;
+ 设置 JavaScript 接口方案(与 'setOnJSCallback' 配套使用)。
+ 注意:只支持 Android 和 iOS ,Web 端用法请前往官方文档查看。
+ 详情请参阅官方文档
+ @param scheme scheme
+ */
+ setJavascriptInterfaceScheme(scheme: string): void;
+ /**
+ !#en
+ This callback called when load URL that start with javascript
+ interface scheme (see also setJavascriptInterfaceScheme).
+ Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.
+ Please refer to the official documentation for more details.
+ !#zh
+ 当加载 URL 以 JavaScript 接口方案开始时调用这个回调函数。
+ 注意:只支持 Android 和 iOS,Web 端用法请前往官方文档查看。
+ 详情请参阅官方文档
+ @param callback callback
+ */
+ setOnJSCallback(callback: Function): void;
+ /**
+ !#en
+ Evaluates JavaScript in the context of the currently displayed page.
+ Please refer to the official document for more details
+ Note: Cross domain issues need to be resolved by yourself
+ !#zh
+ 执行 WebView 内部页面脚本(详情请参阅官方文档)
+ 注意:需要自行解决跨域问题
+ @param str str
+ */
+ 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 平台内存泄露。
+
+ @example
+ ```js
+ webview.node.parent = null; // or webview.node.removeFromParent(false);
+ // when you don't need webview anymore
+ webview.node.destroy();
+ ```
+ */
+ destroy(): boolean;
}
- /** !#en
- This class provide easing methods for {{#crossLink "tween"}}{{/crossLink}} class.
- Demonstratio: https://easings.net/
- !#zh
- 缓动函数类,为 {{#crossLink "Tween"}}{{/crossLink}} 提供缓动效果函数。
- 函数效果演示: https://easings.net/ */
- export class Easing {
+ /** !#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 Easing in with quadratic formula. From slow to fast.
- !#zh 平方曲线缓入函数。运动由慢到快。
- @param t The current time as a percentage of the total time.
- */
- quadIn(t: number): number;
- /**
- !#en Easing out with quadratic formula. From fast to slow.
- !#zh 平方曲线缓出函数。运动由快到慢。
- @param t The current time as a percentage of the total time.
- */
- quadOut(t: number): number;
- /**
- !#en Easing in and out with quadratic formula. From slow to fast, then back to slow.
- !#zh 平方曲线缓入缓出函数。运动由慢到快再到慢。
- @param t The current time as a percentage of the total time.
- */
- quadInOut(t: number): number;
- /**
- !#en Easing in with cubic formula. From slow to fast.
- !#zh 立方曲线缓入函数。运动由慢到快。
- @param t The current time as a percentage of the total time.
- */
- cubicIn(t: number): number;
- /**
- !#en Easing out with cubic formula. From slow to fast.
- !#zh 立方曲线缓出函数。运动由快到慢。
- @param t The current time as a percentage of the total time.
- */
- cubicOut(t: number): number;
- /**
- !#en Easing in and out with cubic formula. From slow to fast, then back to slow.
- !#zh 立方曲线缓入缓出函数。运动由慢到快再到慢。
- @param t The current time as a percentage of the total time.
- */
- cubicInOut(t: number): number;
- /**
- !#en Easing in with quartic formula. From slow to fast.
- !#zh 四次方曲线缓入函数。运动由慢到快。
- @param t The current time as a percentage of the total time.
- */
- quartIn(t: number): number;
- /**
- !#en Easing out with quartic formula. From fast to slow.
- !#zh 四次方曲线缓出函数。运动由快到慢。
- @param t The current time as a percentage of the total time.
- */
- quartOut(t: number): number;
- /**
- !#en Easing in and out with quartic formula. From slow to fast, then back to slow.
- !#zh 四次方曲线缓入缓出函数。运动由慢到快再到慢。
- @param t The current time as a percentage of the total time.
- */
- quartInOut(t: number): number;
- /**
- !#en Easing in with quintic formula. From slow to fast.
- !#zh 五次方曲线缓入函数。运动由慢到快。
- @param t The current time as a percentage of the total time.
- */
- quintIn(t: number): number;
- /**
- !#en Easing out with quintic formula. From fast to slow.
- !#zh 五次方曲线缓出函数。运动由快到慢。
- @param t The current time as a percentage of the total time.
- */
- quintOut(t: number): number;
- /**
- !#en Easing in and out with quintic formula. From slow to fast, then back to slow.
- !#zh 五次方曲线缓入缓出函数。运动由慢到快再到慢。
- @param t The current time as a percentage of the total time.
- */
- quintInOut(t: number): number;
- /**
- !#en Easing in and out with sine formula. From slow to fast.
- !#zh 正弦曲线缓入函数。运动由慢到快。
- @param t The current time as a percentage of the total time.
- */
- sineIn(t: number): number;
- /**
- !#en Easing in and out with sine formula. From fast to slow.
- !#zh 正弦曲线缓出函数。运动由快到慢。
- @param t The current time as a percentage of the total time.
- */
- sineOut(t: number): number;
- /**
- !#en Easing in and out with sine formula. From slow to fast, then back to slow.
- !#zh 正弦曲线缓入缓出函数。运动由慢到快再到慢。
- @param t The current time as a percentage of the total time.
- */
- sineInOut(t: number): number;
- /**
- !#en Easing in and out with exponential formula. From slow to fast.
- !#zh 指数曲线缓入函数。运动由慢到快。
- @param t The current time as a percentage of the total time.
- */
- expoIn(t: number): number;
- /**
- !#en Easing in and out with exponential formula. From fast to slow.
- !#zh 指数曲线缓出函数。运动由快到慢。
- @param t The current time as a percentage of the total time.
- */
- expoOut(t: number): number;
- /**
- !#en Easing in and out with exponential formula. From slow to fast.
- !#zh 指数曲线缓入和缓出函数。运动由慢到很快再到慢。
- @param t The current time as a percentage of the total time, then back to slow.
- */
- expoInOut(t: number): number;
- /**
- !#en Easing in and out with circular formula. From slow to fast.
- !#zh 循环公式缓入函数。运动由慢到快。
- @param t The current time as a percentage of the total time.
- */
- circIn(t: number): number;
- /**
- !#en Easing in and out with circular formula. From fast to slow.
- !#zh 循环公式缓出函数。运动由快到慢。
- @param t The current time as a percentage of the total time.
- */
- circOut(t: number): number;
- /**
- !#en Easing in and out with circular formula. From slow to fast.
- !#zh 指数曲线缓入缓出函数。运动由慢到很快再到慢。
- @param t The current time as a percentage of the total time, then back to slow.
- */
- circInOut(t: number): number;
- /**
- !#en Easing in action with a spring oscillating effect.
- !#zh 弹簧回震效果的缓入函数。
- @param t The current time as a percentage of the total time.
- */
- elasticIn(t: number): number;
- /**
- !#en Easing out action with a spring oscillating effect.
- !#zh 弹簧回震效果的缓出函数。
- @param t The current time as a percentage of the total time.
- */
- elasticOut(t: number): number;
- /**
- !#en Easing in and out action with a spring oscillating effect.
- !#zh 弹簧回震效果的缓入缓出函数。
- @param t The current time as a percentage of the total time.
- */
- elasticInOut(t: number): number;
- /**
- !#en Easing in action with "back up" behavior.
- !#zh 回退效果的缓入函数。
- @param t The current time as a percentage of the total time.
- */
- backIn(t: number): number;
- /**
- !#en Easing out action with "back up" behavior.
- !#zh 回退效果的缓出函数。
- @param t The current time as a percentage of the total time.
- */
- backOut(t: number): number;
- /**
- !#en Easing in and out action with "back up" behavior.
- !#zh 回退效果的缓入缓出函数。
- @param t The current time as a percentage of the total time.
- */
- backInOut(t: number): number;
- /**
- !#en Easing in action with bouncing effect.
- !#zh 弹跳效果的缓入函数。
- @param t The current time as a percentage of the total time.
- */
- bounceIn(t: number): number;
- /**
- !#en Easing out action with bouncing effect.
- !#zh 弹跳效果的缓出函数。
- @param t The current time as a percentage of the total time.
- */
- bounceOut(t: number): number;
- /**
- !#en Easing in and out action with bouncing effect.
- !#zh 弹跳效果的缓入缓出函数。
- @param t The current time as a percentage of the total time.
- */
- bounceInOut(t: number): number;
- /**
- !#en Target will run action with smooth effect.
- !#zh 平滑效果函数。
- @param t The current time as a percentage of the total time.
- */
- smooth(t: number): number;
- /**
- !#en Target will run action with fade effect.
- !#zh 渐褪效果函数。
- @param t The current time as a percentage of the total time.
- */
- fade(t: number): number;
- }
- /** undefined */
- export class Playable {
- /** !#en Is playing or paused in play mode?
- !#zh 当前是否正在播放。 */
- isPlaying: boolean;
- /** !#en Is currently paused? This can be true even if in edit mode(isPlaying == false).
- !#zh 当前是否正在暂停 */
- isPaused: boolean;
- /**
- !#en Play this animation.
- !#zh 播放动画。
+ !#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 Stop this animation.
- !#zh 停止动画播放。
- */
- stop(): void;
- /**
- !#en Pause this animation.
- !#zh 暂停动画。
- */
- pause(): void;
- /**
- !#en Resume this animation.
- !#zh 重新播放动画。
+ !#en If a video is paused, call this method to resume playing.
+ !#zh 如果一个视频播放被暂停播放了,调用这个接口可以继续播放。
*/
resume(): void;
/**
- !#en Perform a single frame step.
- !#zh 执行一帧动画。
+ !#en If a video is playing, call this method to pause playing.
+ !#zh 如果一个视频正在播放,调用这个接口可以暂停播放。
*/
- step(): void;
+ 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
+ videoplayer.node.parent = null; // or videoplayer.node.removeFromParent(false);
+ // when you don't need videoplayer anymore
+ videoplayer.node.destroy();
+ ```
+ */
+ destroy(): boolean;
}
- /** !#en Specifies how time is treated when it is outside of the keyframe range of an Animation.
- !#zh 动画使用的循环模式。 */
- export enum WrapMode {
- Default = 0,
- Normal = 0,
- Reverse = 0,
- Loop = 0,
- LoopReverse = 0,
- PingPong = 0,
- PingPongReverse = 0,
+ /** 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 {
+ }
+ /**
+ - Tileset name
+ - Tileset spacing
+ - Tileset margin
+ - size of the tiles
+ - Image used for the tiles
+ - Image size
+
+ This information is obtained from the TMX file.
+ - Map orientation (hexagonal, isometric or orthogonal)
+ - Tile size
+ - Map size
+ - Layers (an array of TMXLayerInfo objects)
+ - Tilesets (an array of TMXTilesetInfo objects)
+ - ObjectGroups (an array of TMXObjectGroupInfo objects)
- - Tileset name
- - Tileset spacing
- - Tileset margin
- - size of the tiles
- - Image used for the tiles
- - Image size
-
- This information is obtained from the TMX file.
- - Map orientation (hexagonal, isometric or orthogonal)
- - Tile size
- - Map size
- - Layers (an array of TMXLayerInfo objects)
- - Tilesets (an array of TMXTilesetInfo objects)
- - ObjectGroups (an array of TMXObjectGroupInfo objects)
- Attributes of a Particle System:
- - emmision rate of the particles
- - Gravity Mode (Mode A):
- - gravity
- - direction
- - speed +- variance
- - tangential acceleration +- variance
- - radial acceleration +- variance
- - Radius Mode (Mode B):
- - startRadius +- variance
- - endRadius +- variance
- - rotate +- variance
- - Properties common to all modes:
- - life +- life variance
- - start spin +- variance
- - end spin +- variance
- - start size +- variance
- - end size +- variance
- - start color +- variance
- - end color +- variance
- - life +- variance
- - blending function
- - texture
-
- cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).
- 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d,
- cocos2d uses a another approach, but the results are almost identical.
- cocos2d supports all the variables used by Particle Designer plus a bit more:
- - spinning particles (supported when using ParticleSystem)
- - tangential acceleration (Gravity mode)
- - radial acceleration (Gravity mode)
- - radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only)
- It is possible to customize any of the above mentioned properties in runtime. Example:
*/
- export class ParticleSystem extends RenderComponent implements BlendFunc {
- /** !#en Play particle in edit mode.
- !#zh 在编辑器模式下预览粒子,启用后选中粒子时,粒子将自动播放。 */
- preview: boolean;
+ /** !#en
+ Base class for handling assets used in Creator.
+
+ You may want to override:
+ - createNode
+ - getset functions of _nativeAsset
+ - cc.Object._serialize
+ - cc.Object._deserialize
+ !#zh
+ Creator 中的资源基类。
+
+ 您可能需要重写:
+ - createNode
+ - _nativeAsset 的 getset 方法
+ - cc.Object._serialize
+ - cc.Object._deserialize
*/
+ export class Asset extends Object {
/** !#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 Stop emitting particles. Running particles will continue to run until they die.
- !#zh 停止发射器发射粒子,发射出去的粒子将继续运行,直至粒子生命结束。
-
- @example
- ```js
- // stop particle system.
- myParticleSystem.stopSystem();
- ```
- */
- stopSystem(): void;
- /**
- !#en Kill all living particles.
- !#zh 杀死所有存在的粒子,然后重新启动粒子发射器。
-
- @example
- ```js
- // play particle system.
- myParticleSystem.resetSystem();
- ```
- */
- resetSystem(): void;
- /**
- !#en Whether or not the system is full.
- !#zh 发射器中粒子是否大于等于设置的总粒子数量。
- */
- isFull(): boolean;
- /**
- !#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
- */
- 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.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.
+ Whether the asset is loaded or not.
!#zh
- 如果你不再使用 VideoPlayer,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
- 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
+ 该资源是否已经成功加载。 */
+ loaded: boolean;
+ /** !#en
+ Returns the url of this asset's native object, if none it will returns an empty string.
+ !#zh
+ 返回该资源对应的目标平台资源的 URL,如果没有将返回一个空字符串。 */
+ nativeUrl: string;
+ /** !#en
+ The number of reference
- @example
- ```js
- videoplayer.node.parent = null; // or videoplayer.node.removeFromParent(false);
- // when you don't need videoplayer anymore
- videoplayer.node.destroy();
- ```
- */
- destroy(): boolean;
- }
- /** !#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[];
+ !#zh
+ 引用的数量 */
+ refCount: number;
+ /** !#en Indicates whether its dependent raw assets can support deferred load if the owner scene (or prefab) is marked as `asyncLoadAssets`.
+ !#zh 当场景或 Prefab 被标记为 `asyncLoadAssets`,禁止延迟加载该资源所依赖的其它原始资源。 */
+ static preventDeferredLoadDependents: boolean;
+ /** !#en Indicates whether its native object should be preloaded from native url.
+ !#zh 禁止预加载原生对象。 */
+ static preventPreloadNativeObject: boolean;
/**
!#en
- Set javascript interface scheme (see also setOnJSCallback).
- Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.
- Please refer to the official documentation for more details.
+ Returns the asset's url.
+
+ The `Asset` object overrides the `toString()` method of the `Object` object.
+ For `Asset` objects, the `toString()` method returns a string representation of the object.
+ JavaScript calls the `toString()` method automatically when an asset is to be represented as a text value or when a texture is referred to in a string concatenation.
!#zh
- 设置 JavaScript 接口方案(与 'setOnJSCallback' 配套使用)。
- 注意:只支持 Android 和 iOS ,Web 端用法请前往官方文档查看。
- 详情请参阅官方文档
- @param scheme scheme
+ 返回资源的 URL。
+
+ Asset 对象将会重写 Object 对象的 `toString()` 方法。
+ 对于 Asset 对象,`toString()` 方法返回该对象的字符串表示形式。
+ 当资源要表示为文本值时或在字符串连接时引用时,JavaScript 会自动调用 `toString()` 方法。
*/
- setJavascriptInterfaceScheme(scheme: string): void;
+ toString(): string;
/**
!#en
- This callback called when load URL that start with javascript
- interface scheme (see also setJavascriptInterfaceScheme).
- Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.
- Please refer to the official documentation for more details.
+ Create a new node using this asset in the scene.
+ If this type of asset dont have its corresponding node type, this method should be null.
!#zh
- 当加载 URL 以 JavaScript 接口方案开始时调用这个回调函数。
- 注意:只支持 Android 和 iOS,Web 端用法请前往官方文档查看。
- 详情请参阅官方文档
+ 使用该资源在场景中创建一个新节点。
+ 如果这类资源没有相应的节点类型,该方法应该是空的。
@param callback callback
*/
- setOnJSCallback(callback: Function): void;
+ createNode(callback: (error: string, node: any) => void): void;
/**
!#en
- Evaluates JavaScript in the context of the currently displayed page.
- Please refer to the official document for more details
- Note: Cross domain issues need to be resolved by yourself
+ Add references of asset
+
!#zh
- 执行 WebView 内部页面脚本(详情请参阅官方文档)
- 注意:需要自行解决跨域问题
- @param str str
+ 增加资源的引用
*/
- evaluateJS(str: string): void;
+ addRef(): cc.Asset;
/**
- !#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.
+ !#en
+ Reduce references of asset and it will be auto released when refCount equals 0.
+
!#zh
- 如果你不再使用 WebView,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
- 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
+ 减少资源的引用并尝试进行自动释放。
+ */
+ decRef(): cc.Asset;
+ /** `cc.Asset.url` is deprecated, please use {{#crossLink "Asset/nativeUrl:property"}}{{/crossLink}} instead */
+ url: string;
+ }
+ /** !#en Class for audio data handling.
+ !#zh 音频资源类。 */
+ export class AudioClip extends Asset implements EventTarget {
+ /** !#en Get the audio clip duration
+ !#zh 获取音频剪辑的长度 */
+ duration: number;
+ /**
+ !#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
- webview.node.parent = null; // or webview.node.removeFromParent(false);
- // when you don't need webview anymore
- webview.node.destroy();
+ eventTarget.on('fire', function () {
+ cc.log("fire in the hole");
+ }, node);
```
*/
- destroy(): boolean;
+ on
+ If you want to get the original JSON text, you should modify the extname to `.txt`
+ so that it is loaded as a `TextAsset` instead of a `JsonAsset`.
+
!#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[];
+ JSON 资源类。JSON 文件加载后,将会返回该对象。可以通过其中的 `json` 属性访问解析后的 JSON 对象。
+ 如果你想要获得 JSON 的原始文本,那么应该修改源文件的后缀为 `.txt`,这样就会加载为一个 `TextAsset` 而不是 `JsonAsset`。 */
+ export class JsonAsset extends Asset {
+ /** The loaded JSON object. */
+ json: any;
+ }
+ /** !#en Class for LabelAtlas handling.
+ !#zh 艺术数字字体资源类。 */
+ export class LabelAtlas extends BitmapFont {
+ }
+ /** !#en Class for prefab handling.
+ !#zh 预制资源类。 */
+ export class Prefab extends Asset {
+ /** the main cc.Node in the prefab */
+ data: Node;
+ /** !#zh
+ 设置实例化这个 prefab 时所用的优化策略。根据使用情况设置为合适的值,能优化该 prefab 实例化所用的时间。
+ !#en
+ Indicates the optimization policy for instantiating this prefab.
+ Set to a suitable value based on usage, can optimize the time it takes to instantiate this prefab. */
+ optimizationPolicy: Prefab.OptimizationPolicy;
+ /** !#en Indicates the raw assets of this prefab can be load after prefab loaded.
+ !#zh 指示该 Prefab 依赖的资源可否在 Prefab 加载后再延迟加载。 */
+ asyncLoadAssets: boolean;
+ readonly: boolean;
+ /**
+ Dynamically translation prefab data into minimized code.
+ This method will be called automatically before the first time the prefab being instantiated,
+ but you can re-call to refresh the create function once you modified the original prefab data in script.
+ */
+ compileCreateFunction(): void;
+ }
+ /** Render textures are textures that can be rendered to. */
+ export class RenderTexture extends Texture2D {
/**
!#en
- Get the first camera which the node belong to.
+ Init the render texture with size.
!#zh
- 获取节点所在的第一个摄像机。
- @param node node
+ 初始化 render texture
+ @param width width
+ @param height height
+ @param depthStencilFormat depthStencilFormat
*/
- static findCamera(node: Node): Camera;
+ initWithSize(width?: number, height?: number, depthStencilFormat?: number): void;
/**
!#en
- Get the screen to world matrix, only support 2D camera which alignWithScreen is true.
+ Get pixels from render texture, the pixels data stores in a RGBA Uint8Array.
+ It will return a new (width * height * 4) length Uint8Array by default。
+ You can specify a data to store the pixels to reuse the data,
+ you and can specify other params to specify the texture region to read.
!#zh
- 获取屏幕坐标系到世界坐标系的矩阵,只适用于 alignWithScreen 为 true 的 2D 摄像机。
- @param out the matrix to receive the result
+ 从 render texture 读取像素数据,数据类型为 RGBA 格式的 Uint8Array 数组。
+ 默认每次调用此函数会生成一个大小为 (长 x 高 x 4) 的 Uint8Array。
+ 你可以通过传入 data 来接收像素数据,也可以通过传参来指定需要读取的区域的像素。
+ @param data data
+ @param x x
+ @param y y
+ @param w w
+ @param h h
*/
- getScreenToWorldMatrix2D(out: Mat4): Mat4;
+ readPixels(data?: Uint8Array, x?: number, y?: number, w?: number, h?: number): Uint8Array;
+ }
+ /** !#en Class for scene handling.
+ !#zh 场景资源类。 */
+ export class SceneAsset extends Asset {
+ scene: Scene;
+ /** !#en Indicates the raw assets of this scene can be load after scene launched.
+ !#zh 指示该场景依赖的资源可否在场景切换后再延迟加载。 */
+ asyncLoadAssets: boolean;
+ }
+ /** !#en Class for script handling.
+ !#zh Script 资源类。 */
+ export class _Script extends Asset {
+ }
+ /** !#en Class for JavaScript handling.
+ !#zh JavaScript 资源类。 */
+ export class _JavaScript extends Asset {
+ }
+ /** !#en Class for TypeScript handling.
+ !#zh TypeScript 资源类。 */
+ export class TypeScript extends Asset {
+ }
+ /** !#en Class for sprite atlas handling.
+ !#zh 精灵图集资源类。 */
+ export class SpriteAtlas extends Asset {
+ /**
+ Returns the texture of the sprite atlas
+ */
+ getTexture(): Texture2D;
+ /**
+ Returns the sprite frame correspond to the given key in sprite atlas.
+ @param key key
+ */
+ getSpriteFrame(key: string): SpriteFrame;
+ /**
+ Returns the sprite frames in sprite atlas.
+ */
+ getSpriteFrames(): SpriteFrame[];
+ }
+ /** !#en
+ A cc.SpriteFrame has:
+ - texture: A cc.Texture2D that will be used by render components
+ - rectangle: A rectangle of the texture
+
+ !#zh
+ 一个 SpriteFrame 包含:
+ - 纹理:会被渲染组件使用的 Texture2D 对象。
+ - 矩形:在纹理中的矩形区域。 */
+ export class SpriteFrame extends Asset implements EventTarget {
+ /** !#en Top border of the sprite
+ !#zh sprite 的顶部边框 */
+ insetTop: number;
+ /** !#en Bottom border of the sprite
+ !#zh sprite 的底部边框 */
+ insetBottom: number;
+ /** !#en Left border of the sprite
+ !#zh sprite 的左边边框 */
+ insetLeft: number;
+ /** !#en Right border of the sprite
+ !#zh sprite 的左边边框 */
+ insetRight: number;
/**
!#en
- Get the world to camera matrix, only support 2D camera which alignWithScreen is true.
+ Constructor of SpriteFrame class.
!#zh
- 获取世界坐标系到摄像机坐标系的矩阵,只适用于 alignWithScreen 为 true 的 2D 摄像机。
- @param out the matrix to receive the result
+ SpriteFrame 类的构造函数。
+ @param filename filename
+ @param rect rect
+ @param rotated Whether the frame is rotated in the texture
+ @param offset The offset of the frame in the texture
+ @param originalSize The size of the frame in the texture
*/
- getWorldToScreenMatrix2D(out: Mat4): Mat4;
+ constructor(filename?: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size);
+ /**
+ !#en Returns whether the texture have been loaded
+ !#zh 返回是否已加载纹理
+ */
+ textureLoaded(): boolean;
+ /**
+ !#en Returns whether the sprite frame is rotated in the texture.
+ !#zh 获取 SpriteFrame 是否旋转
+ */
+ isRotated(): boolean;
+ /**
+ !#en Set whether the sprite frame is rotated in the texture.
+ !#zh 设置 SpriteFrame 是否旋转
+ @param bRotated bRotated
+ */
+ setRotated(bRotated: boolean): void;
+ /**
+ !#en Returns whether the sprite frame is flip x axis in the texture.
+ !#zh 获取 SpriteFrame 是否反转 x 轴
+ */
+ isFlipX(): boolean;
+ /**
+ !#en Returns whether the sprite frame is flip y axis in the texture.
+ !#zh 获取 SpriteFrame 是否反转 y 轴
+ */
+ isFlipY(): boolean;
+ /**
+ !#en Set whether the sprite frame is flip x axis in the texture.
+ !#zh 设置 SpriteFrame 是否翻转 x 轴
+ @param flipX flipX
+ */
+ setFlipX(flipX: boolean): void;
+ /**
+ !#en Set whether the sprite frame is flip y axis in the texture.
+ !#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.
+ !#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
- Convert point from screen to world.
+ 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
- 将坐标从屏幕坐标系转换到世界坐标系。
- @param screenPosition screenPosition
- @param out out
+ 当你暂时不再使用这个 SpriteFrame 时,可以调用这个方法来保证引用的贴图对象能被 GC。然后当你要渲染 SpriteFrame 时,你需要手动调用 `ensureLoadTexture` 来重新加载贴图。
*/
- getScreenToWorldPoint(screenPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3;
+ 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
- Convert point from world to screen.
+ Register an callback of a specific event type on the EventTarget.
+ This type of event should be triggered via `emit`.
!#zh
- 将坐标从世界坐标系转化到屏幕坐标系。
- @param worldPosition worldPosition
- @param out out
+ 注册事件目标的特定事件类型回调。这种类型的事件应该被 `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);
+ ```
*/
- getWorldToScreenPoint(worldPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3;
+ on
+ Note: texture is packed into texture atlas by default
+ you should set texture.packable as false before getting Html element object.
+ !#zh 获取当前贴图对应的 HTML Image 或 Canvas 对象,只在 Web 平台下有效。
+ 注意:
+ texture 默认参与动态合图,如果需要获取到正确的 Html 元素对象,需要先设置 texture.packable 为 false
*/
- getCameraToWorldMatrix(out: Mat4): Mat4;
+ getHtmlElementObj(): HTMLImageElement;
/**
!#en
- Get the world to camera matrix
+ Destory this texture and immediately release its video memory. (Inherit from cc.Object.destroy)
+ 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 out the matrix to receive the result
+ 销毁该贴图,并立即释放它对应的显存。(继承自 cc.Object.destroy)
+ 销毁后,该对象不再可用。您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。
*/
- getWorldToCameraMatrix(out: Mat4): Mat4;
+ destroy(): boolean;
+ /**
+ !#en
+ Pixel format of the texture.
+ !#zh 获取纹理的像素格式。
+ */
+ getPixelFormat(): number;
+ /**
+ !#en
+ Whether or not the texture has their Alpha premultiplied.
+ !#zh 检查纹理在上传 GPU 时预乘选项是否开启。
+ */
+ hasPremultipliedAlpha(): boolean;
+ /**
+ !#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
+ */
+ handleLoadedTexture(premultiplied?: boolean): void;
+ /**
+ !#en
+ Description of cc.Texture2D.
+ !#zh cc.Texture2D 描述。
+ */
+ description(): string;
+ /**
+ !#en
+ Release texture, please use destroy instead.
+ !#zh 释放纹理,请使用 destroy 替代。
+ */
+ releaseTexture(): void;
+ /**
+ !#en Sets the wrap s and wrap t options.
+ 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
+ */
+ setTexParameters(wrapS: Texture2D.WrapMode, wrapT: Texture2D.WrapMode): void;
+ /**
+ !#en Sets the minFilter and magFilter options
+ !#zh 设置纹理贴图缩小和放大过滤器算法选项。
+ @param minFilter minFilter
+ @param magFilter magFilter
+ */
+ setFilters(minFilter: Texture2D.Filter, magFilter: Texture2D.Filter): void;
+ /**
+ !#en
+ Sets the flipY options
+ !#zh 设置贴图的纵向翻转选项。
+ @param flipY flipY
+ */
+ setFlipY(flipY: boolean): void;
+ /**
+ !#en
+ Sets the premultiply alpha options
+ !#zh 设置贴图的预乘选项。
+ @param premultiply premultiply
+ */
+ setPremultiplyAlpha(premultiply: 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.
+ */
+ 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
-
- You may want to override:
- - createNode
- - getset functions of _nativeAsset
- - cc.Object._serialize
- - cc.Object._deserialize
- !#zh
- Creator 中的资源基类。
-
- 您可能需要重写:
- - createNode
- - _nativeAsset 的 getset 方法
- - cc.Object._serialize
- - cc.Object._deserialize
*/
- export class Asset extends Object {
- /** `cc.Asset.url` is deprecated, please use {{#crossLink "Asset/nativeUrl:property"}}{{/crossLink}} instead */
- url: string;
- /** !#en
- Whether the asset is loaded or not.
- !#zh
- 该资源是否已经成功加载。 */
- loaded: boolean;
- /** !#en
- Returns the url of this asset's native object, if none it will returns an empty string.
- !#zh
- 返回该资源对应的目标平台资源的 URL,如果没有将返回一个空字符串。 */
- nativeUrl: string;
- /** !#en
- The number of reference
-
- !#zh
- 引用的数量 */
- refCount: number;
- /** !#en Indicates whether its dependent raw assets can support deferred load if the owner scene (or prefab) is marked as `asyncLoadAssets`.
- !#zh 当场景或 Prefab 被标记为 `asyncLoadAssets`,禁止延迟加载该资源所依赖的其它原始资源。 */
- static preventDeferredLoadDependents: boolean;
- /** !#en Indicates whether its native object should be preloaded from native url.
- !#zh 禁止预加载原生对象。 */
- static preventPreloadNativeObject: boolean;
- /**
- !#en
- Returns the asset's url.
-
- The `Asset` object overrides the `toString()` method of the `Object` object.
- For `Asset` objects, the `toString()` method returns a string representation of the object.
- JavaScript calls the `toString()` method automatically when an asset is to be represented as a text value or when a texture is referred to in a string concatenation.
- !#zh
- 返回资源的 URL。
-
- Asset 对象将会重写 Object 对象的 `toString()` 方法。
- 对于 Asset 对象,`toString()` 方法返回该对象的字符串表示形式。
- 当资源要表示为文本值时或在字符串连接时引用时,JavaScript 会自动调用 `toString()` 方法。
- */
- toString(): string;
- /**
- !#en
- Create a new node using this asset in the scene.
- If this type of asset dont have its corresponding node type, this method should be null.
- !#zh
- 使用该资源在场景中创建一个新节点。
- 如果这类资源没有相应的节点类型,该方法应该是空的。
- @param callback callback
- */
- createNode(callback: (error: string, node: any) => void): void;
- /**
- !#en
- Add references of asset
-
- !#zh
- 增加资源的引用
- */
- addRef(): cc.Asset;
- /**
- !#en
- Reduce references of asset and it will be auto released when refCount equals 0.
-
- !#zh
- 减少资源的引用并尝试进行自动释放。
- */
- decRef(): cc.Asset;
- }
/** Predefined constants */
export class macro {
/** `cc.macro.DOWNLOAD_MAX_CONCURRENT` is deprecated now, please use {{#crossLink "Downloader/maxConcurrency:property"}}{{/crossLink}} instead */
@@ -6515,6 +7006,444 @@ declare namespace cc {
目前所有平台和设备支持的格式有 ['.webp', '.jpg', '.jpeg', '.bmp', '.png']. 另外 Ios 手机平台还额外支持了 PVR 格式。 */
static SUPPORT_TEXTURE_FORMATS: string[];
}
+ /** !#en The Light Component
+
+ !#zh 光源组件 */
+ export class Light extends Component {
+ }
+ /** !#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
+ 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.
+ !#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
+ */
+ getWorldToScreenPoint(worldPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3;
+ /**
+ !#en
+ Get a ray from screen position
+ !#zh
+ 从屏幕坐标获取一条射线
+ @param screenPos screenPos
+ */
+ getRay(screenPos: Vec2): geomUtils.Ray;
+ /**
+ !#en
+ Check whether the node is in the camera.
+ !#zh
+ 检测节点是否被此摄像机影响
+ @param node the node which need to check
+ */
+ containsNode(node: Node): boolean;
+ /**
+ !#en
+ Render the camera manually.
+ !#zh
+ 手动渲染摄像机。
+ @param rootNode rootNode
+ */
+ render(rootNode?: Node): void;
+ /**
+ !#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
+ */
+ getNodeToCameraTransform(node: Node): AffineTransform;
+ /**
+ !#en
+ Conver a camera coordinates point to world coordinates.
+ !#zh
+ 将一个摄像机坐标系下的点转换到世界坐标系下。
+ @param point the point which should transform
+ @param out the point to receive the result
+ */
+ getCameraToWorldPoint(point: Vec2, out?: Vec2): Vec2;
+ /**
+ !#en
+ Conver a world coordinates point to camera coordinates.
+ !#zh
+ 将一个世界坐标系下的点转换到摄像机坐标系下。
+ @param point point
+ @param out the point to receive the result
+ */
+ getWorldToCameraPoint(point: Vec2, out?: Vec2): Vec2;
+ /**
+ !#en
+ Get the camera to world matrix
+ !#zh
+ 获取摄像机坐标系到世界坐标系的矩阵
+ @param out the matrix to receive the result
+ */
+ getCameraToWorldMatrix(out: Mat4): Mat4;
+ /**
+ !#en
+ Get the world to camera matrix
+ !#zh
+ 获取世界坐标系到摄像机坐标系的矩阵
+ @param out the matrix to receive the result
+ */
+ getWorldToCameraMatrix(out: Mat4): Mat4;
+ }
+ /** !#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 是最常见的事件目标,
+ 但是其他对象也可以是事件目标。
*/
+ 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 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
+ note: It only be available when the event listener is associated with node.
+ It returns 0 when the listener is associated with fixed priority.
+
+ You can get the SystemEvent instance with cc.systemEvent.
+ !#zh
+ 系统事件,它目前支持按键事件和重力感应事件。
+ 你可以通过 cc.systemEvent 获取到 SystemEvent 的实例。
*/
+ 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;
+ }
/** !#en Box Collider.
!#zh 包围盒碰撞组件 */
export class BoxCollider extends Collider implements Collider.Box {
@@ -6788,6 +7717,68 @@ declare namespace cc {
!#zh 多边形顶点数组 */
points: Vec2[];
}
+ /** !#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 属性。
+ */
+ getPreviousLocation(): Vec2;
+ /**
+ !#en Returns the start touch location in OpenGL coordinates.
+ !#zh 获取触点落下时的位置对象,对象包含 x 和 y 属性。
+ */
+ getStartLocation(): Vec2;
+ /**
+ !#en Returns the delta distance from the previous touche to the current one in screen coordinates.
+ !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
+ */
+ getDelta(): Vec2;
+ /**
+ !#en Returns the current touch location in screen coordinates.
+ !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。
+ */
+ getLocationInView(): Vec2;
+ /**
+ !#en Returns the previous touch location in screen coordinates.
+ !#zh 获取触点在上一次事件时在游戏窗口中的位置对象,对象包含 x 和 y 属性。
+ */
+ getPreviousLocationInView(): Vec2;
+ /**
+ !#en Returns the start touch location in screen coordinates.
+ !#zh 获取触点落下时在游戏窗口中的位置对象,对象包含 x 和 y 属性。
+ */
+ getStartLocationInView(): Vec2;
+ /**
+ !#en Returns the id of cc.Touch.
+ !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。
+ */
+ getID(): number;
+ /**
+ !#en Sets information to touch.
+ !#zh 设置触摸相关的信息。用于监控触摸事件。
+ @param id id
+ @param x x
+ @param y y
+ */
+ setTouchInfo(id: number, x: number, y: number): void;
+ }
/** !#en The animation component is used to play back animations.
Animation provide several events to register:
@@ -8351,6 +9342,19 @@ declare namespace cc {
toggleItems: any[];
}
/** !#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.
+
+ !#zh
+ ViewGroup的事件处理比较特殊,因为 ViewGroup 里面的子节点关心的事件跟 ViewGroup 本身可能不一样。
+ 为了让子节点能够正确地处理事件,ViewGroup 需要注册 capture 阶段的事件,并且合理地处理 ViewGroup 之间的事件传递。
+ 请参考 ScrollView 的实现来获取更多信息。 */
+ export class ViewGroup extends Component {
+ }
+ /** !#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.
@@ -8487,19 +9491,6 @@ declare namespace cc {
注意:onEnable 时所在的那一帧仍然会进行对齐。 */
isAlignOnce: boolean;
}
- /** !#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.
-
- !#zh
- ViewGroup的事件处理比较特殊,因为 ViewGroup 里面的子节点关心的事件跟 ViewGroup 本身可能不一样。
- 为了让子节点能够正确地处理事件,ViewGroup 需要注册 capture 阶段的事件,并且合理地处理 ViewGroup 之间的事件传递。
- 请参考 ScrollView 的实现来获取更多信息。 */
- export class ViewGroup extends Component {
- }
/** !#en SubContextView is a view component which controls open data context viewport in minigame platform.
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.
@@ -8538,997 +9529,6 @@ declare namespace cc {
!#zh 自 v2.4.1 起,SwanSubContextView 已经废弃,请使用 SubContextView */
export class SwanSubContextView extends Component {
}
- /** !#en Class for audio data handling.
- !#zh 音频资源类。 */
- export class AudioClip extends Asset implements EventTarget {
- /** !#en Get the audio clip duration
- !#zh 获取音频剪辑的长度 */
- duration: number;
- /**
- !#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
- If you want to get the original JSON text, you should modify the extname to `.txt`
- so that it is loaded as a `TextAsset` instead of a `JsonAsset`.
-
- !#zh
- JSON 资源类。JSON 文件加载后,将会返回该对象。可以通过其中的 `json` 属性访问解析后的 JSON 对象。
- 如果你想要获得 JSON 的原始文本,那么应该修改源文件的后缀为 `.txt`,这样就会加载为一个 `TextAsset` 而不是 `JsonAsset`。 */
- export class JsonAsset extends Asset {
- /** The loaded JSON object. */
- json: any;
- }
- /** !#en Class for LabelAtlas handling.
- !#zh 艺术数字字体资源类。 */
- export class LabelAtlas extends BitmapFont {
- }
- /** !#en Class for prefab handling.
- !#zh 预制资源类。 */
- export class Prefab extends Asset {
- /** the main cc.Node in the prefab */
- data: Node;
- /** !#zh
- 设置实例化这个 prefab 时所用的优化策略。根据使用情况设置为合适的值,能优化该 prefab 实例化所用的时间。
- !#en
- Indicates the optimization policy for instantiating this prefab.
- Set to a suitable value based on usage, can optimize the time it takes to instantiate this prefab. */
- optimizationPolicy: Prefab.OptimizationPolicy;
- /** !#en Indicates the raw assets of this prefab can be load after prefab loaded.
- !#zh 指示该 Prefab 依赖的资源可否在 Prefab 加载后再延迟加载。 */
- asyncLoadAssets: boolean;
- readonly: boolean;
- /**
- Dynamically translation prefab data into minimized code.
- This method will be called automatically before the first time the prefab being instantiated,
- but you can re-call to refresh the create function once you modified the original prefab data in script.
- */
- compileCreateFunction(): void;
- }
- /** Render textures are textures that can be rendered to. */
- export class RenderTexture extends Texture2D {
- /**
- !#en
- Init the render texture with size.
- !#zh
- 初始化 render texture
- @param width width
- @param height height
- @param depthStencilFormat depthStencilFormat
- */
- initWithSize(width?: number, height?: number, depthStencilFormat?: number): void;
- /**
- !#en
- Get pixels from render texture, the pixels data stores in a RGBA Uint8Array.
- It will return a new (width * height * 4) length Uint8Array by default。
- You can specify a data to store the pixels to reuse the data,
- you and can specify other params to specify the texture region to read.
- !#zh
- 从 render texture 读取像素数据,数据类型为 RGBA 格式的 Uint8Array 数组。
- 默认每次调用此函数会生成一个大小为 (长 x 高 x 4) 的 Uint8Array。
- 你可以通过传入 data 来接收像素数据,也可以通过传参来指定需要读取的区域的像素。
- @param data data
- @param x x
- @param y y
- @param w w
- @param h h
- */
- readPixels(data?: Uint8Array, x?: number, y?: number, w?: number, h?: number): Uint8Array;
- }
- /** !#en Class for scene handling.
- !#zh 场景资源类。 */
- export class SceneAsset extends Asset {
- scene: Scene;
- /** !#en Indicates the raw assets of this scene can be load after scene launched.
- !#zh 指示该场景依赖的资源可否在场景切换后再延迟加载。 */
- asyncLoadAssets: boolean;
- }
- /** !#en Class for script handling.
- !#zh Script 资源类。 */
- export class _Script extends Asset {
- }
- /** !#en Class for JavaScript handling.
- !#zh JavaScript 资源类。 */
- export class _JavaScript extends Asset {
- }
- /** !#en Class for TypeScript handling.
- !#zh TypeScript 资源类。 */
- export class TypeScript extends Asset {
- }
- /** !#en Class for sprite atlas handling.
- !#zh 精灵图集资源类。 */
- export class SpriteAtlas extends Asset {
- /**
- Returns the texture of the sprite atlas
- */
- getTexture(): Texture2D;
- /**
- Returns the sprite frame correspond to the given key in sprite atlas.
- @param key key
- */
- getSpriteFrame(key: string): SpriteFrame;
- /**
- Returns the sprite frames in sprite atlas.
- */
- getSpriteFrames(): SpriteFrame[];
- }
- /** !#en
- A cc.SpriteFrame has:
- - texture: A cc.Texture2D that will be used by render components
- - rectangle: A rectangle of the texture
-
- !#zh
- 一个 SpriteFrame 包含:
- - 纹理:会被渲染组件使用的 Texture2D 对象。
- - 矩形:在纹理中的矩形区域。 */
- export class SpriteFrame extends Asset implements EventTarget {
- /** !#en Top border of the sprite
- !#zh sprite 的顶部边框 */
- insetTop: number;
- /** !#en Bottom border of the sprite
- !#zh sprite 的底部边框 */
- insetBottom: number;
- /** !#en Left border of the sprite
- !#zh sprite 的左边边框 */
- insetLeft: number;
- /** !#en Right border of the sprite
- !#zh sprite 的左边边框 */
- insetRight: number;
- /**
- !#en
- Constructor of SpriteFrame class.
- !#zh
- SpriteFrame 类的构造函数。
- @param filename filename
- @param rect rect
- @param rotated Whether the frame is rotated in the texture
- @param offset The offset of the frame in the texture
- @param originalSize The size of the frame in the texture
- */
- constructor(filename?: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size);
- /**
- !#en Returns whether the texture have been loaded
- !#zh 返回是否已加载纹理
- */
- textureLoaded(): boolean;
- /**
- !#en Returns whether the sprite frame is rotated in the texture.
- !#zh 获取 SpriteFrame 是否旋转
- */
- isRotated(): boolean;
- /**
- !#en Set whether the sprite frame is rotated in the texture.
- !#zh 设置 SpriteFrame 是否旋转
- @param bRotated bRotated
- */
- setRotated(bRotated: boolean): void;
- /**
- !#en Returns whether the sprite frame is flip x axis in the texture.
- !#zh 获取 SpriteFrame 是否反转 x 轴
- */
- isFlipX(): boolean;
- /**
- !#en Returns whether the sprite frame is flip y axis in the texture.
- !#zh 获取 SpriteFrame 是否反转 y 轴
- */
- isFlipY(): boolean;
- /**
- !#en Set whether the sprite frame is flip x axis in the texture.
- !#zh 设置 SpriteFrame 是否翻转 x 轴
- @param flipX flipX
- */
- setFlipX(flipX: boolean): void;
- /**
- !#en Set whether the sprite frame is flip y axis in the texture.
- !#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.
- !#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
- Note: texture is packed into texture atlas by default
- you should set texture.packable as false before getting Html element object.
- !#zh 获取当前贴图对应的 HTML Image 或 Canvas 对象,只在 Web 平台下有效。
- 注意:
- texture 默认参与动态合图,如果需要获取到正确的 Html 元素对象,需要先设置 texture.packable 为 false
- */
- getHtmlElementObj(): HTMLImageElement;
- /**
- !#en
- Destory this texture and immediately release its video memory. (Inherit from cc.Object.destroy)
- 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)
- 销毁后,该对象不再可用。您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。
- */
- destroy(): boolean;
- /**
- !#en
- Pixel format of the texture.
- !#zh 获取纹理的像素格式。
- */
- getPixelFormat(): number;
- /**
- !#en
- Whether or not the texture has their Alpha premultiplied.
- !#zh 检查纹理在上传 GPU 时预乘选项是否开启。
- */
- hasPremultipliedAlpha(): boolean;
- /**
- !#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
- */
- handleLoadedTexture(premultiplied?: boolean): void;
- /**
- !#en
- Description of cc.Texture2D.
- !#zh cc.Texture2D 描述。
- */
- description(): string;
- /**
- !#en
- Release texture, please use destroy instead.
- !#zh 释放纹理,请使用 destroy 替代。
- */
- releaseTexture(): void;
- /**
- !#en Sets the wrap s and wrap t options.
- 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
- */
- setTexParameters(wrapS: Texture2D.WrapMode, wrapT: Texture2D.WrapMode): void;
- /**
- !#en Sets the minFilter and magFilter options
- !#zh 设置纹理贴图缩小和放大过滤器算法选项。
- @param minFilter minFilter
- @param magFilter magFilter
- */
- setFilters(minFilter: Texture2D.Filter, magFilter: Texture2D.Filter): void;
- /**
- !#en
- Sets the flipY options
- !#zh 设置贴图的纵向翻转选项。
- @param flipY flipY
- */
- setFlipY(flipY: boolean): void;
- /**
- !#en
- Sets the premultiply alpha options
- !#zh 设置贴图的预乘选项。
- @param premultiply premultiply
- */
- setPremultiplyAlpha(premultiply: 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.
- */
- 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
- note: It only be available when the event listener is associated with node.
- It returns 0 when the listener is associated with fixed priority.
-
*/
- 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 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
- You can get the SystemEvent instance with cc.systemEvent.
- !#zh
- 系统事件,它目前支持按键事件和重力感应事件。
- 你可以通过 cc.systemEvent 获取到 SystemEvent 的实例。
*/
- 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;
- }
/** undefined */
export class Graphics extends RenderComponent {
/** !#en
@@ -9673,6 +9673,233 @@ declare namespace cc {
*/
fill(): 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.
+ 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 事件触发后才可获取。
+ 大多数情况下,它都会是 WebGL 渲染引擎实例,但是在微信开放数据域当中,它会是 Canvas 渲染引擎实例。请注意,从 2.0 开始,我们在其他平台和环境下都废弃了 Canvas 渲染器。 */
+ static renderEngine: any;
+ /** !#en The total draw call count in last rendered frame.
+ !#zh 上一次渲染帧所提交的渲染批次总数。 */
+ static drawCalls: number;
+ }
+ /** !#en Mesh Asset.
+ !#zh 网格资源。 */
+ export class Mesh extends Asset implements EventTarget {
+ /** !#en Get ir set the sub meshes.
+ !#zh 设置或者获取子网格。 */
+ subMeshes: InputAssembler[];
+ /**
+ !#en
+ 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
+ */
+ init(vertexFormat: gfx.VertexFormat, vertexCount: number, dynamic?: boolean, index?: boolean): void;
+ /**
+ !#en
+ Set the vertex values.
+ !#zh
+ 设置顶点数据
+ @param name the attribute name, e.g. gfx.ATTR_POSITION
+ @param values the vertex values
+ */
+ setVertices(name: string, values: Vec2[]|Vec3[]|Color[]|number[]|Uint8Array|Float32Array): 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.
+ */
+ setIndices(indices: number[]|Uint16Array|Uint8Array, index?: number, dynamic?: boolean): void;
+ /**
+ !#en
+ Set the sub mesh primitive type.
+ !#zh
+ 设置子网格绘制线条的方式。
+ @param type type
+ @param index index
+ */
+ setPrimitiveType(type: number, index: number): void;
+ /**
+ !#en
+ Clear the buffer data.
+ !#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.
+ */
+ 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
+ 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
- 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 事件触发后才可获取。
- 大多数情况下,它都会是 WebGL 渲染引擎实例,但是在微信开放数据域当中,它会是 Canvas 渲染引擎实例。请注意,从 2.0 开始,我们在其他平台和环境下都废弃了 Canvas 渲染器。 */
- static renderEngine: any;
- /** !#en The total draw call count in last rendered frame.
- !#zh 上一次渲染帧所提交的渲染批次总数。 */
- static drawCalls: number;
+ /** !#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;
+ /**
+ !#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"
+
+ ```
+ */
+ static basename(pathStr: string, extname?: string): any;
+ /**
+ !#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"
+
+ ```
+ */
+ 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;
}
- /** !#en Mesh Asset.
- !#zh 网格资源。 */
- export class Mesh extends Asset implements EventTarget {
- /** !#en Get ir set the sub meshes.
- !#zh 设置或者获取子网格。 */
- subMeshes: InputAssembler[];
+ /** !#en
+ AffineTransform class represent an affine transform matrix. It's composed basically by translation, rotation, scale transformations.
+ !#zh
+ AffineTransform 类代表一个仿射变换矩阵。它基本上是由平移旋转,缩放转变所组成。
*/
+ 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
- Init vertex buffer according to the vertex format.
+ Create a identity transformation matrix:
+ [ 1, 0, 0,
+ 0, 1, 0 ]
!#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
+ 单位矩阵:
+ [ 1, 0, 0,
+ 0, 1, 0 ]
*/
- init(vertexFormat: gfx.VertexFormat, vertexCount: number, dynamic?: boolean, index?: boolean): void;
+ static identity(): AffineTransform;
+ /**
+ !#en Clone a AffineTransform object from the specified transform.
+ !#zh 克隆指定的 AffineTransform 对象。
+ @param t t
+ */
+ static clone(t: AffineTransform): AffineTransform;
/**
!#en
- Set the vertex values.
+ 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
- 设置顶点数据
- @param name the attribute name, e.g. gfx.ATTR_POSITION
- @param values the vertex values
+ 拼接两个矩阵,将结果保存到 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.
*/
- setVertices(name: string, values: Vec2[]|Vec3[]|Color[]|number[]|Uint8Array|Float32Array): void;
+ static concat(out: AffineTransform, t1: AffineTransform, t2: AffineTransform): AffineTransform;
+ /**
+ !#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
+ */
+ 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
+ The local active state of this node.
+ Note that a Node may be inactive because a parent is not active, even if this returns true.
+ Use {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}} if you want to check if the Node is actually treated as active in the scene.
+ !#zh
+ 当前节点的自身激活状态。
+ 值得注意的是,一个节点的父节点如果不被激活,那么即使它自身设为激活,它仍然无法激活。
+ 如果你想检查节点在场景中实际的激活状态可以使用 {{#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
- 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.
+ Properties configuration function
+ All properties in attrs will be set to the node,
+ when the setter of the node is available,
+ the property will be set via setter function.
+ !#zh 属性配置函数。在 attrs 的所有属性将被设置为节点属性。
+ @param attrs Properties to be set to node
+
+ @example
+ ```js
+ var attrs = { key: 0, num: 100 };
+ node.attr(attrs);
+ ```
*/
- setIndices(indices: number[]|Uint16Array|Uint8Array, index?: number, dynamic?: boolean): void;
+ attr(attrs: any): void;
+ /**
+ !#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);
+ ```
+ */
+ getChildByUuid(uuid: string): Node;
+ /**
+ !#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");
+ ```
+ */
+ getChildByName(name: string): Node;
/**
!#en
- Set the sub mesh primitive type.
+ Inserts a child to the node at a specified index.
!#zh
- 设置子网格绘制线条的方式。
- @param type type
- @param index index
+ 插入子节点到指定位置
+ @param child the child node to be inserted
+ @param siblingIndex the sibling index to place the child in
+
+ @example
+ ```js
+ node.insertChild(child, 2);
+ ```
*/
- setPrimitiveType(type: number, index: number): void;
+ insertChild(child: Node, siblingIndex: number): void;
+ /**
+ !#en Get the sibling index.
+ !#zh 获取同级索引。
+
+ @example
+ ```js
+ var index = node.getSiblingIndex();
+ ```
+ */
+ getSiblingIndex(): number;
+ /**
+ !#en Set the sibling index of this node.
+ !#zh 设置节点同级索引。
+ @param index index
+
+ @example
+ ```js
+ node.setSiblingIndex(1);
+ ```
+ */
+ setSiblingIndex(index: number): 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');
+ });
+ ```
+ */
+ walk(prefunc: (target: _BaseNode) => void, postfunc: (target: _BaseNode) => void): void;
/**
!#en
- Clear the buffer data.
+ Remove itself from its parent node. If cleanup is `true`, then also remove all events and actions.
+ 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.
+ If the node orphan, then nothing happens.
!#zh
- 清除网格创建的内存数据。
+ 从父节点中删除该节点。如果不传入 cleanup 参数或者传入 `true`,那么这个节点上所有绑定的事件、action 都会被删除。
+ 因此建议调用这个 API 时总是传入 `false` 参数。
+ 如果这个节点是一个孤节点,那么什么都不会发生。
+ @param cleanup true if all actions and callbacks on this node should be removed, false otherwise.
+
+ @example
+ ```js
+ node.removeFromParent();
+ node.removeFromParent(false);
+ ```
*/
- clear(): void;
+ removeFromParent(cleanup?: boolean): void;
/**
- !#en Set mesh bounding box
- !#zh 设置网格的包围盒
- @param min min
- @param max max
+ !#en
+ Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter.