From f4b2afb9f59687a99ac8a9d401e01554fbb2354a Mon Sep 17 00:00:00 2001
From: JianMiau An interval action is an action that takes place within a certain period of time. These CCActionInterval actions have some interesting properties, like: For example, you can simulate a Ping Pong effect running the action normally and
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 也同步定时器与显示器的刷新速率。
@@ -4424,16 +4424,16 @@ declare namespace cc {
@param repeat repeat
@param delay delay
@param paused paused
-
- @example
+
+ @example
```js
//register a schedule to scheduler
cc.director.getScheduler().schedule(callback, this, interval, !this._isRunning);
-
- ```
+
+ ```
*/
schedule(callback: Function, target: any, interval: number, repeat: number, delay: number, paused?: boolean): void;
- schedule(callback: Function, target: any, interval: number, paused?: boolean): void;
+ schedule(callback: Function, target: any, interval: number, paused?: boolean): void;
/**
!#en
Schedules the update callback for a given target,
@@ -4444,9 +4444,9 @@ declare namespace cc {
优先级的值越低,定时器被触发的越早。
@param target target
@param priority priority
- @param paused paused
+ @param paused paused
*/
- scheduleUpdate(target: any, priority: number, paused: boolean): void;
+ scheduleUpdate(target: any, priority: number, paused: boolean): void;
/**
!#en
Unschedules a callback for a callback and a given target.
@@ -4455,32 +4455,32 @@ declare namespace cc {
取消指定对象定时器。
如果需要取消 update 定时器,请使用 unscheduleUpdate()。
@param callback The callback to be unscheduled
- @param target The target bound to the callback.
+ @param target The target bound to the callback.
*/
- unschedule(callback: Function, target: any): void;
+ unschedule(callback: Function, target: any): void;
/**
!#en Unschedules the update callback for a given target.
!#zh 取消指定对象的 update 定时器。
- @param target The target to be unscheduled.
+ @param target The target to be unscheduled.
*/
- unscheduleUpdate(target: any): void;
+ unscheduleUpdate(target: any): void;
/**
!#en
Unschedules all scheduled callbacks for a given target.
This also includes the "update" callback.
!#zh 取消指定对象的所有定时器,包括 update 定时器。
- @param target The target to be unscheduled.
+ @param target The target to be unscheduled.
*/
- unscheduleAllForTarget(target: any): void;
+ unscheduleAllForTarget(target: any): void;
/**
!#en
Unschedules all scheduled callbacks from all targets including the system callbacks. 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.
If enabled, the texture coordinates will be calculated by using this formula:
If enabled, actions that alter the position property (eg: CCMoveBy, CCJumpBy, CCBezierBy, etc..) will be stacked.
- Gets current target of the event
Please DO NOT remove this String, it is an important flag for bug tracking.
If you post a bug to forum, please attach this flag. */
- export var ENGINE_VERSION: string;
+ export var ENGINE_VERSION: string;
/**
!#en
Creates the speed action which changes the speed of an action, making it take longer (speed > 1)
@@ -16,129 +16,129 @@ declare namespace cc {
!#zh 修改目标动作的速率。
@param action action
@param speed speed
-
- @example
+
+ @example
```js
// change the target action speed;
var action = cc.scaleTo(0.2, 1, 0.6);
var newAction = cc.speed(action, 0.5);
- ```
+ ```
*/
- export function speed(action: ActionInterval, speed: number): Action;
+ export function speed(action: ActionInterval, speed: number): Action;
/**
!#en Create a follow action which makes its target follows another node.
!#zh 追踪目标节点的位置。
@param followedNode followedNode
@param rect rect
-
- @example
+
+ @example
```js
// example
// creates the action with a set boundary
var followAction = cc.follow(targetNode, cc.rect(0, 0, screenWidth * 2 - 100, screenHeight));
node.runAction(followAction);
-
+
// creates the action with no boundary set
var followAction = cc.follow(targetNode);
node.runAction(followAction);
- ```
+ ```
*/
- export function follow(followedNode: Node, rect: Rect): Action;
+ export function follow(followedNode: Node, rect: Rect): Action;
/**
Points setter
- @param points points
+ @param points points
*/
- export function setPoints(points: any[]): void;
+ export function setPoints(points: any[]): void;
/**
!#en Creates an action with a Cardinal Spline array of points and tension.
!#zh 按基数样条曲线轨迹移动到目标位置。
@param duration duration
@param points array of control points
@param tension tension
-
- @example
+
+ @example
```js
//create a cc.CardinalSplineTo
var action1 = cc.cardinalSplineTo(3, array, 0);
- ```
+ ```
*/
- export function cardinalSplineTo(duration: number, points: any[], tension: number): ActionInterval;
+ export function cardinalSplineTo(duration: number, points: any[], tension: number): ActionInterval;
/**
update position of target
- @param newPos newPos
+ @param newPos newPos
*/
- export function updatePosition(newPos: Vec2): void;
+ export function updatePosition(newPos: Vec2): void;
/**
!#en Creates an action with a Cardinal Spline array of points and tension.
!#zh 按基数样条曲线轨迹移动指定的距离。
@param duration duration
@param points points
- @param tension tension
+ @param tension tension
*/
- export function cardinalSplineBy(duration: number, points: any[], tension: number): ActionInterval;
+ export function cardinalSplineBy(duration: number, points: any[], tension: number): ActionInterval;
/**
!#en Creates an action with a Cardinal Spline array of points and tension.
!#zh 按 Catmull Rom 样条曲线轨迹移动到目标位置。
@param dt dt
@param points points
-
- @example
+
+ @example
```js
var action1 = cc.catmullRomTo(3, array);
- ```
+ ```
*/
- export function catmullRomTo(dt: number, points: any[]): ActionInterval;
+ export function catmullRomTo(dt: number, points: any[]): ActionInterval;
/**
!#en Creates an action with a Cardinal Spline array of points and tension.
!#zh 按 Catmull Rom 样条曲线轨迹移动指定的距离。
@param dt dt
@param points points
-
- @example
+
+ @example
```js
var action1 = cc.catmullRomBy(3, array);
- ```
+ ```
*/
- export function catmullRomBy(dt: number, points: any[]): ActionInterval;
+ export function catmullRomBy(dt: number, points: any[]): ActionInterval;
/**
!#en
Creates the action easing object with the rate parameter.
From slow to fast.
!#zh 创建 easeIn 缓动对象,由慢到快。
@param rate rate
-
- @example
+
+ @example
```js
action.easing(cc.easeIn(3.0));
- ```
+ ```
*/
- export function easeIn(rate: number): any;
+ export function easeIn(rate: number): any;
/**
!#en
Creates the action easing object with the rate parameter.
From fast to slow.
!#zh 创建 easeOut 缓动对象,由快到慢。
@param rate rate
-
- @example
+
+ @example
```js
action.easing(cc.easeOut(3.0));
- ```
+ ```
*/
- export function easeOut(rate: number): any;
+ export function easeOut(rate: number): any;
/**
!#en
Creates the action easing object with the rate parameter.
Slow to fast then to slow.
!#zh 创建 easeInOut 缓动对象,慢到快,然后慢。
@param rate rate
-
- @example
+
+ @example
```js
action.easing(cc.easeInOut(3.0));
- ```
+ ```
*/
- export function easeInOut(rate: number): any;
+ export function easeInOut(rate: number): any;
/**
!#en
Creates the action easing object with the rate parameter.
@@ -148,13 +148,13 @@ declare namespace cc {
创建 easeExponentialIn 缓动对象。
EaseExponentialIn 是按指数函数缓动进入的动作。
参考 easeInExpo:http://www.zhihu.com/question/21981571/answer/19925418
-
- @example
+
+ @example
```js
action.easing(cc.easeExponentialIn());
- ```
+ ```
*/
- export function easeExponentialIn(): any;
+ export function easeExponentialIn(): any;
/**
!#en
Creates the action easing object.
@@ -164,13 +164,13 @@ declare namespace cc {
创建 easeExponentialOut 缓动对象。
EaseExponentialOut 是按指数函数缓动退出的动作。
参考 easeOutExpo:http://www.zhihu.com/question/21981571/answer/19925418
-
- @example
+
+ @example
```js
action.easing(cc.easeExponentialOut());
- ```
+ ```
*/
- export function easeExponentialOut(): any;
+ export function easeExponentialOut(): any;
/**
!#en
Creates an EaseExponentialInOut action easing object.
@@ -180,13 +180,13 @@ declare namespace cc {
创建 easeExponentialInOut 缓动对象。
EaseExponentialInOut 是按指数函数缓动进入并退出的动作。
参考 easeInOutExpo:http://www.zhihu.com/question/21981571/answer/19925418
-
- @example
+
+ @example
```js
action.easing(cc.easeExponentialInOut());
- ```
+ ```
*/
- export function easeExponentialInOut(): any;
+ export function easeExponentialInOut(): any;
/**
!#en
Creates an EaseSineIn action.
@@ -196,13 +196,13 @@ declare namespace cc {
创建 EaseSineIn 缓动对象。
EaseSineIn 是按正弦函数缓动进入的动作。
参考 easeInSine:http://www.zhihu.com/question/21981571/answer/19925418
-
- @example
+
+ @example
```js
action.easing(cc.easeSineIn());
- ```
+ ```
*/
- export function easeSineIn(): any;
+ export function easeSineIn(): any;
/**
!#en
Creates an EaseSineOut action easing object.
@@ -212,13 +212,13 @@ declare namespace cc {
创建 EaseSineOut 缓动对象。
EaseSineIn 是按正弦函数缓动退出的动作。
参考 easeOutSine:http://www.zhihu.com/question/21981571/answer/19925418
-
- @example
+
+ @example
```js
action.easing(cc.easeSineOut());
- ```
+ ```
*/
- export function easeSineOut(): any;
+ export function easeSineOut(): any;
/**
!#en
Creates the action easing object.
@@ -228,13 +228,13 @@ declare namespace cc {
创建 easeSineInOut 缓动对象。
EaseSineIn 是按正弦函数缓动进入并退出的动作。
参考 easeInOutSine:http://www.zhihu.com/question/21981571/answer/19925418
-
- @example
+
+ @example
```js
action.easing(cc.easeSineInOut());
- ```
+ ```
*/
- export function easeSineInOut(): any;
+ export function easeSineInOut(): any;
/**
!#en
Creates the action easing object with the period in radians (default is 0.3).
@@ -245,14 +245,14 @@ declare namespace cc {
EaseElasticIn 是按弹性曲线缓动进入的动作。
参数 easeInElastic:http://www.zhihu.com/question/21981571/answer/19925418
@param period period
-
- @example
+
+ @example
```js
// example
action.easing(cc.easeElasticIn(3.0));
- ```
+ ```
*/
- export function easeElasticIn(period: number): any;
+ export function easeElasticIn(period: number): any;
/**
!#en
Creates the action easing object with the period in radians (default is 0.3).
@@ -263,14 +263,14 @@ declare namespace cc {
EaseElasticOut 是按弹性曲线缓动退出的动作。
参考 easeOutElastic:http://www.zhihu.com/question/21981571/answer/19925418
@param period period
-
- @example
+
+ @example
```js
// example
action.easing(cc.easeElasticOut(3.0));
- ```
+ ```
*/
- export function easeElasticOut(period: number): any;
+ export function easeElasticOut(period: number): any;
/**
!#en
Creates the action easing object with the period in radians (default is 0.3).
@@ -281,14 +281,14 @@ declare namespace cc {
EaseElasticInOut 是按弹性曲线缓动进入并退出的动作。
参考 easeInOutElastic:http://www.zhihu.com/question/21981571/answer/19925418
@param period period
-
- @example
+
+ @example
```js
// example
action.easing(cc.easeElasticInOut(3.0));
- ```
+ ```
*/
- export function easeElasticInOut(period: number): any;
+ export function easeElasticInOut(period: number): any;
/**
!#en
Creates the action easing object.
@@ -296,14 +296,14 @@ declare namespace cc {
!#zh
创建 easeBounceIn 缓动对象。
EaseBounceIn 是按弹跳动作缓动进入的动作。
-
- @example
+
+ @example
```js
// example
action.easing(cc.easeBounceIn());
- ```
+ ```
*/
- export function easeBounceIn(): any;
+ export function easeBounceIn(): any;
/**
!#en
Creates the action easing object.
@@ -311,14 +311,14 @@ declare namespace cc {
!#zh
创建 easeBounceOut 缓动对象。
EaseBounceOut 是按弹跳动作缓动退出的动作。
-
- @example
+
+ @example
```js
// example
action.easing(cc.easeBounceOut());
- ```
+ ```
*/
- export function easeBounceOut(): any;
+ export function easeBounceOut(): any;
/**
!#en
Creates the action easing object.
@@ -326,14 +326,14 @@ declare namespace cc {
!#zh
创建 easeBounceInOut 缓动对象。
EaseBounceInOut 是按弹跳动作缓动进入并退出的动作。
-
- @example
+
+ @example
```js
// example
action.easing(cc.easeBounceInOut());
- ```
+ ```
*/
- export function easeBounceInOut(): any;
+ export function easeBounceInOut(): any;
/**
!#en
Creates the action easing object.
@@ -341,14 +341,14 @@ declare namespace cc {
!#zh
创建 easeBackIn 缓动对象。
easeBackIn 是在相反的方向缓慢移动,然后加速到正确的方向。
-
- @example
+
+ @example
```js
// example
action.easing(cc.easeBackIn());
- ```
+ ```
*/
- export function easeBackIn(): any;
+ export function easeBackIn(): any;
/**
!#en
Creates the action easing object.
@@ -356,28 +356,28 @@ declare namespace cc {
!#zh
创建 easeBackOut 缓动对象。
easeBackOut 快速移动超出目标,然后慢慢回到目标点。
-
- @example
+
+ @example
```js
// example
action.easing(cc.easeBackOut());
- ```
+ ```
*/
- export function easeBackOut(): any;
+ export function easeBackOut(): any;
/**
!#en
Creates the action easing object.
Begining of cc.EaseBackIn. Ending of cc.EaseBackOut.
!#zh
创建 easeBackInOut 缓动对象。
-
- @example
+
+ @example
```js
// example
action.easing(cc.easeBackInOut());
- ```
+ ```
*/
- export function easeBackInOut(): any;
+ export function easeBackInOut(): any;
/**
!#en
Creates the action easing object.
@@ -390,14 +390,14 @@ declare namespace cc {
@param p1 The second bezier parameter
@param p2 The third bezier parameter
@param p3 The fourth bezier parameter
-
- @example
+
+ @example
```js
// example
action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0));
- ```
+ ```
*/
- export function easeBezierAction(p0: number, p1: number, p2: number, p3: number): any;
+ export function easeBezierAction(p0: number, p1: number, p2: number, p3: number): any;
/**
!#en
Creates the action easing object.
@@ -407,14 +407,14 @@ declare namespace cc {
创建 easeQuadraticActionIn 缓动对象。
EaseQuadraticIn是按二次函数缓动进入的动作。
参考 easeInQuad:http://www.zhihu.com/question/21981571/answer/19925418
-
- @example
+
+ @example
```js
//example
action.easing(cc.easeQuadraticActionIn());
- ```
+ ```
*/
- export function easeQuadraticActionIn(): any;
+ export function easeQuadraticActionIn(): any;
/**
!#en
Creates the action easing object.
@@ -424,14 +424,14 @@ declare namespace cc {
创建 easeQuadraticActionOut 缓动对象。
EaseQuadraticOut 是按二次函数缓动退出的动作。
参考 easeOutQuad:http://www.zhihu.com/question/21981571/answer/19925418
-
- @example
+
+ @example
```js
//example
action.easing(cc.easeQuadraticActionOut());
- ```
+ ```
*/
- export function easeQuadraticActionOut(): any;
+ export function easeQuadraticActionOut(): any;
/**
!#en
Creates the action easing object.
@@ -441,14 +441,14 @@ declare namespace cc {
创建 easeQuadraticActionInOut 缓动对象。
EaseQuadraticInOut 是按二次函数缓动进入并退出的动作。
参考 easeInOutQuad:http://www.zhihu.com/question/21981571/answer/19925418
-
- @example
+
+ @example
```js
//example
action.easing(cc.easeQuadraticActionInOut());
- ```
+ ```
*/
- export function easeQuadraticActionInOut(): any;
+ export function easeQuadraticActionInOut(): any;
/**
!#en
Creates the action easing object.
@@ -458,14 +458,14 @@ declare namespace cc {
创建 easeQuarticActionIn 缓动对象。
EaseQuarticIn 是按四次函数缓动进入的动作。
参考 easeIntQuart:http://www.zhihu.com/question/21981571/answer/19925418
-
- @example
+
+ @example
```js
//example
action.easing(cc.easeQuarticActionIn());
- ```
+ ```
*/
- export function easeQuarticActionIn(): any;
+ export function easeQuarticActionIn(): any;
/**
!#en
Creates the action easing object.
@@ -475,14 +475,14 @@ declare namespace cc {
创建 easeQuarticActionOut 缓动对象。
EaseQuarticOut 是按四次函数缓动退出的动作。
参考 easeOutQuart:http://www.zhihu.com/question/21981571/answer/19925418
-
- @example
+
+ @example
```js
//example
action.easing(cc.QuarticActionOut());
- ```
+ ```
*/
- export function easeQuarticActionOut(): any;
+ export function easeQuarticActionOut(): any;
/**
!#en
Creates the action easing object.
@@ -491,9 +491,9 @@ declare namespace cc {
!#zh
创建 easeQuarticActionInOut 缓动对象。
EaseQuarticInOut 是按四次函数缓动进入并退出的动作。
- 参考 easeInOutQuart:http://www.zhihu.com/question/21981571/answer/19925418
+ 参考 easeInOutQuart:http://www.zhihu.com/question/21981571/answer/19925418
*/
- export function easeQuarticActionInOut(): any;
+ export function easeQuarticActionInOut(): any;
/**
!#en
Creates the action easing object.
@@ -503,14 +503,14 @@ declare namespace cc {
创建 easeQuinticActionIn 缓动对象。
EaseQuinticIn 是按五次函数缓动进的动作。
参考 easeInQuint:http://www.zhihu.com/question/21981571/answer/19925418
-
- @example
+
+ @example
```js
//example
action.easing(cc.easeQuinticActionIn());
- ```
+ ```
*/
- export function easeQuinticActionIn(): any;
+ export function easeQuinticActionIn(): any;
/**
!#en
Creates the action easing object.
@@ -520,14 +520,14 @@ declare namespace cc {
创建 easeQuinticActionOut 缓动对象。
EaseQuinticOut 是按五次函数缓动退出的动作
参考 easeOutQuint:http://www.zhihu.com/question/21981571/answer/19925418
-
- @example
+
+ @example
```js
//example
action.easing(cc.easeQuadraticActionOut());
- ```
+ ```
*/
- export function easeQuinticActionOut(): any;
+ export function easeQuinticActionOut(): any;
/**
!#en
Creates the action easing object.
@@ -537,14 +537,14 @@ declare namespace cc {
创建 easeQuinticActionInOut 缓动对象。
EaseQuinticInOut是按五次函数缓动进入并退出的动作。
参考 easeInOutQuint:http://www.zhihu.com/question/21981571/answer/19925418
-
- @example
+
+ @example
```js
//example
action.easing(cc.easeQuinticActionInOut());
- ```
+ ```
*/
- export function easeQuinticActionInOut(): any;
+ export function easeQuinticActionInOut(): any;
/**
!#en
Creates the action easing object.
@@ -554,14 +554,14 @@ declare namespace cc {
创建 easeCircleActionIn 缓动对象。
EaseCircleIn是按圆形曲线缓动进入的动作。
参考 easeInCirc:http://www.zhihu.com/question/21981571/answer/19925418
-
- @example
+
+ @example
```js
//example
action.easing(cc.easeCircleActionIn());
- ```
+ ```
*/
- export function easeCircleActionIn(): any;
+ export function easeCircleActionIn(): any;
/**
!#en
Creates the action easing object.
@@ -571,14 +571,14 @@ declare namespace cc {
创建 easeCircleActionOut 缓动对象。
EaseCircleOut是按圆形曲线缓动退出的动作。
参考 easeOutCirc:http://www.zhihu.com/question/21981571/answer/19925418
-
- @example
+
+ @example
```js
//example
actioneasing(cc.easeCircleActionOut());
- ```
+ ```
*/
- export function easeCircleActionOut(): any;
+ export function easeCircleActionOut(): any;
/**
!#en
Creates the action easing object.
@@ -588,14 +588,14 @@ declare namespace cc {
创建 easeCircleActionInOut 缓动对象。
EaseCircleInOut 是按圆形曲线缓动进入并退出的动作。
参考 easeInOutCirc:http://www.zhihu.com/question/21981571/answer/19925418
-
- @example
+
+ @example
```js
//example
action.easing(cc.easeCircleActionInOut());
- ```
+ ```
*/
- export function easeCircleActionInOut(): any;
+ export function easeCircleActionInOut(): any;
/**
!#en
Creates the action easing object.
@@ -605,14 +605,14 @@ declare namespace cc {
创建 easeCubicActionIn 缓动对象。
EaseCubicIn 是按三次函数缓动进入的动作。
参考 easeInCubic:http://www.zhihu.com/question/21981571/answer/19925418
-
- @example
+
+ @example
```js
//example
action.easing(cc.easeCubicActionIn());
- ```
+ ```
*/
- export function easeCubicActionIn(): any;
+ export function easeCubicActionIn(): any;
/**
!#en
Creates the action easing object.
@@ -622,14 +622,14 @@ declare namespace cc {
创建 easeCubicActionOut 缓动对象。
EaseCubicOut 是按三次函数缓动退出的动作。
参考 easeOutCubic:http://www.zhihu.com/question/21981571/answer/19925418
-
- @example
+
+ @example
```js
//example
action.easing(cc.easeCubicActionOut());
- ```
+ ```
*/
- export function easeCubicActionOut(): any;
+ export function easeCubicActionOut(): any;
/**
!#en
Creates the action easing object.
@@ -638,118 +638,118 @@ declare namespace cc {
!#zh
创建 easeCubicActionInOut 缓动对象。
EaseCubicInOut是按三次函数缓动进入并退出的动作。
- 参考 easeInOutCubic:http://www.zhihu.com/question/21981571/answer/19925418
+ 参考 easeInOutCubic:http://www.zhihu.com/question/21981571/answer/19925418
*/
- export function easeCubicActionInOut(): any;
+ export function easeCubicActionInOut(): any;
/**
!#en Show the Node.
!#zh 立即显示。
-
- @example
+
+ @example
```js
// example
var showAction = cc.show();
- ```
+ ```
*/
- export function show(): ActionInstant;
+ export function show(): ActionInstant;
/**
!#en Hide the node.
!#zh 立即隐藏。
-
- @example
+
+ @example
```js
// example
var hideAction = cc.hide();
- ```
+ ```
*/
- export function hide(): ActionInstant;
+ export function hide(): ActionInstant;
/**
!#en Toggles the visibility of a node.
!#zh 显隐状态切换。
-
- @example
+
+ @example
```js
// example
var toggleVisibilityAction = cc.toggleVisibility();
- ```
+ ```
*/
- export function toggleVisibility(): ActionInstant;
+ export function toggleVisibility(): ActionInstant;
/**
!#en Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing.
!#zh 从父节点移除自身。
- @param isNeedCleanUp isNeedCleanUp
-
- @example
+ @param isNeedCleanUp isNeedCleanUp
+
+ @example
```js
// example
var removeSelfAction = cc.removeSelf();
- ```
+ ```
*/
- export function removeSelf(isNeedCleanUp ?: boolean): ActionInstant;
+ export function removeSelf(isNeedCleanUp?: boolean): ActionInstant;
/**
!#en Destroy self
!#zh 创建一个销毁自身的动作。
-
- @example
+
+ @example
```js
var destroySelfAction = cc.destroySelf();
- ```
+ ```
*/
- export function destroySelf(): ActionInstant;
+ export function destroySelf(): ActionInstant;
/**
!#en Create a FlipX action to flip or unflip the target.
!#zh X轴翻转。
@param flip Indicate whether the target should be flipped or not
-
- @example
+
+ @example
```js
var flipXAction = cc.flipX(true);
- ```
+ ```
*/
- export function flipX(flip: boolean): ActionInstant;
+ export function flipX(flip: boolean): ActionInstant;
/**
!#en Create a FlipY action to flip or unflip the target.
!#zh Y轴翻转。
@param flip flip
-
- @example
+
+ @example
```js
var flipYAction = cc.flipY(true);
- ```
+ ```
*/
- export function flipY(flip: boolean): ActionInstant;
+ export function flipY(flip: boolean): ActionInstant;
/**
!#en Creates a Place action with a position.
!#zh 放置在目标位置。
@param pos pos
@param y y
-
- @example
+
+ @example
```js
// example
var placeAction = cc.place(cc.v2(200, 200));
var placeAction = cc.place(200, 200);
- ```
+ ```
*/
- export function place(pos: Vec2|number, y?: number): ActionInstant;
+ export function place(pos: Vec2 | number, y?: number): ActionInstant;
/**
!#en Creates the action with the callback.
!#zh 执行回调函数。
@param selector selector
@param selectorTarget selectorTarget
@param data data for function, it accepts all data types.
-
- @example
+
+ @example
```js
// example
// CallFunc without data
var finish = cc.callFunc(this.removeSprite, this);
-
+
// CallFunc with data
var finish = cc.callFunc(this.removeFromParentAndCleanup, this._grossini, true);
- ```
+ ```
*/
- export function callFunc(selector: Function, selectorTarget?: any, data?: any): ActionInstant;
+ export function callFunc(selector: Function, selectorTarget?: any, data?: any): ActionInstant;
/**
!#en
Helper constructor to create an array of sequenceable actions
@@ -757,57 +757,57 @@ declare namespace cc {
!#zh 顺序执行动作,创建的动作将按顺序依次运行。
@param actionOrActionArray actionOrActionArray
@param tempArray tempArray
-
- @example
+
+ @example
```js
// example
// create sequence with actions
var seq = cc.sequence(act1, act2);
-
+
// create sequence with array
var seq = cc.sequence(actArray);
- ```
+ ```
*/
- export function sequence(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): ActionInterval;
+ export function sequence(actionOrActionArray: FiniteTimeAction | FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): ActionInterval;
/**
!#en Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30)
!#zh 重复动作,可以按一定次数重复一个动,如果想永远重复一个动作请使用 repeatForever 动作来完成。
@param action action
@param times times
-
- @example
+
+ @example
```js
// example
var rep = cc.repeat(cc.sequence(jump2, jump1), 5);
- ```
+ ```
*/
- export function repeat(action: FiniteTimeAction, times: number): ActionInterval;
+ export function repeat(action: FiniteTimeAction, times: number): ActionInterval;
/**
!#en Create a acton which repeat forever, as it runs forever, it can't be added into cc.sequence and cc.spawn.
!#zh 永远地重复一个动作,有限次数内重复一个动作请使用 repeat 动作,由于这个动作不会停止,所以不能被添加到 cc.sequence 或 cc.spawn 中。
@param action action
-
- @example
+
+ @example
```js
// example
var repeat = cc.repeatForever(cc.rotateBy(1.0, 360));
- ```
+ ```
*/
- export function repeatForever(action: FiniteTimeAction): ActionInterval;
+ export function repeatForever(action: FiniteTimeAction): ActionInterval;
/**
!#en Create a spawn action which runs several actions in parallel.
!#zh 同步执行动作,同步执行一组动作。
@param actionOrActionArray actionOrActionArray
@param tempArray tempArray
-
- @example
+
+ @example
```js
// example
var action = cc.spawn(cc.jumpBy(2, cc.v2(300, 0), 50, 4), cc.rotateBy(2, 720));
todo: It should be the direct use new
- ```
+ ```
*/
- export function spawn(actionOrActionArray: FiniteTimeAction|FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): FiniteTimeAction;
+ export function spawn(actionOrActionArray: FiniteTimeAction | FiniteTimeAction[], ...tempArray: FiniteTimeAction[]): FiniteTimeAction;
/**
!#en
Rotates a Node object to a certain angle by modifying its angle property.
@@ -815,14 +815,14 @@ declare namespace cc {
!#zh 旋转到目标角度,通过逐帧修改它的 angle 属性,旋转方向将由最短的角度决定。
@param duration duration in seconds
@param dstAngle dstAngle in degrees.
-
- @example
+
+ @example
```js
// example
var rotateTo = cc.rotateTo(2, 61.0);
- ```
+ ```
*/
- export function rotateTo(duration: number, dstAngle: number): ActionInterval;
+ export function rotateTo(duration: number, dstAngle: number): ActionInterval;
/**
!#en
Rotates a Node object clockwise a number of degrees by modifying its angle property.
@@ -830,14 +830,14 @@ declare namespace cc {
!#zh 旋转指定的角度。
@param duration duration in seconds
@param deltaAngle deltaAngle in degrees
-
- @example
+
+ @example
```js
// example
var actionBy = cc.rotateBy(2, 360);
- ```
+ ```
*/
- export function rotateBy(duration: number, deltaAngle: number): ActionInterval;
+ export function rotateBy(duration: number, deltaAngle: number): ActionInterval;
/**
!#en
Moves a Node object x,y pixels by modifying its position property.
@@ -848,14 +848,14 @@ declare namespace cc {
@param duration duration in seconds
@param deltaPos deltaPos
@param deltaY deltaY
-
- @example
+
+ @example
```js
// example
var actionTo = cc.moveBy(2, cc.v2(windowSize.width - 40, windowSize.height - 40));
- ```
+ ```
*/
- export function moveBy(duration: number, deltaPos: Vec2|number, deltaY?: number): ActionInterval;
+ export function moveBy(duration: number, deltaPos: Vec2 | number, deltaY?: number): ActionInterval;
/**
!#en
Moves a Node object to the position x,y. x and y are absolute coordinates by modifying its position property.
@@ -865,14 +865,14 @@ declare namespace cc {
@param duration duration in seconds
@param position position
@param y y
-
- @example
+
+ @example
```js
// example
var actionBy = cc.moveTo(2, cc.v2(80, 80));
- ```
+ ```
*/
- export function moveTo(duration: number, position: Vec2|number, y?: number): ActionInterval;
+ export function moveTo(duration: number, position: Vec2 | number, y?: number): ActionInterval;
/**
!#en
Create a action which skews a Node object to given angles by modifying its skewX and skewY properties.
@@ -881,14 +881,14 @@ declare namespace cc {
@param t time in seconds
@param sx sx
@param sy sy
-
- @example
+
+ @example
```js
// example
var actionTo = cc.skewTo(2, 37.2, -37.2);
- ```
+ ```
*/
- export function skewTo(t: number, sx: number, sy: number): ActionInterval;
+ export function skewTo(t: number, sx: number, sy: number): ActionInterval;
/**
!#en
Skews a Node object by skewX and skewY degrees.
@@ -897,14 +897,14 @@ declare namespace cc {
@param t time in seconds
@param sx sx skew in degrees for X axis
@param sy sy skew in degrees for Y axis
-
- @example
+
+ @example
```js
// example
var actionBy = cc.skewBy(2, 0, -90);
- ```
+ ```
*/
- export function skewBy(t: number, sx: number, sy: number): ActionInterval;
+ export function skewBy(t: number, sx: number, sy: number): ActionInterval;
/**
!#en
Moves a Node object simulating a parabolic jump movement by modifying it's position property.
@@ -915,15 +915,15 @@ declare namespace cc {
@param y y
@param height height
@param jumps jumps
-
- @example
+
+ @example
```js
// example
var actionBy = cc.jumpBy(2, cc.v2(300, 0), 50, 4);
var actionBy = cc.jumpBy(2, 300, 0, 50, 4);
- ```
+ ```
*/
- export function jumpBy(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval;
+ export function jumpBy(duration: number, position: Vec2 | number, y?: number, height?: number, jumps?: number): ActionInterval;
/**
!#en
Moves a Node object to a parabolic position simulating a jump movement by modifying its position property.
@@ -934,15 +934,15 @@ declare namespace cc {
@param y y
@param height height
@param jumps jumps
-
- @example
+
+ @example
```js
// example
var actionTo = cc.jumpTo(2, cc.v2(300, 300), 50, 4);
var actionTo = cc.jumpTo(2, 300, 300, 50, 4);
- ```
+ ```
*/
- export function jumpTo(duration: number, position: Vec2|number, y?: number, height?: number, jumps?: number): ActionInterval;
+ export function jumpTo(duration: number, position: Vec2 | number, y?: number, height?: number, jumps?: number): ActionInterval;
/**
!#en
An action that moves the target with a cubic Bezier curve by a certain distance.
@@ -950,47 +950,47 @@ declare namespace cc {
!#zh 按贝赛尔曲线轨迹移动指定的距离。
@param t time in seconds
@param c Array of points
-
- @example
+
+ @example
```js
// example
var bezier = [cc.v2(0, windowSize.height / 2), cc.v2(300, -windowSize.height / 2), cc.v2(300, 100)];
var bezierForward = cc.bezierBy(3, bezier);
- ```
+ ```
*/
- export function bezierBy(t: number, c: Vec2[]): ActionInterval;
+ export function bezierBy(t: number, c: Vec2[]): ActionInterval;
/**
!#en An action that moves the target with a cubic Bezier curve to a destination point.
!#zh 按贝赛尔曲线轨迹移动到目标位置。
@param t t
@param c Array of points
-
- @example
+
+ @example
```js
// example
var bezier = [cc.v2(0, windowSize.height / 2), cc.v2(300, -windowSize.height / 2), cc.v2(300, 100)];
var bezierTo = cc.bezierTo(2, bezier);
- ```
+ ```
*/
- export function bezierTo(t: number, c: Vec2[]): ActionInterval;
+ export function bezierTo(t: number, c: Vec2[]): ActionInterval;
/**
!#en Scales a Node object to a zoom factor by modifying it's scale property.
!#zh 将节点大小缩放到指定的倍数。
@param duration duration
@param sx scale parameter in X
@param sy scale parameter in Y, if Null equal to sx
-
- @example
+
+ @example
```js
// example
// It scales to 0.5 in both X and Y.
var actionTo = cc.scaleTo(2, 0.5);
-
+
// It scales to 0.5 in x and 2 in Y
var actionTo = cc.scaleTo(2, 0.5, 2);
- ```
+ ```
*/
- export function scaleTo(duration: number, sx: number, sy?: number): ActionInterval;
+ export function scaleTo(duration: number, sx: number, sy?: number): ActionInterval;
/**
!#en
Scales a Node object a zoom factor by modifying it's scale property.
@@ -999,30 +999,30 @@ declare namespace cc {
@param duration duration in seconds
@param sx sx scale parameter in X
@param sy sy scale parameter in Y, if Null equal to sx
-
- @example
+
+ @example
```js
// example without sy, it scales by 2 both in X and Y
var actionBy = cc.scaleBy(2, 2);
-
+
//example with sy, it scales by 0.25 in X and 4.5 in Y
var actionBy2 = cc.scaleBy(2, 0.25, 4.5);
- ```
+ ```
*/
- export function scaleBy(duration: number, sx: number, sy?: number|void): ActionInterval;
+ export function scaleBy(duration: number, sx: number, sy?: number | void): ActionInterval;
/**
!#en Blinks a Node object by modifying it's visible property.
!#zh 闪烁(基于透明度)。
@param duration duration in seconds
@param blinks blinks in times
-
- @example
+
+ @example
```js
// example
var action = cc.blink(2, 10);
- ```
+ ```
*/
- export function blink(duration: number, blinks: number): ActionInterval;
+ export function blink(duration: number, blinks: number): ActionInterval;
/**
!#en
Fades an object that implements the cc.RGBAProtocol protocol.
@@ -1030,38 +1030,38 @@ declare namespace cc {
!#zh 修改透明度到指定值。
@param duration duration
@param opacity 0-255, 0 is transparent
-
- @example
+
+ @example
```js
// example
var action = cc.fadeTo(1.0, 0);
- ```
+ ```
*/
- export function fadeTo(duration: number, opacity: number): ActionInterval;
+ export function fadeTo(duration: number, opacity: number): ActionInterval;
/**
!#en Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255.
!#zh 渐显效果。
@param duration duration in seconds
-
- @example
+
+ @example
```js
//example
var action = cc.fadeIn(1.0);
- ```
+ ```
*/
- export function fadeIn(duration: number): ActionInterval;
+ export function fadeIn(duration: number): ActionInterval;
/**
!#en Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0.
!#zh 渐隐效果。
@param d duration in seconds
-
- @example
+
+ @example
```js
// example
var action = cc.fadeOut(1.0);
- ```
+ ```
*/
- export function fadeOut(d: number): ActionInterval;
+ export function fadeOut(d: number): ActionInterval;
/**
!#en Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one.
!#zh 修改颜色到指定值。
@@ -1069,14 +1069,14 @@ declare namespace cc {
@param red 0-255
@param green 0-255
@param blue 0-255
-
- @example
+
+ @example
```js
// example
var action = cc.tintTo(2, 255, 0, 255);
- ```
+ ```
*/
- export function tintTo(duration: number, red: number, green: number, blue: number): ActionInterval;
+ export function tintTo(duration: number, red: number, green: number, blue: number): ActionInterval;
/**
!#en
Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one.
@@ -1086,53 +1086,53 @@ declare namespace cc {
@param deltaRed deltaRed
@param deltaGreen deltaGreen
@param deltaBlue deltaBlue
-
- @example
+
+ @example
```js
// example
var action = cc.tintBy(2, -127, -255, -127);
- ```
+ ```
*/
- export function tintBy(duration: number, deltaRed: number, deltaGreen: number, deltaBlue: number): ActionInterval;
+ export function tintBy(duration: number, deltaRed: number, deltaGreen: number, deltaBlue: number): ActionInterval;
/**
!#en Delays the action a certain amount of seconds.
!#zh 延迟指定的时间量。
@param d duration in seconds
-
- @example
+
+ @example
```js
// example
var delay = cc.delayTime(1);
- ```
+ ```
*/
- export function delayTime(d: number): ActionInterval;
+ export function delayTime(d: number): ActionInterval;
/**
!#en Executes an action in reverse order, from time=duration to time=0.
!#zh 反转目标动作的时间轴。
@param action action
-
- @example
+
+ @example
```js
// example
var reverse = cc.reverseTime(this);
- ```
+ ```
*/
- export function reverseTime(action: FiniteTimeAction): ActionInterval;
+ export function reverseTime(action: FiniteTimeAction): ActionInterval;
/**
!#en Create an action with the specified action and forced target.
!#zh 用已有动作和一个新的目标节点创建动作。
@param target target
- @param action action
+ @param action action
*/
- export function targetedAction(target: Node, action: FiniteTimeAction): ActionInterval;
+ export function targetedAction(target: Node, action: FiniteTimeAction): ActionInterval;
/**
-
- @param target the target to animate
+
+ @param target the target to animate
*/
- export function tween
@@ -1143,9 +1143,9 @@ declare namespace cc {
- 在 Cocos Creator 中,错误信息显示是红色的。
- 在 Chrome 中,错误信息有红色的图标以及红色的消息文本。
@param msg A JavaScript string containing zero or more substitution strings.
- @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
+ @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 error(msg: any, ...subst: any[]): void;
+ export function error(msg: any, ...subst: any[]): void;
/**
!#en
Outputs a warning message to the Cocos Creator Console (editor) or Web Console (runtime).
@@ -1156,22 +1156,22 @@ declare namespace cc {
- 在 Cocos Creator 中,警告信息显示是黄色的。
- 在 Chrome 中,警告信息有着黄色的图标以及黄色的消息文本。
@param msg A JavaScript string containing zero or more substitution strings.
- @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
+ @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 warn(msg: any, ...subst: any[]): void;
+ export function warn(msg: any, ...subst: any[]): void;
/**
!#en Outputs a message to the Cocos Creator Console (editor) or Web Console (runtime).
!#zh 输出一条消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
@param msg A JavaScript string containing zero or more substitution strings.
- @param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
+ @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;
+ export function log(msg: string | any, ...subst: any[]): void;
/** !#en Director
!#zh 导演类。 */
- export var director: Director;
+ export var director: Director;
/** !#en This is a Game instance.
!#zh 这是一个 Game 类的实例,包含游戏主体信息并负责驱动游戏的游戏对象。。 */
- export var game: Game;
+ export var game: Game;
/**
!#en
Rotates a Node object to a certain angle by modifying its quternion property.
@@ -1181,14 +1181,14 @@ declare namespace cc {
@param dstAngleX dstAngleX in degrees.
@param dstAngleY dstAngleY in degrees.
@param dstAngleZ dstAngleZ in degrees.
-
- @example
+
+ @example
```js
// example
var rotate3DTo = cc.rotate3DTo(2, cc.v3(0, 180, 0));
- ```
+ ```
*/
- export function rotate3DTo(duration: number, dstAngleX: number|Vec3|Quat, dstAngleY?: number, dstAngleZ?: number): ActionInterval;
+ export function rotate3DTo(duration: number, dstAngleX: number | Vec3 | Quat, dstAngleY?: number, dstAngleZ?: number): ActionInterval;
/**
!#en
Rotates a Node object counter clockwise a number of degrees by modifying its quaternion property.
@@ -1198,53 +1198,53 @@ declare namespace cc {
@param deltaAngleX deltaAngleX in degrees
@param deltaAngleY deltaAngleY in degrees
@param deltaAngleZ deltaAngleZ in degrees
-
- @example
+
+ @example
```js
// example
var actionBy = cc.rotate3DBy(2, cc.v3(0, 360, 0));
- ```
+ ```
*/
- export function rotate3DBy(duration: number, deltaAngleX: number|Vec3, deltaAngleY?: number, deltaAngleZ?: number): ActionInterval;
- export var assetManager: AssetManager;
+ 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;
+ export var resources: AssetManager.Bundle;
/** !#en The System event singleton for global usage
!#zh 系统事件单例,方便全局使用 */
- export var systemEvent: SystemEvent;
+ export var systemEvent: SystemEvent;
/**
Finds a node by hierarchy path, the path is case-sensitive.
It will traverse the hierarchy by splitting the path using '/' character.
This function will still returns the node even if it is inactive.
It is recommended to not use this function every frame instead cache the result at startup.
@param path path
- @param referenceNode referenceNode
+ @param referenceNode referenceNode
*/
- export function find(path: string, referenceNode?: Node): Node;
+ export function find(path: string, referenceNode?: Node): Node;
/**
!#en Defines a CCClass using the given specification, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class.html) for details.
!#zh 定义一个 CCClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅[类型定义](/docs/creator/scripting/class.html)。
@param options options
-
- @example
+
+ @example
```js
// define base class
var Node = cc.Class();
-
+
// define sub class
var Sprite = cc.Class({
name: 'Sprite',
extends: Node,
-
+
ctor: function () {
this.url = "";
this.id = 0;
},
-
+
statics: {
// define static members
count: 0,
@@ -1252,7 +1252,7 @@ declare namespace cc {
// compute bounds...
}
},
-
+
properties {
width: {
default: 128,
@@ -1266,154 +1266,154 @@ declare namespace cc {
}
}
},
-
+
load: function () {
// load this.url...
};
});
-
+
// instantiate
-
+
var obj = new Sprite();
obj.url = 'sprite.png';
obj.load();
- ```
+ ```
*/
- export function Class(options?: {name?: string; extends?: Function; ctor?: Function; __ctor__?: Function; properties?: any; statics?: any; mixins?: Function[]; editor?: {executeInEditMode?: boolean; requireComponent?: Function; menu?: string; executionOrder?: number; disallowMultiple?: boolean; playOnFocus?: boolean; inspector?: string; icon?: string; help?: string; }; update?: Function; lateUpdate?: Function; onLoad?: Function; start?: Function; onEnable?: Function; onDisable?: Function; onDestroy?: Function; onFocusInEditor?: Function; onLostFocusInEditor?: Function; resetInEditor?: Function; onRestore?: Function; _getLocalBounds?: Function; }): Function;
+ export function Class(options?: { name?: string; extends?: Function; ctor?: Function; __ctor__?: Function; properties?: any; statics?: any; mixins?: Function[]; editor?: { executeInEditMode?: boolean; requireComponent?: Function; menu?: string; executionOrder?: number; disallowMultiple?: boolean; playOnFocus?: boolean; inspector?: string; icon?: string; help?: string; }; update?: Function; lateUpdate?: Function; onLoad?: Function; start?: Function; onEnable?: Function; onDisable?: Function; onDestroy?: Function; onFocusInEditor?: Function; onLostFocusInEditor?: Function; resetInEditor?: Function; onRestore?: Function; _getLocalBounds?: Function; }): Function;
/**
!#en
Define an enum type.
If a enum item has a value of -1, it will be given an Integer number according to it's order in the list.
Otherwise it will use the value specified by user who writes the enum definition.
-
+
!#zh
定义一个枚举类型。
用户可以把枚举值设为任意的整数,如果设为 -1,系统将会分配为上一个枚举值 + 1。
@param obj a JavaScript literal object containing enum names and values, or a TypeScript enum type
-
- @example
+
+ @example
```js
// JavaScript:
-
+
var WrapMode = cc.Enum({
- Repeat: -1,
- Clamp: -1
+ Repeat: -1,
+ Clamp: -1
});
-
+
// Texture.WrapMode.Repeat == 0
// Texture.WrapMode.Clamp == 1
// Texture.WrapMode[0] == "Repeat"
// Texture.WrapMode[1] == "Clamp"
-
+
var FlagType = cc.Enum({
- Flag1: 1,
- Flag2: 2,
- Flag3: 4,
- Flag4: 8,
+ Flag1: 1,
+ Flag2: 2,
+ Flag3: 4,
+ Flag4: 8,
});
-
+
var AtlasSizeList = cc.Enum({
- 128: 128,
- 256: 256,
- 512: 512,
- 1024: 1024,
+ 128: 128,
+ 256: 256,
+ 512: 512,
+ 1024: 1024,
});
-
+
// TypeScript:
-
+
// If used in TypeScript, just define a TypeScript enum:
enum Direction {
- Up,
- Down,
- Left,
- Right
+ Up,
+ Down,
+ Left,
+ Right
}
-
+
// If you need to inspect the enum in Properties panel, you can call cc.Enum:
const {ccclass, property} = cc._decorator;
-
+
@ccclass
class NewScript extends cc.Component {
- @property({
- type: cc.Enum(Direction) // call cc.Enum
- })
- direction: Direction = Direction.Up;
+ @property({
+ type: cc.Enum(Direction) // call cc.Enum
+ })
+ direction: Direction = Direction.Up;
}
-
- ```
+
+ ```
*/
- export function Enum
@@ -1421,14 +1421,14 @@ declare namespace cc {
So `isValid` will return false from the next frame, while `isValid` in the current frame will still be true.
If you want to determine whether the current frame has called `destroy`, use `cc.isValid(obj, true)`,
but this is often caused by a particular logical requirements, which is not normally required.
-
+
!#zh
检查该对象是否不为 null 并且尚未销毁。
当一个对象的 `destroy` 调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始 `isValid` 就会返回 false,而当前帧内 `isValid` 仍然会是 true。如果希望判断当前帧是否调用过 `destroy`,请使用 `cc.isValid(obj, true)`,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。
@param value value
@param strictMode If true, Object called destroy() in this frame will also treated as invalid.
-
- @example
+
+ @example
```js
var node = new cc.Node();
cc.log(cc.isValid(node)); // true
@@ -1436,40 +1436,40 @@ declare namespace cc {
cc.log(cc.isValid(node)); // true, still valid in this frame
// after a frame...
cc.log(cc.isValid(node)); // false, destroyed in the end of last frame
- ```
+ ```
*/
- export function isValid(value: any, strictMode?: boolean): boolean;
+ export function isValid(value: any, strictMode?: boolean): boolean;
/** !#en cc.view is the shared view object.
!#zh cc.view 是全局的视图对象。 */
- export var view: View;
+ export var view: View;
/** !#en cc.winSize is the alias object for the size of the current game window.
!#zh cc.winSize 为当前的游戏窗口的大小。 */
- export var winSize: Size;
+ export var winSize: Size;
/** Specify that the input value must be integer in Inspector.
Also used to indicates that the elements in array should be type integer. */
- export var Integer: string;
+ export var Integer: string;
/** Indicates that the elements in array should be type double. */
- export var Float: string;
+ export var Float: string;
/** Indicates that the elements in array should be type boolean. */
- export var Boolean: string;
+ export var Boolean: string;
/** Indicates that the elements in array should be type string. */
- export var String: string;
+ export var String: string;
/**
!#en Deserialize json to cc.Asset
!#zh 将 JSON 反序列化为对象实例。
@param data the serialized cc.Asset json string or json object.
@param details additional loading result
- @param options options
+ @param options options
*/
- export function deserialize(data: string|any, details?: Details, options?: any): any;
+ export function deserialize(data: string | any, details?: Details, options?: any): any;
/**
!#en Clones the object `original` and returns the clone, or instantiate a node from the Prefab.
!#zh 克隆指定的任意类型的对象,或者从 Prefab 实例化出新节点。
-
+
(Instantiate 时,function 和 dom 等非可序列化对象会直接保留原有引用,Asset 会直接进行浅拷贝,可序列化类型会进行深拷贝。)
@param original An existing object that you want to make a copy of.
-
- @example
+
+ @example
```js
// instantiate node from prefab
var scene = cc.director.getScene();
@@ -1479,15 +1479,15 @@ declare namespace cc {
var scene = cc.director.getScene();
var node = cc.instantiate(targetNode);
node.parent = scene;
- ```
+ ```
*/
export function instantiate(original: Prefab): Node;
- export function instantiate
@@ -1565,216 +1565,216 @@ declare namespace cc {
注意:可以使用 cc.p 或者是 cc.v2 代替,它们将很快取代 cc.Size。
@param w width or a size object
@param h height
-
- @example
+
+ @example
```js
var size1 = cc.size();
var size2 = cc.size(100,100);
var size3 = cc.size(size2);
var size4 = cc.size({width: 100, height: 100});
-
- ```
+
+ ```
*/
- export function size(w: number|Size, h?: number): Size;
- export var EPSILON: number;
+ export function size(w: number | Size, h?: number): Size;
+ export var EPSILON: number;
/**
Clamps a value between a minimum float and maximum float value.
@param val val
@param min min
- @param max max
+ @param max max
*/
- export function clamp(val: number, min: number, max: number): number;
+ export function clamp(val: number, min: number, max: number): number;
/**
Clamps a value between 0 and 1.
- @param val val
+ @param val val
*/
- export function clamp01(val: number): number;
+ export function clamp01(val: number): number;
/**
-
+
@param from from
@param to to
- @param ratio the interpolation coefficient
+ @param ratio the interpolation coefficient
*/
- export function lerp(from: number, to: number, ratio: number): number;
- export function random(): void;
+ export function lerp(from: number, to: number, ratio: number): number;
+ export function random(): void;
/**
Returns a floating-point random number between min (inclusive) and max (exclusive).
@param min min
- @param max max
+ @param max max
*/
- export function randomRange(min: number, max: number): number;
+ export function randomRange(min: number, max: number): number;
/**
Returns a random integer between min (inclusive) and max (exclusive).
@param min min
- @param max max
+ @param max max
*/
- export function randomRangeInt(min: number, max: number): number;
+ export function randomRangeInt(min: number, max: number): number;
/**
Linear congruential generator using Hull-Dobell Theorem.
- @param seed the random seed
+ @param seed the random seed
*/
- export function pseudoRandom(seed: number): number;
+ export function pseudoRandom(seed: number): number;
/**
Returns a floating-point pseudo-random number between min (inclusive) and max (exclusive).
@param seed seed
@param min min
- @param max max
+ @param max max
*/
- export function pseudoRandomRange(seed: number, min: number, max: number): number;
+ export function pseudoRandomRange(seed: number, min: number, max: number): number;
/**
Returns a pseudo-random integer between min (inclusive) and max (exclusive).
@param seed seed
@param min min
- @param max max
+ @param max max
*/
- export function pseudoRandomRangeInt(seed: number, min: number, max: number): number;
+ export function pseudoRandomRangeInt(seed: number, min: number, max: number): number;
/**
Returns the next power of two for the value
- @param val val
+ @param val val
*/
- export function nextPow2(val: number): number;
+ export function nextPow2(val: number): number;
/**
Returns float remainder for t / length
@param t time start at 0
- @param length time of one cycle
+ @param length time of one cycle
*/
- export function repeat(t: number, length: number): number;
+ export function repeat(t: number, length: number): number;
/**
Returns time wrapped in ping-pong mode
@param t time start at 0
- @param length time of one cycle
+ @param length time of one cycle
*/
- export function repeat(t: number, length: number): number;
+ export function repeat(t: number, length: number): number;
/**
Returns ratio of a value within a given range
@param from start value
@param to end value
- @param value given value
+ @param value given value
*/
- export function repeat(from: number, to: number, value: number): number;
+ export function repeat(from: number, to: number, value: number): number;
/**
Returns -1, 0, +1 depending on sign of x.
- @param v v
+ @param v v
*/
- export function sign(v: number): void;
+ export function sign(v: number): void;
/**
!#en The convenience method to create a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}.
!#zh 通过该简便的函数进行创建 {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}} 对象。
@param x x
@param y y
-
- @example
+
+ @example
```js
var v1 = cc.v2();
var v2 = cc.v2(0, 0);
var v3 = cc.v2(v2);
var v4 = cc.v2({x: 100, y: 100});
- ```
+ ```
*/
- export function v2(x?: number|any, y?: number): Vec2;
+ export function v2(x?: number | any, y?: number): Vec2;
/**
!#en The convenience method to create a new {{#crossLink "Vec3"}}cc.Vec3{{/crossLink}}.
!#zh 通过该简便的函数进行创建 {{#crossLink "Vec3"}}cc.Vec3{{/crossLink}} 对象。
@param x x
@param y y
@param z z
-
- @example
+
+ @example
```js
var v1 = cc.v3();
var v2 = cc.v3(0, 0, 0);
var v3 = cc.v3(v2);
var v4 = cc.v3({x: 100, y: 100, z: 0});
- ```
+ ```
*/
- export function v3(x?: number|any, y?: number, z?: number): Vec3;
- export var dynamicAtlasManager: DynamicAtlasManager;
+ export function v3(x?: number | any, y?: number, z?: number): Vec3;
+ export var dynamicAtlasManager: DynamicAtlasManager;
/** !#en The matrix storage */
- export var matrix: any[];
+ export var matrix: any[];
/**
!#en Get an element
@param i i
- @param j j
+ @param j j
*/
- export function get(i: number, j: number): number;
+ export function get(i: number, j: number): number;
/**
!#en Set an element
@param i i
@param j j
- @param value value
+ @param value value
*/
- export function set(i: number, j: number, value: boolean): void;
+ export function set(i: number, j: number, value: boolean): void;
/**
- !#en Sets all elements to zero
+ !#en Sets all elements to zero
*/
- export function reset(): void;
+ export function reset(): void;
/** !#en Base class cc.Action for action classes.
!#zh Action 类是所有动作类型的基类。 */
- export class Action {
+ export class Action {
/**
!#en
to copy object with deep copy.
returns a clone of action.
- !#zh 返回一个克隆的动作。
+ !#zh 返回一个克隆的动作。
*/
- clone(): Action;
+ clone(): Action;
/**
!#en
return true if the action has finished.
- !#zh 如果动作已完成就返回 true。
+ !#zh 如果动作已完成就返回 true。
*/
- isDone(): boolean;
+ isDone(): boolean;
/**
!#en get the target.
- !#zh 获取当前目标节点。
+ !#zh 获取当前目标节点。
*/
- getTarget(): Node;
+ getTarget(): Node;
/**
!#en The action will modify the target properties.
!#zh 设置目标节点。
- @param target target
+ @param target target
*/
- setTarget(target: Node): void;
+ setTarget(target: Node): void;
/**
!#en get the original target.
- !#zh 获取原始目标节点。
+ !#zh 获取原始目标节点。
*/
- getOriginalTarget(): Node;
+ getOriginalTarget(): Node;
/**
!#en get tag number.
- !#zh 获取用于识别动作的标签。
+ !#zh 获取用于识别动作的标签。
*/
- getTag(): number;
+ getTag(): number;
/**
!#en set tag number.
!#zh 设置标签,用于识别动作。
- @param tag tag
+ @param tag tag
*/
- setTag(tag: number): void;
+ setTag(tag: number): void;
/** !#en Default Action tag.
!#zh 默认动作标签。 */
- static TAG_INVALID: number;
- }
+ static TAG_INVALID: number;
+ }
/** !#en
Base class actions that do have a finite time duration.
Possible actions:
- An action with a duration of 0 seconds.
- An action with a duration of 35.5 seconds.
-
+
Infinite time actions are valid
!#zh 有限时间动作,这种动作拥有时长 duration 属性。 */
- export class FiniteTimeAction extends Action {
+ export class FiniteTimeAction extends Action {
/**
!#en get duration of the action. (seconds).
- !#zh 获取动作以秒为单位的持续时间。
+ !#zh 获取动作以秒为单位的持续时间。
*/
- getDuration(): number;
+ getDuration(): number;
/**
!#en set duration of the action. (seconds).
!#zh 设置动作以秒为单位的持续时间。
- @param duration duration
+ @param duration duration
*/
- setDuration(duration: number): void;
+ setDuration(duration: number): void;
/**
!#en
Returns a reversed action.
@@ -1782,62 +1782,62 @@ declare namespace cc {
- The action will be x coordinates of 0 move to 100.
- The reversed action will be x of 100 move to 0.
- Will be rewritten
- !#zh 返回一个新的动作,执行与原动作完全相反的动作。
+ !#zh 返回一个新的动作,执行与原动作完全相反的动作。
*/
- reverse(): void;
+ reverse(): void;
/**
!#en
to copy object with deep copy.
returns a clone of action.
- !#zh 返回一个克隆的动作。
+ !#zh 返回一个克隆的动作。
*/
- clone(): FiniteTimeAction;
- }
+ clone(): FiniteTimeAction;
+ }
/** !#en Instant actions are immediate actions. They don't have a duration like the ActionInterval actions.
!#zh 即时动作,这种动作立即就会执行,继承自 FiniteTimeAction。 */
- export class ActionInstant extends FiniteTimeAction {
- }
+ export class ActionInstant extends FiniteTimeAction {
+ }
/** !#en
It has an start time, and a finish time. The finish time is the parameter
duration plus the start time.
- They can run normally (default)
- They can run reversed with the reverse method
- They can run with the time altered with the Accelerate, AccelDeccel and Speed actions.
then running it again in Reverse mode.
To repeat the an action for a limited number of times use the Repeat action.
- !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 Repeat 动作。
+ !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 Repeat 动作。
*/
- repeatForever(): ActionInterval;
- }
+ repeatForever(): ActionInterval;
+ }
/** !#en
cc.ActionManager is a class that can manage actions.
Normally you won't need to use this class directly. 99% of the cases you will use the CCNode interface,
@@ -1853,7 +1853,7 @@ declare namespace cc {
例如:
- 当你想要运行一个动作,但目标不是 CCNode 类型时。
- 当你想要暂停/恢复动作时。
*/
- export class ActionManager {
+ export class ActionManager {
/**
!#en
Adds an action with a target.
@@ -1867,14 +1867,14 @@ declare namespace cc {
当目标状态的 paused 为 true,动作将不会被执行
@param action action
@param target target
- @param paused paused
+ @param paused paused
*/
- addAction(action: Action, target: Node, paused: boolean): void;
+ addAction(action: Action, target: Node, paused: boolean): void;
/**
!#en Removes all actions from all the targets.
- !#zh 移除所有对象的所有动作。
+ !#zh 移除所有对象的所有动作。
*/
- removeAllActions(): void;
+ removeAllActions(): void;
/**
!#en
Removes all actions from a certain target.
@@ -1883,29 +1883,29 @@ declare namespace cc {
移除指定对象上的所有动作。
属于该目标的所有的动作将被删除。
@param target target
- @param forceDelete forceDelete
+ @param forceDelete forceDelete
*/
- removeAllActionsFromTarget(target: Node, forceDelete: boolean): void;
+ removeAllActionsFromTarget(target: Node, forceDelete: boolean): void;
/**
!#en Removes an action given an action reference.
!#zh 移除指定的动作。
- @param action action
+ @param action action
*/
- removeAction(action: Action): void;
+ removeAction(action: Action): void;
/**
!#en Removes an action given its tag and the target.
!#zh 删除指定对象下特定标签的一个动作,将删除首个匹配到的动作。
@param tag tag
- @param target target
+ @param target target
*/
- removeActionByTag(tag: number, target?: Node): void;
+ removeActionByTag(tag: number, target?: Node): void;
/**
!#en Gets an action given its tag an a target.
!#zh 通过目标对象和标签获取一个动作。
@param tag tag
- @param target target
+ @param target target
*/
- getActionByTag(tag: number, target: Node): Action;
+ getActionByTag(tag: number, target: Node): Action;
/**
!#en
Returns the numbers of actions that are running in a certain target.
@@ -1919,54 +1919,54 @@ declare namespace cc {
例如:
- 如果您正在运行 7 个动作组成的序列动作(Sequence),这个函数将返回 1。
- 如果你正在运行 2 个序列动作(Sequence)和 5 个普通动作,这个函数将返回 7。
- @param target target
+ @param target target
*/
- getNumberOfRunningActionsInTarget(target: Node): number;
+ getNumberOfRunningActionsInTarget(target: Node): number;
/**
!#en Pauses the target: all running actions and newly added actions will be paused.
!#zh 暂停指定对象:所有正在运行的动作和新添加的动作都将会暂停。
- @param target target
+ @param target target
*/
- pauseTarget(target: Node): void;
+ pauseTarget(target: Node): void;
/**
!#en Resumes the target. All queued actions will be resumed.
!#zh 让指定目标恢复运行。在执行序列中所有被暂停的动作将重新恢复运行。
- @param target target
+ @param target target
*/
- resumeTarget(target: Node): void;
+ resumeTarget(target: Node): void;
/**
!#en Pauses all running actions, returning a list of targets whose actions were paused.
- !#zh 暂停所有正在运行的动作,返回一个包含了那些动作被暂停了的目标对象的列表。
+ !#zh 暂停所有正在运行的动作,返回一个包含了那些动作被暂停了的目标对象的列表。
*/
- pauseAllRunningActions(): any[];
+ pauseAllRunningActions(): any[];
/**
!#en Resume a set of targets (convenience function to reverse a pauseAllRunningActions or pauseTargets call).
!#zh 让一组指定对象恢复运行(用来逆转 pauseAllRunningActions 效果的便捷函数)。
- @param targetsToResume targetsToResume
+ @param targetsToResume targetsToResume
*/
- resumeTargets(targetsToResume: any[]): void;
+ resumeTargets(targetsToResume: any[]): void;
/**
!#en Pause a set of targets.
!#zh 暂停一组指定对象。
- @param targetsToPause targetsToPause
+ @param targetsToPause targetsToPause
*/
- pauseTargets(targetsToPause: any[]): void;
+ pauseTargets(targetsToPause: any[]): void;
/**
!#en
purges the shared action manager. It releases the retained instance.
because it uses this, so it can not be static.
!#zh
清除共用的动作管理器。它释放了持有的实例。
- 因为它使用 this,因此它不能是静态的。
+ 因为它使用 this,因此它不能是静态的。
*/
- purgeSharedManager(): void;
+ purgeSharedManager(): void;
/**
!#en The ActionManager update。
!#zh ActionManager 主循环。
- @param dt delta time in seconds
+ @param dt delta time in seconds
*/
- update(dt: number): void;
- }
+ update(dt: number): void;
+ }
/** !#en
Tween provide a simple and flexible way to create action. Tween's api is more flexible than `cc.Action`:
- Support creating an action sequence in chained api.
@@ -1979,116 +1979,116 @@ declare namespace cc {
- 支持对任意对象的任意属性进行缓动,不再局限于节点上的属性,而 `cc.Action` 添加一个属性的支持时还需要添加一个新的 action 类型。
- 支持与 `cc.Action` 混用。
- 支持设置 {{#crossLink "Easing"}}{{/crossLink}} 或者 progress 函数。 */
- export class Tween
@@ -2207,851 +2207,851 @@ declare namespace cc {
注意:
在 Android 系统浏览器上,不同浏览器,不同版本的效果不尽相同。
比如说:大多数浏览器都需要用户物理交互才可以开始播放音效,有一些不支持 WebAudio,有一些不支持多音轨播放。总之如果对音乐依赖比较强,请做尽可能多的测试。 */
- export class audioEngine {
+ 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
+
+ @example
```js
cc.resources.load(path, cc.AudioClip, null, function (err, clip) {
- var audioID = cc.audioEngine.play(clip, false, 0.5);
+ var audioID = cc.audioEngine.play(clip, false, 0.5);
});
- ```
+ ```
*/
- static play(clip: AudioClip, loop: boolean, volume: number): number;
+ static play(clip: AudioClip, loop: boolean, volume: number): number;
/**
!#en Set audio loop.
!#zh 设置音频是否循环。
@param audioID audio id.
@param loop Whether cycle.
-
- @example
+
+ @example
```js
cc.audioEngine.setLoop(id, true);
- ```
+ ```
*/
- static setLoop(audioID: number, loop: boolean): void;
+ static setLoop(audioID: number, loop: boolean): void;
/**
!#en Get audio cycle state.
!#zh 获取音频的循环状态。
@param audioID audio id.
-
- @example
+
+ @example
```js
cc.audioEngine.isLoop(id);
- ```
+ ```
*/
- static isLoop(audioID: number): boolean;
+ 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
+
+ @example
```js
cc.audioEngine.setVolume(id, 0.5);
- ```
+ ```
*/
- static setVolume(audioID: number, volume: number): void;
+ 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
+
+ @example
```js
var volume = cc.audioEngine.getVolume(id);
- ```
+ ```
*/
- static getVolume(audioID: number): number;
+ static getVolume(audioID: number): number;
/**
!#en Set current time
!#zh 设置当前的音频时间。
@param audioID audio id.
@param sec current time.
-
- @example
+
+ @example
```js
cc.audioEngine.setCurrentTime(id, 2);
- ```
+ ```
*/
- static setCurrentTime(audioID: number, sec: number): boolean;
+ static setCurrentTime(audioID: number, sec: number): boolean;
/**
!#en Get current time
!#zh 获取当前的音频播放时间。
@param audioID audio id.
-
- @example
+
+ @example
```js
var time = cc.audioEngine.getCurrentTime(id);
- ```
+ ```
*/
- static getCurrentTime(audioID: number): number;
+ static getCurrentTime(audioID: number): number;
/**
!#en Get audio duration
!#zh 获取音频总时长。
@param audioID audio id.
-
- @example
+
+ @example
```js
var time = cc.audioEngine.getDuration(id);
- ```
+ ```
*/
- static getDuration(audioID: number): number;
+ static getDuration(audioID: number): number;
/**
!#en Get audio state
!#zh 获取音频状态。
@param audioID audio id.
-
- @example
+
+ @example
```js
var state = cc.audioEngine.getState(id);
- ```
+ ```
*/
- static getState(audioID: number): audioEngine.AudioState;
+ static getState(audioID: number): audioEngine.AudioState;
/**
!#en Set Audio finish callback
!#zh 设置一个音频结束后的回调
@param audioID audio id.
@param callback loaded callback.
-
- @example
+
+ @example
```js
cc.audioEngine.setFinishCallback(id, function () {});
- ```
+ ```
*/
- static setFinishCallback(audioID: number, callback: Function): void;
+ static setFinishCallback(audioID: number, callback: Function): void;
/**
!#en Pause playing audio.
!#zh 暂停正在播放音频。
@param audioID The return value of function play.
-
- @example
+
+ @example
```js
cc.audioEngine.pause(audioID);
- ```
+ ```
*/
- static pause(audioID: number): void;
+ static pause(audioID: number): void;
/**
!#en Pause all playing audio
!#zh 暂停现在正在播放的所有音频。
-
- @example
+
+ @example
```js
cc.audioEngine.pauseAll();
- ```
+ ```
*/
- static pauseAll(): void;
+ static pauseAll(): void;
/**
!#en Resume playing audio.
!#zh 恢复播放指定的音频。
@param audioID The return value of function play.
-
- @example
+
+ @example
```js
cc.audioEngine.resume(audioID);
- ```
+ ```
*/
- static resume(audioID: number): void;
+ static resume(audioID: number): void;
/**
!#en Resume all playing audio.
!#zh 恢复播放所有之前暂停的所有音频。
-
- @example
+
+ @example
```js
cc.audioEngine.resumeAll();
- ```
+ ```
*/
- static resumeAll(): void;
+ static resumeAll(): void;
/**
!#en Stop playing audio.
!#zh 停止播放指定音频。
@param audioID The return value of function play.
-
- @example
+
+ @example
```js
cc.audioEngine.stop(audioID);
- ```
+ ```
*/
- static stop(audioID: number): void;
+ static stop(audioID: number): void;
/**
!#en Stop all playing audio.
!#zh 停止正在播放的所有音频。
-
- @example
+
+ @example
```js
cc.audioEngine.stopAll();
- ```
+ ```
*/
- static stopAll(): void;
+ 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
+
+ @example
```js
cc.audioEngine.setMaxAudioInstance(20);
- ```
+ ```
*/
- static setMaxAudioInstance(num: number): void;
+ static setMaxAudioInstance(num: number): void;
/**
!#en Getting audio can produce several examples.
!#zh 获取一个音频可以设置几个实例
-
- @example
+
+ @example
```js
cc.audioEngine.getMaxAudioInstance();
- ```
+ ```
*/
- static getMaxAudioInstance(): number;
+ static getMaxAudioInstance(): number;
/**
!#en Unload the preloaded audio from internal buffer.
!#zh 卸载预加载的音频。
@param clip clip
-
- @example
+
+ @example
```js
cc.audioEngine.uncache(filePath);
- ```
+ ```
*/
- static uncache(clip: AudioClip): void;
+ static uncache(clip: AudioClip): void;
/**
!#en Unload all audio from internal buffer.
!#zh 卸载所有音频。
-
- @example
+
+ @example
```js
cc.audioEngine.uncacheAll();
- ```
+ ```
*/
- static uncacheAll(): void;
+ static uncacheAll(): void;
/**
!#en Play background music
!#zh 播放背景音乐
@param clip The audio clip to play.
@param loop Whether the music loop or not.
-
- @example
+
+ @example
```js
cc.resources.load(path, cc.AudioClip, null, function (err, clip) {
- var audioID = cc.audioEngine.playMusic(clip, false);
+ var audioID = cc.audioEngine.playMusic(clip, false);
});
- ```
+ ```
*/
- static playMusic(clip: AudioClip, loop: boolean): number;
+ static playMusic(clip: AudioClip, loop: boolean): number;
/**
!#en Stop background music.
!#zh 停止播放背景音乐。
-
- @example
+
+ @example
```js
cc.audioEngine.stopMusic();
- ```
+ ```
*/
- static stopMusic(): void;
+ static stopMusic(): void;
/**
!#en Pause the background music.
!#zh 暂停播放背景音乐。
-
- @example
+
+ @example
```js
cc.audioEngine.pauseMusic();
- ```
+ ```
*/
- static pauseMusic(): void;
+ static pauseMusic(): void;
/**
!#en Resume playing background music.
!#zh 恢复播放背景音乐。
-
- @example
+
+ @example
```js
cc.audioEngine.resumeMusic();
- ```
+ ```
*/
- static resumeMusic(): void;
+ static resumeMusic(): void;
/**
!#en Get the volume(0.0 ~ 1.0).
!#zh 获取音量(0.0 ~ 1.0)。
-
- @example
+
+ @example
```js
var volume = cc.audioEngine.getMusicVolume();
- ```
+ ```
*/
- static getMusicVolume(): number;
+ 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
+
+ @example
```js
cc.audioEngine.setMusicVolume(0.5);
- ```
+ ```
*/
- static setMusicVolume(volume: number): void;
+ static setMusicVolume(volume: number): void;
/**
!#en Background music playing state
!#zh 背景音乐是否正在播放
-
- @example
+
+ @example
```js
cc.audioEngine.isMusicPlaying();
- ```
+ ```
*/
- static isMusicPlaying(): boolean;
+ static isMusicPlaying(): boolean;
/**
!#en Play effect audio.
!#zh 播放音效
@param clip The audio clip to play.
@param loop Whether the music loop or not.
-
- @example
+
+ @example
```js
cc.resources.load(path, cc.AudioClip, null, function (err, clip) {
- var audioID = cc.audioEngine.playEffect(clip, false);
+ var audioID = cc.audioEngine.playEffect(clip, false);
});
- ```
+ ```
*/
- static playEffect(clip: AudioClip, loop: boolean): number;
+ 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
+
+ @example
```js
cc.audioEngine.setEffectsVolume(0.5);
- ```
+ ```
*/
- static setEffectsVolume(volume: number): void;
+ 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
+
+ @example
```js
var volume = cc.audioEngine.getEffectsVolume();
- ```
+ ```
*/
- static getEffectsVolume(): number;
+ static getEffectsVolume(): number;
/**
!#en Pause effect audio.
!#zh 暂停播放音效。
@param audioID audio id.
-
- @example
+
+ @example
```js
cc.audioEngine.pauseEffect(audioID);
- ```
+ ```
*/
- static pauseEffect(audioID: number): void;
+ static pauseEffect(audioID: number): void;
/**
!#en Stop playing all the sound effects.
!#zh 暂停播放所有音效。
-
- @example
+
+ @example
```js
cc.audioEngine.pauseAllEffects();
- ```
+ ```
*/
- static pauseAllEffects(): void;
+ static pauseAllEffects(): void;
/**
!#en Resume effect audio.
!#zh 恢复播放音效音频。
@param audioID The return value of function play.
-
- @example
+
+ @example
```js
cc.audioEngine.resumeEffect(audioID);
- ```
+ ```
*/
- static resumeEffect(audioID: number): void;
+ static resumeEffect(audioID: number): void;
/**
!#en Resume all effect audio.
!#zh 恢复播放所有之前暂停的音效。
-
- @example
+
+ @example
```js
cc.audioEngine.resumeAllEffects();
- ```
+ ```
*/
- static resumeAllEffects(): void;
+ static resumeAllEffects(): void;
/**
!#en Stop playing the effect audio.
!#zh 停止播放音效。
@param audioID audio id.
-
- @example
+
+ @example
```js
cc.audioEngine.stopEffect(id);
- ```
+ ```
*/
- static stopEffect(audioID: number): void;
+ static stopEffect(audioID: number): void;
/**
!#en Stop playing all the effects.
!#zh 停止播放所有音效。
-
- @example
+
+ @example
```js
cc.audioEngine.stopAllEffects();
- ```
+ ```
*/
- static stopAllEffects(): void;
- }
+ static stopAllEffects(): void;
+ }
/** !#en Class for animation data handling.
!#zh 动画剪辑,用于存储动画数据。 */
- export class AnimationClip extends Asset {
+ export class AnimationClip extends Asset {
/** !#en Duration of this animation.
!#zh 动画的持续时间。 */
- duration: number;
+ duration: number;
/** !#en FrameRate of this animation.
!#zh 动画的帧速率。 */
- sample: number;
+ sample: number;
/** !#en Speed of this animation.
!#zh 动画的播放速度。 */
- speed: number;
+ speed: number;
/** !#en WrapMode of this animation.
!#zh 动画的循环模式。 */
- wrapMode: WrapMode;
+ wrapMode: WrapMode;
/** !#en Curve data.
!#zh 曲线数据。 */
- curveData: any;
+ curveData: any;
/** !#en Event data.
!#zh 事件数据。 */
- events: {frame: number, func: string, params: string[]}[];
+ events: { frame: number, func: string, params: string[] }[];
/**
!#en Crate clip with a set of sprite frames
!#zh 使用一组序列帧图片来创建动画剪辑
@param spriteFrames spriteFrames
@param sample sample
-
- @example
+
+ @example
```js
var clip = cc.AnimationClip.createWithSpriteFrames(spriteFrames, 10);
- ```
+ ```
*/
- static createWithSpriteFrames(spriteFrames: SpriteFrame[], sample: number): AnimationClip;
- }
+ static createWithSpriteFrames(spriteFrames: SpriteFrame[], sample: number): AnimationClip;
+ }
/** !#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 {
+ export class Easing {
/**
!#en Easing in with quadratic formula. From slow to fast.
!#zh 平方曲线缓入函数。运动由慢到快。
- @param t The current time as a percentage of the total time.
+ @param t The current time as a percentage of the total time.
*/
- quadIn(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- quadOut(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- quadInOut(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- cubicIn(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- cubicOut(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- cubicInOut(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- quartIn(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- quartOut(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- quartInOut(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- quintIn(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- quintOut(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- quintInOut(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- sineIn(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- sineOut(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- sineInOut(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- expoIn(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- expoOut(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time, then back to slow.
*/
- expoInOut(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- circIn(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- circOut(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time, then back to slow.
*/
- circInOut(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- elasticIn(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- elasticOut(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- elasticInOut(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- backIn(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- backOut(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- backInOut(t: number): number;
+ backInOut(t: number): number;
/**
!#en Easing in action with bouncing effect.
!#zh 弹跳效果的缓入函数。
- @param t The current time as a percentage of the total time.
+ @param t The current time as a percentage of the total time.
*/
- bounceIn(t: number): number;
+ bounceIn(t: number): number;
/**
!#en Easing out action with bouncing effect.
!#zh 弹跳效果的缓出函数。
- @param t The current time as a percentage of the total time.
+ @param t The current time as a percentage of the total time.
*/
- bounceOut(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- bounceInOut(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- smooth(t: number): number;
+ 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.
+ @param t The current time as a percentage of the total time.
*/
- fade(t: number): number;
- }
+ fade(t: number): number;
+ }
/** !#en
The AnimationState gives full control over animation playback process.
In most cases the Animation Component is sufficient and easier to use. Use the AnimationState if you need full control.
!#zh
AnimationState 完全控制动画播放过程。
大多数情况下 动画组件 是足够和易于使用的。如果您需要更多的动画控制接口,请使用 AnimationState。 */
- export class AnimationState extends Playable {
+ export class AnimationState extends Playable {
/**
-
+
@param clip clip
- @param name name
+ @param name name
*/
- constructor(clip: AnimationClip, name?: string);
+ constructor(clip: AnimationClip, name?: string);
/** !#en The curves list.
!#zh 曲线列表。 */
- curves: any[];
+ 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;
+ 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;
+ repeatCount: number;
/** !#en The iteration duration of this animation in seconds. (length)
!#zh 单次动画的持续时间,秒。 */
- duration: number;
+ duration: number;
/** !#en The animation's playback speed. 1 is normal playback speed.
!#zh 播放速率。 */
- speed: number;
+ 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;
+ wrapMode: WrapMode;
/** !#en The current time of this animation in seconds.
!#zh 动画当前的时间,秒。 */
- time: number;
+ time: number;
/** !#en The clip that is being played by this animation state.
!#zh 此动画状态正在播放的剪辑。 */
- clip: AnimationClip;
+ clip: AnimationClip;
/** !#en The name of the playing animation.
!#zh 动画的名字 */
- name: string;
- }
+ name: string;
+ }
/** undefined */
- export class Playable {
+ export class Playable {
/** !#en Is playing or paused in play mode?
!#zh 当前是否正在播放。 */
- isPlaying: boolean;
+ isPlaying: boolean;
/** !#en Is currently paused? This can be true even if in edit mode(isPlaying == false).
!#zh 当前是否正在暂停 */
- isPaused: boolean;
+ isPaused: boolean;
/**
!#en Play this animation.
- !#zh 播放动画。
+ !#zh 播放动画。
*/
- play(): void;
+ play(): void;
/**
!#en Stop this animation.
- !#zh 停止动画播放。
+ !#zh 停止动画播放。
*/
- stop(): void;
+ stop(): void;
/**
!#en Pause this animation.
- !#zh 暂停动画。
+ !#zh 暂停动画。
*/
- pause(): void;
+ pause(): void;
/**
!#en Resume this animation.
- !#zh 重新播放动画。
+ !#zh 重新播放动画。
*/
- resume(): void;
+ resume(): void;
/**
!#en Perform a single frame step.
- !#zh 执行一帧动画。
+ !#zh 执行一帧动画。
*/
- step(): void;
- }
+ step(): void;
+ }
/** !#en Specifies how time is treated when it is outside of the keyframe range of an Animation.
!#zh 动画使用的循环模式。 */
- export enum WrapMode {
+ export enum WrapMode {
Default = 0,
Normal = 0,
Reverse = 0,
Loop = 0,
LoopReverse = 0,
PingPong = 0,
- PingPongReverse = 0,
- }
+ PingPongReverse = 0,
+ }
/** !#en An object to boot the game.
!#zh 包含游戏主体信息并负责驱动游戏的游戏对象。 */
- export class debug {
+ export class debug {
/**
!#en Gets error message with the error id and possible parameters.
!#zh 通过 error id 和必要的参数来获取错误信息。
@param errorId errorId
- @param param param
+ @param param param
*/
- static getError(errorId: number, param?: any): string;
+ static getError(errorId: number, param?: any): string;
/**
!#en Returns whether or not to display the FPS informations.
- !#zh 是否显示 FPS 信息。
+ !#zh 是否显示 FPS 信息。
*/
- static isDisplayStats(): boolean;
+ static isDisplayStats(): boolean;
/**
!#en Sets whether display the FPS on the bottom-left corner.
!#zh 设置是否在左下角显示 FPS。
- @param displayStats displayStats
+ @param displayStats displayStats
*/
- static setDisplayStats(displayStats: boolean): void;
- }
+ 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();
-
+ - 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)
-
+ - 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
+ - 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
+ - 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 代替 cc.Director。
+ 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 启用。
+ - GL_TEXTURE_2D 启用。
+ - GL_VERTEX_ARRAY 启用。
+ - GL_COLOR_ARRAY 启用。
+ - GL_TEXTURE_COORD_ARRAY 启用。
特点和局限性:
- - 将计时器 & 渲染与显示器的刷新频率同步。
- - 只支持动画的间隔 1/60 1/30 & 1/15。
+ - 将计时器 & 渲染与显示器的刷新频率同步。
+ - 只支持动画的间隔 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
+ @param uiPoint uiPoint
*/
- convertToGL(uiPoint: Vec2): Vec2;
+ 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
+ @param glPoint glPoint
*/
- convertToUI(glPoint: Vec2): Vec2;
+ convertToUI(glPoint: Vec2): Vec2;
/**
- End the life of director in the next frame
+ End the life of director in the next frame
*/
- end(): void;
+ 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 获取视图的大小,以点为单位。
+ !#zh 获取视图的大小,以点为单位。
*/
- getWinSize(): Size;
+ getWinSize(): Size;
/**
!#en
Returns the size of the OpenGL view in pixels.
@@ -3060,18 +3060,18 @@ declare namespace cc {
(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())
+ 如果要获取屏幕物理分辨率,需要用 cc.view.getFrameSize())
*/
- getWinSizeInPixels(): Size;
+ 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}}。
+ 如果想要更彻底得暂停游戏,包含渲染,音频和事件,请使用 {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}。
*/
- pause(): void;
+ pause(): void;
/**
!#en
Run a scene. Replaces the running scene with a new one or enter the first scene.
@@ -3079,9 +3079,9 @@ declare namespace cc {
!#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.
+ @param onLaunched The function invoked at the scene after launch.
*/
- runSceneImmediate(scene: Scene|SceneAsset, onBeforeLoadScene?: Function, onLaunched?: Function): void;
+ 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.
@@ -3089,16 +3089,16 @@ declare namespace cc {
!#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.
+ @param onLaunched The function invoked at the scene after launch.
*/
- runScene(scene: Scene|SceneAsset, onBeforeLoadScene?: Function, onLaunched?: Function): void;
+ 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.
+ @param onLaunched callback, will be called after scene launched.
*/
- loadScene(sceneName: string, onLaunched?: Function): boolean;
+ loadScene(sceneName: string, onLaunched?: Function): boolean;
/**
!#en
Preloads the scene to reduces loading time. You can call this method at any time you want.
@@ -3110,22 +3110,22 @@ declare namespace cc {
就算预加载还没完成,你也可以直接调用 `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.
+ @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;
+ 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 恢复暂停场景的游戏逻辑,如果当前场景没有暂停将没任何事情发生。
+ !#zh 恢复暂停场景的游戏逻辑,如果当前场景没有暂停将没任何事情发生。
*/
- resume(): void;
+ resume(): void;
/**
!#en
Enables or disables WebGL depth test.
Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js
!#zh 启用/禁用深度测试(在 Canvas 渲染模式下不会生效)。
- @param on on
+ @param on on
*/
- setDepthTest(on: boolean): void;
+ setDepthTest(on: boolean): void;
/**
!#en
Set color for clear screen.
@@ -3133,272 +3133,272 @@ declare namespace cc {
!#zh
设置场景的默认擦除颜色。
支持全透明,但不支持透明度为中间值。要支持全透明需手工开启 cc.macro.ENABLE_TRANSPARENT_CANVAS。
- @param clearColor clearColor
+ @param clearColor clearColor
*/
- setClearColor(clearColor: Color): void;
+ setClearColor(clearColor: Color): void;
/**
!#en Returns current logic Scene.
!#zh 获取当前逻辑场景。
-
- @example
+
+ @example
```js
// This will help you to get the Canvas node in scene
cc.director.getScene().getChildByName('Canvas');
- ```
+ ```
*/
- getScene(): Scene;
+ 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}} 来控制游戏帧率。
+ !#zh 获取单位帧执行时间。请使用 {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} 来控制游戏帧率。
*/
- getAnimationInterval(): number;
+ 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.
+ @param value The animation interval desired.
*/
- setAnimationInterval(value: number): void;
+ setAnimationInterval(value: number): void;
/**
!#en Returns the delta time since last frame.
- !#zh 获取上一帧的增量时间。
+ !#zh 获取上一帧的增量时间。
*/
- getDeltaTime(): number;
+ getDeltaTime(): number;
/**
!#en Returns the total passed time since game start, unit: ms
- !#zh 获取从游戏开始到现在总共经过的时间,单位为 ms
+ !#zh 获取从游戏开始到现在总共经过的时间,单位为 ms
*/
- getTotalTime(): number;
+ getTotalTime(): number;
/**
!#en Returns how many frames were called since the director started.
- !#zh 获取 director 启动以来游戏运行的总帧数。
+ !#zh 获取 director 启动以来游戏运行的总帧数。
*/
- getTotalFrames(): number;
+ getTotalFrames(): number;
/**
!#en Returns whether or not the Director is paused.
- !#zh 是否处于暂停状态。
+ !#zh 是否处于暂停状态。
*/
- isPaused(): boolean;
+ isPaused(): boolean;
/**
!#en Returns the cc.Scheduler associated with this director.
- !#zh 获取和 director 相关联的 cc.Scheduler。
+ !#zh 获取和 director 相关联的 cc.Scheduler。
*/
- getScheduler(): Scheduler;
+ getScheduler(): Scheduler;
/**
!#en Sets the cc.Scheduler associated with this director.
!#zh 设置和 director 相关联的 cc.Scheduler。
- @param scheduler scheduler
+ @param scheduler scheduler
*/
- setScheduler(scheduler: Scheduler): void;
+ setScheduler(scheduler: Scheduler): void;
/**
!#en Returns the cc.ActionManager associated with this director.
- !#zh 获取和 director 相关联的 cc.ActionManager(动作管理器)。
+ !#zh 获取和 director 相关联的 cc.ActionManager(动作管理器)。
*/
- getActionManager(): ActionManager;
+ getActionManager(): ActionManager;
/**
!#en Sets the cc.ActionManager associated with this director.
!#zh 设置和 director 相关联的 cc.ActionManager(动作管理器)。
- @param actionManager actionManager
+ @param actionManager actionManager
*/
- setActionManager(actionManager: ActionManager): void;
+ setActionManager(actionManager: ActionManager): void;
/**
!#en Returns the cc.CollisionManager associated with this director.
- !#zh 获取和 director 相关联的 cc.CollisionManager (碰撞管理器)。
+ !#zh 获取和 director 相关联的 cc.CollisionManager (碰撞管理器)。
*/
- getCollisionManager(): CollisionManager;
+ getCollisionManager(): CollisionManager;
/**
!#en Returns the cc.PhysicsManager associated with this director.
- !#zh 返回与 director 相关联的 cc.PhysicsManager (物理管理器)。
+ !#zh 返回与 director 相关联的 cc.PhysicsManager (物理管理器)。
*/
- getPhysicsManager(): PhysicsManager;
+ getPhysicsManager(): PhysicsManager;
/**
!#en Returns the cc.Physics3DManager associated with this director.
- !#zh 返回与 director 相关联的 cc.Physics3DManager (物理管理器)。
+ !#zh 返回与 director 相关联的 cc.Physics3DManager (物理管理器)。
*/
- getPhysics3DManager(): 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;
+ static EVENT_PROJECTION_CHANGED: string;
/** !#en The event which will be triggered before loading a new scene.
!#zh 加载新场景之前所触发的事件。 */
- static EVENT_BEFORE_SCENE_LOADING: string;
+ 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;
+ 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;
+ 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;
+ 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;
+ 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;
+ 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;
+ static EVENT_AFTER_VISIT: string;
/** !#en The event which will be triggered before the rendering process.
!#zh 渲染过程之前所触发的事件。 */
- static EVENT_BEFORE_DRAW: string;
+ static EVENT_BEFORE_DRAW: string;
/** !#en The event which will be triggered after the rendering process.
!#zh 渲染过程之后所触发的事件。 */
- static EVENT_AFTER_DRAW: string;
+ static EVENT_AFTER_DRAW: string;
/** Constant for 2D projection (orthogonal projection) */
- static PROJECTION_2D: number;
+ static PROJECTION_2D: number;
/** Constant for 3D projection with a fovy=60, znear=0.5f and zfar=1500. */
- static PROJECTION_3D: number;
+ 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;
+ static PROJECTION_CUSTOM: number;
/** Constant for default projection of cc.Director, default projection is 2D projection */
- static PROJECTION_DEFAULT: number;
- }
+ static PROJECTION_DEFAULT: number;
+ }
/** !#en An object to boot the game.
!#zh 包含游戏主体信息并负责驱动游戏的游戏对象。 */
- export class Game extends EventTarget {
+ export class Game extends EventTarget {
/** !#en Event triggered when game hide to background.
Please note that this event is not 100% guaranteed to be fired on Web platform,
on native platforms, it corresponds to enter background event, os status bar or notification center may not trigger this event.
!#zh 游戏进入后台时触发的事件。
请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。
在原生平台,它对应的是应用被切换到后台事件,下拉菜单和上拉状态栏等不一定会触发这个事件,这取决于系统行为。 */
- EVENT_HIDE: string;
+ EVENT_HIDE: string;
/** !#en Event triggered when game back to foreground
Please note that this event is not 100% guaranteed to be fired on Web platform,
on native platforms, it corresponds to enter foreground event.
!#zh 游戏进入前台运行时触发的事件。
请注意,在 WEB 平台,这个事件不一定会 100% 触发,这完全取决于浏览器的回调行为。
在原生平台,它对应的是应用被切换到前台事件。 */
- EVENT_SHOW: string;
+ EVENT_SHOW: string;
/** !#en Event triggered when game restart
!#zh 调用restart后,触发事件。 */
- EVENT_RESTART: string;
+ EVENT_RESTART: string;
/** Event triggered after game inited, at this point all engine objects and game scripts are loaded */
- EVENT_GAME_INITED: string;
+ EVENT_GAME_INITED: string;
/** Event triggered after engine inited, at this point you will be able to use all engine classes.
It was defined as EVENT_RENDERER_INITED in cocos creator v1.x and renamed in v2.0 */
- EVENT_ENGINE_INITED: string;
+ EVENT_ENGINE_INITED: string;
/** Web Canvas 2d API as renderer backend */
- RENDER_TYPE_CANVAS: number;
+ RENDER_TYPE_CANVAS: number;
/** WebGL API as renderer backend */
- RENDER_TYPE_WEBGL: number;
+ RENDER_TYPE_WEBGL: number;
/** OpenGL API as renderer backend */
- RENDER_TYPE_OPENGL: number;
+ RENDER_TYPE_OPENGL: number;
/** !#en The outer frame of the game canvas, parent of game container.
!#zh 游戏画布的外框,container 的父容器。 */
- frame: any;
+ frame: any;
/** !#en The container of game canvas.
!#zh 游戏画布的容器。 */
- container: HTMLDivElement;
+ container: HTMLDivElement;
/** !#en The canvas of the game.
!#zh 游戏的画布。 */
- canvas: HTMLCanvasElement;
+ canvas: HTMLCanvasElement;
/** !#en The renderer backend of the game.
!#zh 游戏的渲染器类型。 */
- renderType: number;
+ renderType: number;
/** !#en
The current game configuration, including:
1. debugMode
- "debugMode" possible values :
- 0 - No message will be printed.
- 1 - cc.error, cc.assert, cc.warn, cc.log will print in console.
- 2 - cc.error, cc.assert, cc.warn will print in console.
- 3 - cc.error, cc.assert will print in console.
- 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web.
- 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web.
- 6 - cc.error, cc.assert will print on canvas, available only on web.
+ "debugMode" possible values :
+ 0 - No message will be printed.
+ 1 - cc.error, cc.assert, cc.warn, cc.log will print in console.
+ 2 - cc.error, cc.assert, cc.warn will print in console.
+ 3 - cc.error, cc.assert will print in console.
+ 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web.
+ 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web.
+ 6 - cc.error, cc.assert will print on canvas, available only on web.
2. showFPS
- Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide.
+ Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide.
3. exposeClassName
- Expose class name to chrome debug tools, the class intantiate performance is a little bit slower when exposed.
+ Expose class name to chrome debug tools, the class intantiate performance is a little bit slower when exposed.
4. frameRate
- "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment.
+ "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment.
5. id
- "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web.
+ "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web.
6. renderMode
- "renderMode" sets the renderer type, only useful on web :
- 0 - Automatically chosen by engine
- 1 - Forced to use canvas renderer
- 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers
+ "renderMode" sets the renderer type, only useful on web :
+ 0 - Automatically chosen by engine
+ 1 - Forced to use canvas renderer
+ 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers
Please DO NOT modify this object directly, it won't have any effect.
!#zh
当前的游戏配置,包括:
1. debugMode(debug 模式,但是在浏览器中这个选项会被忽略)
- "debugMode" 各种设置选项的意义。
- 0 - 没有消息被打印出来。
- 1 - cc.error,cc.assert,cc.warn,cc.log 将打印在 console 中。
- 2 - cc.error,cc.assert,cc.warn 将打印在 console 中。
- 3 - cc.error,cc.assert 将打印在 console 中。
- 4 - cc.error,cc.assert,cc.warn,cc.log 将打印在 canvas 中(仅适用于 web 端)。
- 5 - cc.error,cc.assert,cc.warn 将打印在 canvas 中(仅适用于 web 端)。
- 6 - cc.error,cc.assert 将打印在 canvas 中(仅适用于 web 端)。
+ "debugMode" 各种设置选项的意义。
+ 0 - 没有消息被打印出来。
+ 1 - cc.error,cc.assert,cc.warn,cc.log 将打印在 console 中。
+ 2 - cc.error,cc.assert,cc.warn 将打印在 console 中。
+ 3 - cc.error,cc.assert 将打印在 console 中。
+ 4 - cc.error,cc.assert,cc.warn,cc.log 将打印在 canvas 中(仅适用于 web 端)。
+ 5 - cc.error,cc.assert,cc.warn 将打印在 canvas 中(仅适用于 web 端)。
+ 6 - cc.error,cc.assert 将打印在 canvas 中(仅适用于 web 端)。
2. showFPS(显示 FPS)
- 当 showFPS 为 true 的时候界面的左下角将显示 fps 的信息,否则被隐藏。
+ 当 showFPS 为 true 的时候界面的左下角将显示 fps 的信息,否则被隐藏。
3. exposeClassName
- 暴露类名让 Chrome DevTools 可以识别,如果开启会稍稍降低类的创建过程的性能,但对对象构造没有影响。
+ 暴露类名让 Chrome DevTools 可以识别,如果开启会稍稍降低类的创建过程的性能,但对对象构造没有影响。
4. frameRate (帧率)
- “frameRate” 设置想要的帧率你的游戏,但真正的FPS取决于你的游戏实现和运行环境。
+ “frameRate” 设置想要的帧率你的游戏,但真正的FPS取决于你的游戏实现和运行环境。
5. id
- "gameCanvas" Web 页面上的 Canvas Element ID,仅适用于 web 端。
+ "gameCanvas" Web 页面上的 Canvas Element ID,仅适用于 web 端。
6. renderMode(渲染模式)
- “renderMode” 设置渲染器类型,仅适用于 web 端:
- 0 - 通过引擎自动选择。
- 1 - 强制使用 canvas 渲染。
- 2 - 强制使用 WebGL 渲染,但是在部分 Android 浏览器中这个选项会被忽略。
+ “renderMode” 设置渲染器类型,仅适用于 web 端:
+ 0 - 通过引擎自动选择。
+ 1 - 强制使用 canvas 渲染。
+ 2 - 强制使用 WebGL 渲染,但是在部分 Android 浏览器中这个选项会被忽略。
注意:请不要直接修改这个对象,它不会有任何效果。 */
- config: any;
+ config: any;
/**
!#en Callback when the scripts of engine have been load.
- !#zh 当引擎完成启动后的回调函数。
+ !#zh 当引擎完成启动后的回调函数。
*/
- onStart(): void;
+ onStart(): void;
/**
!#en Set frame rate of game.
!#zh 设置游戏帧率。
- @param frameRate frameRate
+ @param frameRate frameRate
*/
- setFrameRate(frameRate: number): void;
+ setFrameRate(frameRate: number): void;
/**
!#en Get frame rate set for the game, it doesn't represent the real frame rate.
- !#zh 获取设置的游戏帧率(不等同于实际帧率)。
+ !#zh 获取设置的游戏帧率(不等同于实际帧率)。
*/
- getFrameRate(): number;
+ getFrameRate(): number;
/**
!#en Run the game frame by frame.
- !#zh 执行一帧游戏循环。
+ !#zh 执行一帧游戏循环。
*/
- step(): void;
+ step(): void;
/**
!#en Pause the game main loop. This will pause:
game logic execution, rendering process, event manager, background music and all audio effects.
This is different with cc.director.pause which only pause the game logic execution.
- !#zh 暂停游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。这点和只暂停游戏逻辑的 cc.director.pause 不同。
+ !#zh 暂停游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。这点和只暂停游戏逻辑的 cc.director.pause 不同。
*/
- pause(): void;
+ pause(): void;
/**
!#en Resume the game from pause. This will resume:
game logic execution, rendering process, event manager, background music and all audio effects.
- !#zh 恢复游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。
+ !#zh 恢复游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。
*/
- resume(): void;
+ resume(): void;
/**
!#en Check whether the game is paused.
- !#zh 判断游戏是否暂停。
+ !#zh 判断游戏是否暂停。
*/
- isPaused(): boolean;
+ isPaused(): boolean;
/**
!#en Restart game.
- !#zh 重新开始游戏
+ !#zh 重新开始游戏
*/
- restart(): void;
+ restart(): void;
/**
!#en End game, it will close the game window
- !#zh 退出游戏
+ !#zh 退出游戏
*/
- end(): void;
+ end(): void;
/**
!#en
Register an callback of a specific event type on the game object.
@@ -3407,10 +3407,10 @@ declare namespace cc {
注册 game 的特定事件类型回调。这种类型的事件应该被 `emit` 触发。
@param type A string representing the event type to listen for.
@param callback The callback that will be invoked when the event is dispatched.
- The callback is ignored if it is a duplicate (the callbacks are unique).
- @param target The target (this object) to invoke the callback, can be null
+ 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
*/
- on
@@ -3443,108 +3443,108 @@ declare namespace cc {
!#zh
声明常驻根节点,该节点不会被在场景切换中被销毁。
目标节点必须位于为层级的根节点,否则无效。
- @param node The node to be made persistent
+ @param node The node to be made persistent
*/
- addPersistRootNode(node: Node): void;
+ addPersistRootNode(node: Node): void;
/**
!#en Remove a persistent root node.
!#zh 取消常驻根节点。
- @param node The node to be removed from persistent node list
+ @param node The node to be removed from persistent node list
*/
- removePersistRootNode(node: Node): void;
+ removePersistRootNode(node: Node): void;
/**
!#en Check whether the node is a persistent root node.
!#zh 检查节点是否是常驻根节点。
- @param node The node to be checked
+ @param node The node to be checked
*/
- isPersistRootNode(node: Node): boolean;
- }
+ isPersistRootNode(node: Node): boolean;
+ }
/** !#en
Class of all entities in Cocos Creator scenes.
For events supported by Node, please refer to {{#crossLink "Node.EventType"}}{{/crossLink}}
!#zh
Cocos Creator 场景中的所有节点类。
支持的节点事件,请参阅 {{#crossLink "Node.EventType"}}{{/crossLink}}。 */
- export class Node extends _BaseNode {
+ export class Node extends _BaseNode {
/** !#en
Group index of node.
Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.
!#zh
节点的分组索引。
节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。
*/
- groupIndex: number;
+ groupIndex: number;
/** !#en
Group of node.
Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.
!#zh
节点的分组。
节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。
*/
- group: string;
+ group: string;
/** !#en The position (x, y) of the node in its parent's coordinates.
!#zh 节点在父节点坐标系中的位置(x, y)。 */
- position: Vec3;
+ position: Vec3;
/** !#en x axis position of node.
!#zh 节点 X 轴坐标。 */
- x: number;
+ x: number;
/** !#en y axis position of node.
!#zh 节点 Y 轴坐标。 */
- y: number;
+ y: number;
/** !#en z axis position of node.
!#zh 节点 Z 轴坐标。 */
- z: number;
+ z: number;
/** !#en Rotation of node.
!#zh 该节点旋转角度。 */
- rotation: number;
+ rotation: number;
/** !#en
Angle of node, the positive value is anti-clockwise direction.
!#zh
该节点的旋转角度,正值为逆时针方向。 */
- angle: number;
+ angle: number;
/** !#en The rotation as Euler angles in degrees, used in 3D node.
!#zh 该节点的欧拉角度,用于 3D 节点。 */
- eulerAngles: Vec3;
+ eulerAngles: Vec3;
/** !#en Rotation on x axis.
!#zh 该节点 X 轴旋转角度。 */
- rotationX: number;
+ rotationX: number;
/** !#en Rotation on y axis.
!#zh 该节点 Y 轴旋转角度。 */
- rotationY: number;
+ rotationY: number;
/** !#en The local scale relative to the parent.
!#zh 节点相对父节点的缩放。 */
- scale: number;
+ scale: number;
/** !#en Scale on x axis.
!#zh 节点 X 轴缩放。 */
- scaleX: number;
+ scaleX: number;
/** !#en Scale on y axis.
!#zh 节点 Y 轴缩放。 */
- scaleY: number;
+ scaleY: number;
/** !#en Scale on z axis.
!#zh 节点 Z 轴缩放。 */
- scaleZ: number;
+ scaleZ: number;
/** !#en Skew x
!#zh 该节点 X 轴倾斜角度。 */
- skewX: number;
+ skewX: number;
/** !#en Skew y
!#zh 该节点 Y 轴倾斜角度。 */
- skewY: number;
+ skewY: number;
/** !#en Opacity of node, default value is 255.
!#zh 节点透明度,默认值为 255。 */
- opacity: number;
+ opacity: number;
/** !#en Color of node, default value is white: (255, 255, 255).
!#zh 节点颜色。默认为白色,数值为:(255,255,255)。 */
- color: Color;
+ color: Color;
/** !#en Anchor point's position on x axis.
!#zh 节点 X 轴锚点位置。 */
- anchorX: number;
+ anchorX: number;
/** !#en Anchor point's position on y axis.
!#zh 节点 Y 轴锚点位置。 */
- anchorY: number;
+ anchorY: number;
/** !#en Width of node.
!#zh 节点宽度。 */
- width: number;
+ width: number;
/** !#en Height of node.
!#zh 节点高度。 */
- height: number;
+ height: number;
/** !#en zIndex is the 'key' used to sort the node relative to its siblings.
The value of zIndex should be in the range between cc.macro.MIN_ZINDEX and cc.macro.MAX_ZINDEX.
The Node's parent will sort all its children based on the zIndex value and the arrival order.
@@ -3555,26 +3555,26 @@ declare namespace cc {
zIndex 的取值应该介于 cc.macro.MIN_ZINDEX 和 cc.macro.MAX_ZINDEX 之间
父节点主要根据节点的 zIndex 和添加次序来排序,拥有更高 zIndex 的节点将被排在后面,如果两个节点的 zIndex 一致,先添加的节点会稳定排在另一个节点之前。
节点在 children 中的顺序决定了其渲染顺序。父节点永远在所有子节点之前被渲染 */
- zIndex: number;
+ zIndex: number;
/** !#en
Switch 2D/3D node. The 2D nodes will run faster.
!#zh
切换 2D/3D 节点,2D 节点会有更高的运行效率 */
- is3DNode: boolean;
+ is3DNode: boolean;
/** !#en Returns a normalized vector representing the up direction (Y axis) of the node in world space.
!#zh 获取节点正上方(y 轴)面对的方向,返回值为世界坐标系下的归一化向量 */
- up: Vec3;
+ up: Vec3;
/** !#en Returns a normalized vector representing the right direction (X axis) of the node in world space.
!#zh 获取节点正右方(x 轴)面对的方向,返回值为世界坐标系下的归一化向量 */
- right: Vec3;
+ right: Vec3;
/** !#en Returns a normalized vector representing the forward direction (Z axis) of the node in world space.
!#zh 获取节点正前方(z 轴)面对的方向,返回值为世界坐标系下的归一化向量 */
- forward: Vec3;
+ forward: Vec3;
/**
-
- @param name name
+
+ @param name name
*/
- constructor(name?: string);
+ constructor(name?: string);
/**
!#en
Register a callback of a specific event type on Node.
@@ -3603,8 +3603,8 @@ declare namespace cc {
@param callback The callback that will be invoked when the event is dispatched. The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null
@param useCapture When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase.
-
- @example
+
+ @example
```js
this.node.on(cc.Node.EventType.TOUCH_START, this.memberFunction, this); // if "this" is component and the "memberFunction" declared in CCClass.
node.on(cc.Node.EventType.TOUCH_START, callback, this);
@@ -3613,9 +3613,9 @@ declare namespace cc {
node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this);
node.on(cc.Node.EventType.ANCHOR_CHANGED, callback);
node.on(cc.Node.EventType.COLOR_CHANGED, callback);
- ```
+ ```
*/
- on
@@ -3737,80 +3737,80 @@ declare namespace cc {
调用 runAction 时,节点自身处于不激活状态将不会有任何效果。
注意:你不应该修改 runAction 后的动作,将无法发挥作用,如果想进行修改,请在定义 action 时加入。
@param action action
-
- @example
+
+ @example
```js
var action = cc.scaleTo(0.2, 1, 0.6);
node.runAction(action);
node.runAction(action).repeatForever(); // fail
node.runAction(action.repeatForever()); // right
- ```
+ ```
*/
- runAction(action: Action): Action;
+ runAction(action: Action): Action;
/**
!#en Pause all actions running on the current node. Equals to `cc.director.getActionManager().pauseTarget(node)`.
!#zh 暂停本节点上所有正在运行的动作。和 `cc.director.getActionManager().pauseTarget(node);` 等价。
-
- @example
+
+ @example
```js
node.pauseAllActions();
- ```
+ ```
*/
- pauseAllActions(): void;
+ pauseAllActions(): void;
/**
!#en Resume all paused actions on the current node. Equals to `cc.director.getActionManager().resumeTarget(node)`.
!#zh 恢复运行本节点上所有暂停的动作。和 `cc.director.getActionManager().resumeTarget(node);` 等价。
-
- @example
+
+ @example
```js
node.resumeAllActions();
- ```
+ ```
*/
- resumeAllActions(): void;
+ resumeAllActions(): void;
/**
!#en Stops and removes all actions from the running action list .
!#zh 停止并且移除所有正在运行的动作列表。
-
- @example
+
+ @example
```js
node.stopAllActions();
- ```
+ ```
*/
- stopAllActions(): void;
+ stopAllActions(): void;
/**
!#en Stops and removes an action from the running action list.
!#zh 停止并移除指定的动作。
@param action An action object to be removed.
-
- @example
+
+ @example
```js
var action = cc.scaleTo(0.2, 1, 0.6);
node.stopAction(action);
- ```
+ ```
*/
- stopAction(action: Action): void;
+ stopAction(action: Action): void;
/**
!#en Removes an action from the running action list by its tag.
!#zh 停止并且移除指定标签的动作。
@param tag A tag that indicates the action to be removed.
-
- @example
+
+ @example
```js
node.stopActionByTag(1);
- ```
+ ```
*/
- stopActionByTag(tag: number): void;
+ stopActionByTag(tag: number): void;
/**
!#en Returns an action from the running action list by its tag.
!#zh 通过标签获取指定动作。
@param tag tag
-
- @example
+
+ @example
```js
var action = node.getActionByTag(1);
- ```
+ ```
*/
- getActionByTag(tag: number): Action;
+ getActionByTag(tag: number): Action;
/**
!#en
Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).
@@ -3822,14 +3822,14 @@ declare namespace cc {
例如:
- 如果你正在运行 7 个动作中的 1 个 Sequence,它将返回 1。
- 如果你正在运行 2 个动作中的 7 个 Sequence,它将返回 7。
-
- @example
+
+ @example
```js
var count = node.getNumberOfRunningActions();
cc.log("Running Action Count: " + count);
- ```
+ ```
*/
- getNumberOfRunningActions(): number;
+ getNumberOfRunningActions(): number;
/**
!#en
Returns a copy of the position (x, y, z) of the node in its parent's coordinates.
@@ -3838,13 +3838,13 @@ declare namespace cc {
获取节点在父节点坐标系中的位置(x, y, z)。
你可以传一个 cc.Vec2 或者 cc.Vec3 作为参数来接收返回值。
@param out The return value to receive position
-
- @example
+
+ @example
```js
cc.log("Node Position: " + node.getPosition());
- ```
+ ```
*/
- getPosition(out?: Vec2|Vec3): Vec2;
+ getPosition(out?: Vec2 | Vec3): Vec2;
/**
!#en
Sets the position (x, y, z) of the node in its parent's coordinates.
@@ -3861,22 +3861,22 @@ declare namespace cc {
4. 对于 3D 节点可以传入 cc.v3(x, y, z) 类型为 cc.Vec3 的对象。
@param x X coordinate for position or the position object
@param y Y coordinate for position
- @param z Z coordinate for position
+ @param z Z coordinate for position
*/
- setPosition(x: Vec2|Vec3|number, y?: number, z?: number): void;
+ setPosition(x: Vec2 | Vec3 | number, y?: number, z?: number): void;
/**
!#en
Returns the scale factor of the node.
Need pass a cc.Vec2 or cc.Vec3 as the argument to receive the return values.
!#zh 获取节点的缩放,需要传一个 cc.Vec2 或者 cc.Vec3 作为参数来接收返回值。
@param out out
-
- @example
+
+ @example
```js
cc.log("Node Scale: " + node.getScale(cc.v3()));
- ```
+ ```
*/
- getScale(out: Vec2|Vec3): Vec2;
+ getScale(out: Vec2 | Vec3): Vec2;
/**
!#en
Sets the scale of axis in local coordinates of the node.
@@ -3891,46 +3891,46 @@ declare namespace cc {
@param x scaleX or scale object
@param y y
@param z z
-
- @example
+
+ @example
```js
node.setScale(cc.v2(2, 2)); // Notice: scaleZ will be 0
node.setScale(cc.v3(2, 2, 2)); // for 3D node
node.setScale(2);
- ```
+ ```
*/
- setScale(x: number|Vec2|Vec3, y?: number, z?: number): void;
+ setScale(x: number | Vec2 | Vec3, y?: number, z?: number): void;
/**
!#en
Get rotation of node (in quaternion).
Need pass a cc.Quat as the argument to receive the return values.
!#zh
获取该节点的 quaternion 旋转角度,需要传一个 cc.Quat 作为参数来接收返回值。
- @param out out
+ @param out out
*/
- getRotation(out: Quat): Quat;
+ getRotation(out: Quat): Quat;
/**
!#en Set rotation of node (in quaternion).
!#zh 设置该节点的 quaternion 旋转角度。
@param quat Quaternion object represents the rotation or the x value of quaternion
@param y y value of quternion
@param z z value of quternion
- @param w w value of quternion
+ @param w w value of quternion
*/
- setRotation(quat: Quat|number, y?: number, z?: number, w?: number): void;
+ setRotation(quat: Quat | number, y?: number, z?: number, w?: number): void;
/**
!#en
Returns a copy the untransformed size of the node.
The contentSize remains the same no matter the node is scaled or rotated.
All nodes has a size. Layer and Scene has the same size of the screen by default.
!#zh 获取节点自身大小,不受该节点是否被缩放或者旋转的影响。
-
- @example
+
+ @example
```js
cc.log("Content Size: " + node.getContentSize());
- ```
+ ```
*/
- getContentSize(): Size;
+ getContentSize(): Size;
/**
!#en
Sets the untransformed size of the node.
@@ -3939,14 +3939,14 @@ declare namespace cc {
!#zh 设置节点原始大小,不受该节点是否被缩放或者旋转的影响。
@param size The untransformed size of the node or The untransformed size's width of the node.
@param height The untransformed size's height of the node.
-
- @example
+
+ @example
```js
node.setContentSize(cc.size(100, 100));
node.setContentSize(100, 100);
- ```
+ ```
*/
- setContentSize(size: Size|number, height?: number): void;
+ setContentSize(size: Size | number, height?: number): void;
/**
!#en
Returns a copy of the anchor point.
@@ -3962,13 +3962,13 @@ declare namespace cc {
但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。
默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。
注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
-
- @example
+
+ @example
```js
cc.log("Node AnchorPoint: " + node.getAnchorPoint());
- ```
+ ```
*/
- getAnchorPoint(): Vec2;
+ getAnchorPoint(): Vec2;
/**
!#en
Sets the anchor point in percent.
@@ -3986,47 +3986,47 @@ declare namespace cc {
注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
@param point The anchor point of node or The x axis anchor of node.
@param y The y axis anchor of node.
-
- @example
+
+ @example
```js
node.setAnchorPoint(cc.v2(1, 1));
node.setAnchorPoint(1, 1);
- ```
+ ```
*/
- setAnchorPoint(point: Vec2|number, y?: number): void;
+ setAnchorPoint(point: Vec2 | number, y?: number): void;
/**
!#en Set rotation by lookAt target point, normally used by Camera Node
!#zh 通过观察目标来设置 rotation,一般用于 Camera Node 上
@param pos pos
- @param up default is (0,1,0)
+ @param up default is (0,1,0)
*/
- lookAt(pos: Vec3, up?: Vec3): void;
+ lookAt(pos: Vec3, up?: Vec3): void;
/**
!#en
Get the local transform matrix (4x4), based on parent node coordinates
!#zh 返回局部空间坐标系的矩阵,基于父节点坐标系。
@param out The matrix object to be filled with data
-
- @example
+
+ @example
```js
let mat4 = cc.mat4();
node.getLocalMatrix(mat4);
- ```
+ ```
*/
- getLocalMatrix(out: Mat4): Mat4;
+ getLocalMatrix(out: Mat4): Mat4;
/**
!#en
Get the world transform matrix (4x4)
!#zh 返回世界空间坐标系的矩阵。
@param out The matrix object to be filled with data
-
- @example
+
+ @example
```js
let mat4 = cc.mat4();
node.getWorldMatrix(mat4);
- ```
+ ```
*/
- getWorldMatrix(out: Mat4): Mat4;
+ getWorldMatrix(out: Mat4): Mat4;
/**
!#en
Converts a Point to node (local) space coordinates.
@@ -4034,14 +4034,14 @@ declare namespace cc {
将一个点转换到节点 (局部) 空间坐标系。
@param worldPoint worldPoint
@param out out
-
- @example
+
+ @example
```js
var newVec2 = node.convertToNodeSpaceAR(cc.v2(100, 100));
var newVec3 = node.convertToNodeSpaceAR(cc.v3(100, 100, 100));
- ```
+ ```
*/
- convertToNodeSpaceAR
这个 API 的设计是为了和 cocos2d-x 中行为一致,更多情况下你可能需要使用 convertToNodeSpaceAR。
@param worldPoint worldPoint
-
- @example
+
+ @example
```js
var newVec2 = node.convertToNodeSpace(cc.v2(100, 100));
- ```
+ ```
*/
- convertToNodeSpace(worldPoint: Vec2): Vec2;
+ convertToNodeSpace(worldPoint: Vec2): Vec2;
/**
!#en Converts a Point related to the left bottom corner of the node's bounding box to world space coordinates.
This equals to the API behavior of cocos2d-x, you probably want to use convertToWorldSpaceAR instead
!#zh 将一个相对于节点左下角的坐标位置转换到世界空间坐标系。
这个 API 的设计是为了和 cocos2d-x 中行为一致,更多情况下你可能需要使用 convertToWorldSpaceAR
@param nodePoint nodePoint
-
- @example
+
+ @example
```js
var newVec2 = node.convertToWorldSpace(cc.v2(100, 100));
- ```
+ ```
*/
- convertToWorldSpace(nodePoint: Vec2): Vec2;
+ convertToWorldSpace(nodePoint: Vec2): Vec2;
/**
!#en
Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
The matrix is in Pixels.
!#zh 返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。这个矩阵以像素为单位。
@param out The affine transform object to be filled with data
-
- @example
+
+ @example
```js
let affineTransform = cc.AffineTransform.create();
node.getNodeToParentTransform(affineTransform);
- ```
+ ```
*/
- getNodeToParentTransform(out?: AffineTransform): AffineTransform;
+ getNodeToParentTransform(out?: AffineTransform): AffineTransform;
/**
!#en
Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
@@ -4109,26 +4109,26 @@ declare namespace cc {
这个矩阵以像素为单位。
该方法基于节点坐标。
@param out The affine transform object to be filled with data
-
- @example
+
+ @example
```js
let affineTransform = cc.AffineTransform.create();
node.getNodeToParentTransformAR(affineTransform);
- ```
+ ```
*/
- getNodeToParentTransformAR(out?: AffineTransform): AffineTransform;
+ getNodeToParentTransformAR(out?: AffineTransform): AffineTransform;
/**
!#en Returns the world affine transform matrix. The matrix is in Pixels.
!#zh 返回节点到世界坐标系的仿射变换矩阵。矩阵单位是像素。
@param out The affine transform object to be filled with data
-
- @example
+
+ @example
```js
let affineTransform = cc.AffineTransform.create();
node.getNodeToWorldTransform(affineTransform);
- ```
+ ```
*/
- getNodeToWorldTransform(out?: AffineTransform): AffineTransform;
+ getNodeToWorldTransform(out?: AffineTransform): AffineTransform;
/**
!#en
Returns the world affine transform matrix. The matrix is in Pixels.
@@ -4137,14 +4137,14 @@ declare namespace cc {
返回节点到世界坐标仿射变换矩阵。矩阵单位是像素。
该方法基于节点坐标。
@param out The affine transform object to be filled with data
-
- @example
+
+ @example
```js
let affineTransform = cc.AffineTransform.create();
node.getNodeToWorldTransformAR(affineTransform);
- ```
+ ```
*/
- getNodeToWorldTransformAR(out?: AffineTransform): AffineTransform;
+ getNodeToWorldTransformAR(out?: AffineTransform): AffineTransform;
/**
!#en
Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.
@@ -4153,60 +4153,60 @@ declare namespace cc {
返回将父节点的坐标系转换成节点(局部)的空间坐标系的矩阵。
该矩阵以像素为单位。返回的矩阵是只读的,不能更改。
@param out The affine transform object to be filled with data
-
- @example
+
+ @example
```js
let affineTransform = cc.AffineTransform.create();
node.getParentToNodeTransform(affineTransform);
- ```
+ ```
*/
- getParentToNodeTransform(out?: AffineTransform): AffineTransform;
+ getParentToNodeTransform(out?: AffineTransform): AffineTransform;
/**
!#en Returns the inverse world affine transform matrix. The matrix is in Pixels.
!#en 返回世界坐标系到节点坐标系的逆矩阵。
@param out The affine transform object to be filled with data
-
- @example
+
+ @example
```js
let affineTransform = cc.AffineTransform.create();
node.getWorldToNodeTransform(affineTransform);
- ```
+ ```
*/
- getWorldToNodeTransform(out?: AffineTransform): AffineTransform;
+ getWorldToNodeTransform(out?: AffineTransform): AffineTransform;
/**
!#en convenience methods which take a cc.Touch instead of cc.Vec2.
!#zh 将触摸点转换成本地坐标系中位置。
@param touch The touch object
-
- @example
+
+ @example
```js
var newVec2 = node.convertTouchToNodeSpace(touch);
- ```
+ ```
*/
- convertTouchToNodeSpace(touch: Touch): Vec2;
+ convertTouchToNodeSpace(touch: Touch): Vec2;
/**
!#en converts a cc.Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative).
!#zh 转换一个 cc.Touch(世界坐标)到一个局部坐标,该方法基于节点坐标。
@param touch The touch object
-
- @example
+
+ @example
```js
var newVec2 = node.convertTouchToNodeSpaceAR(touch);
- ```
+ ```
*/
- convertTouchToNodeSpaceAR(touch: Touch): Vec2;
+ convertTouchToNodeSpaceAR(touch: Touch): Vec2;
/**
!#en
Returns a "local" axis aligned bounding box of the node.
The returned box is relative only to its parent.
!#zh 返回父节坐标系下的轴向对齐的包围盒。
-
- @example
+
+ @example
```js
var boundingBox = node.getBoundingBox();
- ```
+ ```
*/
- getBoundingBox(): Rect;
+ getBoundingBox(): Rect;
/**
!#en
Returns a "world" axis aligned bounding box of the node.
@@ -4214,13 +4214,13 @@ declare namespace cc {
!#zh
返回节点在世界坐标系下的对齐轴向的包围盒(AABB)。
该边框包含自身和已激活的子节点的世界边框。
-
- @example
+
+ @example
```js
var newRect = node.getBoundingBoxToWorld();
- ```
+ ```
*/
- getBoundingBoxToWorld(): Rect;
+ getBoundingBoxToWorld(): Rect;
/**
!#en
Adds a child to the node with z order and name.
@@ -4229,29 +4229,29 @@ declare namespace cc {
@param child A child node
@param zIndex Z order for drawing priority. Please refer to zIndex property
@param name A name to identify the node easily. Please refer to name property
-
- @example
+
+ @example
```js
node.addChild(newNode, 1, "node");
- ```
+ ```
*/
- addChild(child: Node, zIndex?: number, name?: string): void;
+ addChild(child: Node, zIndex?: number, name?: string): void;
/**
!#en Stops all running actions and schedulers.
!#zh 停止所有正在播放的动作和计时器。
-
- @example
+
+ @example
```js
node.cleanup();
- ```
+ ```
*/
- cleanup(): void;
+ cleanup(): void;
/**
!#en Sorts the children array depends on children's zIndex and arrivalOrder,
normally you won't need to invoke this function.
- !#zh 根据子节点的 zIndex 和 arrivalOrder 进行排序,正常情况下开发者不需要手动调用这个函数。
+ !#zh 根据子节点的 zIndex 和 arrivalOrder 进行排序,正常情况下开发者不需要手动调用这个函数。
*/
- sortAllChildren(): void;
+ sortAllChildren(): void;
/**
!#en
Returns the displayed opacity of Node,
@@ -4259,9 +4259,9 @@ declare namespace cc {
!#zh
获取节点显示透明度,
显示透明度和透明度之间的不同之处在于当启用级连透明度时,
- 显示透明度是基于自身透明度和父节点透明度计算的。
+ 显示透明度是基于自身透明度和父节点透明度计算的。
*/
- getDisplayedOpacity(): number;
+ getDisplayedOpacity(): number;
/**
!#en
Returns the displayed color of Node,
@@ -4269,46 +4269,46 @@ declare namespace cc {
!#zh
获取节点的显示颜色,
显示颜色和颜色之间的不同之处在于当启用级连颜色时,
- 显示颜色是基于自身颜色和父节点颜色计算的。
+ 显示颜色是基于自身颜色和父节点颜色计算的。
*/
- getDisplayedColor(): Color;
+ getDisplayedColor(): Color;
/** !#en Cascade opacity is removed from v2.0
Indicate whether node's opacity value affect its child nodes, default value is true.
!#zh 透明度级联功能从 v2.0 开始已移除
节点的不透明度值是否影响其子节点,默认值为 true。 */
- cascadeOpacity: boolean;
+ cascadeOpacity: boolean;
/**
!#en Cascade opacity is removed from v2.0
Returns whether node's opacity value affect its child nodes.
!#zh 透明度级联功能从 v2.0 开始已移除
- 返回节点的不透明度值是否影响其子节点。
+ 返回节点的不透明度值是否影响其子节点。
*/
- isCascadeOpacityEnabled(): boolean;
+ isCascadeOpacityEnabled(): boolean;
/**
!#en Cascade opacity is removed from v2.0
Enable or disable cascade opacity, if cascade enabled, child nodes' opacity will be the multiplication of parent opacity and its own opacity.
!#zh 透明度级联功能从 v2.0 开始已移除
启用或禁用级连不透明度,如果级连启用,子节点的不透明度将是父不透明度乘上它自己的不透明度。
- @param cascadeOpacityEnabled cascadeOpacityEnabled
+ @param cascadeOpacityEnabled cascadeOpacityEnabled
*/
- setCascadeOpacityEnabled(cascadeOpacityEnabled: boolean): void;
+ setCascadeOpacityEnabled(cascadeOpacityEnabled: boolean): void;
/**
!#en Opacity modify RGB have been removed since v2.0
Set whether color should be changed with the opacity value,
useless in ccsg.Node, but this function is override in some class to have such behavior.
!#zh 透明度影响颜色配置已经被废弃
设置更改透明度时是否修改RGB值,
- @param opacityValue opacityValue
+ @param opacityValue opacityValue
*/
- setOpacityModifyRGB(opacityValue: boolean): void;
+ setOpacityModifyRGB(opacityValue: boolean): void;
/**
!#en Opacity modify RGB have been removed since v2.0
Get whether color should be changed with the opacity value.
!#zh 透明度影响颜色配置已经被废弃
- 获取更改透明度时是否修改RGB值。
+ 获取更改透明度时是否修改RGB值。
*/
- isOpacityModifyRGB(): boolean;
- }
+ isOpacityModifyRGB(): boolean;
+ }
/** !#en
Class of private entities in Cocos Creator scenes.
The PrivateNode is hidden in editor, and completely transparent to users.
@@ -4327,31 +4327,31 @@ declare namespace cc {
1. 它有着最小的渲染排序的 Z 轴深度,并且无法被更改,因为它们不能被显示在其他正常子节点之上。
2. 它的定位也是特殊的,对于私有节点来说,父节点包围盒的左下角是它的局部坐标系原点,这个原点相当于父节点的位置减去它锚点的偏移。这样私有节点可以比较容易被控制在包围盒之中。
目前在引擎中,RichText 和 TileMap 都有可能生成私有节点。 */
- export class PrivateNode extends Node {
+ export class PrivateNode extends Node {
/**
-
- @param name name
+
+ @param name name
*/
- constructor(name?: string);
- }
+ 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 {
+ 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;
- }
+ autoReleaseAssets: boolean;
+ }
/** !#en
Scheduler is responsible of triggering the scheduled callbacks.
You should not use NSTimer. Instead use this class.
There are 2 different types of callbacks (selectors):
- - update callback: the 'update' callback will be called every frame. You can customize the priority.
- - custom callback: A custom callback will be called every frame, or with a custom interval of time
+ - update callback: the 'update' callback will be called every frame. You can customize the priority.
+ - custom callback: A custom callback will be called every frame, or with a custom interval of time
The 'custom selectors' should be avoided when possible. It is faster,
and consumes less memory to use the 'update callback'. *
@@ -4359,18 +4359,18 @@ declare namespace cc {
Scheduler 是负责触发回调函数的类。
通常情况下,建议使用 cc.director.getScheduler() 来获取系统定时器。
有两种不同类型的定时器:
- - update 定时器:每一帧都会触发。您可以自定义优先级。
- - 自定义定时器:自定义定时器可以每一帧或者自定义的时间间隔触发。
+ - update 定时器:每一帧都会触发。您可以自定义优先级。
+ - 自定义定时器:自定义定时器可以每一帧或者自定义的时间间隔触发。
如果希望每帧都触发,应该使用 update 定时器,使用 update 定时器更快,而且消耗更少的内存。 */
- export class Scheduler {
+ export class Scheduler {
/**
!#en This method should be called for any target which needs to schedule tasks, and this method should be called before any scheduler API usage.
This method will add a `_id` property if it doesn't exist.
!#zh 任何需要用 Scheduler 管理任务的对象主体都应该调用这个方法,并且应该在调用任何 Scheduler API 之前调用这个方法。
这个方法会给对象添加一个 `_id` 属性,如果这个属性不存在的话。
- @param target target
+ @param target target
*/
- enableForTarget(target: any): void;
+ enableForTarget(target: any): void;
/**
!#en
Modifies the time of all scheduled callbacks.
@@ -4384,20 +4384,20 @@ declare namespace cc {
默认是 1.0。要创建一个 “slow motion(慢动作)” 效果,使用值低于 1.0。
要使用 “fast forward(快进)” 效果,使用值大于 1.0。
注意:它影响该 Scheduler 下管理的所有定时器。
- @param timeScale timeScale
+ @param timeScale timeScale
*/
- setTimeScale(timeScale: number): void;
+ setTimeScale(timeScale: number): void;
/**
!#en Returns time scale of scheduler.
- !#zh 获取时间间隔的缩放比例。
+ !#zh 获取时间间隔的缩放比例。
*/
- getTimeScale(): number;
+ getTimeScale(): number;
/**
!#en 'update' the scheduler. (You should NEVER call this method, unless you know what you are doing.)
!#zh update 调度函数。(不应该直接调用这个方法,除非完全了解这么做的结果)
- @param dt delta time
+ @param dt delta time
*/
- update(dt: number): void;
+ update(dt: number): void;
/**
!#en
You should NEVER call this method, unless you know what you are doing.
!#zh
取消所有对象的所有定时器,包括系统定时器。
- 不要调用此函数,除非你确定你在做什么。
+ 不要调用此函数,除非你确定你在做什么。
*/
- unscheduleAll(): void;
+ unscheduleAll(): void;
/**
!#en
Unschedules all callbacks from all targets with a minimum priority.
@@ -4489,25 +4489,25 @@ declare namespace cc {
取消所有优先级的值大于指定优先级的定时器。
你应该只取消优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。
@param minPriority The minimum priority of selector to be unscheduled. Which means, all selectors which
- priority is higher than minPriority will be unscheduled.
+ priority is higher than minPriority will be unscheduled.
*/
- unscheduleAllWithMinPriority(minPriority: number): void;
+ unscheduleAllWithMinPriority(minPriority: number): void;
/**
!#en Checks whether a callback for a given target is scheduled.
!#zh 检查指定的回调函数和回调对象组合是否存在定时器。
@param callback The callback to check.
- @param target The target of the callback.
+ @param target The target of the callback.
*/
- isScheduled(callback: Function, target: any): boolean;
+ isScheduled(callback: Function, target: any): boolean;
/**
!#en
Pause all selectors from all targets.
You should NEVER call this method, unless you know what you are doing.
!#zh
暂停所有对象的所有定时器。
- 不要调用这个方法,除非你知道你正在做什么。
+ 不要调用这个方法,除非你知道你正在做什么。
*/
- pauseAllTargets(): void;
+ pauseAllTargets(): void;
/**
!#en
Pause all selectors from all targets with a minimum priority.
@@ -4515,9 +4515,9 @@ declare namespace cc {
!#zh
暂停所有优先级的值大于指定优先级的定时器。
你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。
- @param minPriority minPriority
+ @param minPriority minPriority
*/
- pauseAllTargetsWithMinPriority(minPriority: number): void;
+ pauseAllTargetsWithMinPriority(minPriority: number): void;
/**
!#en
Resume selectors on a set of targets.
@@ -4525,9 +4525,9 @@ declare namespace cc {
!#zh
恢复指定数组中所有对象的定时器。
这个函数是 pauseAllCallbacks 的逆操作。
- @param targetsToResume targetsToResume
+ @param targetsToResume targetsToResume
*/
- resumeTargets(targetsToResume: any[]): void;
+ resumeTargets(targetsToResume: any[]): void;
/**
!#en
Pauses the target.
@@ -4537,9 +4537,9 @@ declare namespace cc {
暂停指定对象的定时器。
指定对象的所有定时器都会被暂停。
如果指定的对象没有定时器,什么也不会发生。
- @param target target
+ @param target target
*/
- pauseTarget(target: any): void;
+ pauseTarget(target: any): void;
/**
!#en
Resumes the target.
@@ -4549,85 +4549,85 @@ declare namespace cc {
恢复指定对象的所有定时器。
指定对象的所有定时器将继续工作。
如果指定的对象没有定时器,什么也不会发生。
- @param target target
+ @param target target
*/
- resumeTarget(target: any): void;
+ resumeTarget(target: any): void;
/**
!#en Returns whether or not the target is paused.
!#zh 返回指定对象的定时器是否暂停了。
- @param target target
+ @param target target
*/
- isTargetPaused(target: any): boolean;
+ isTargetPaused(target: any): boolean;
/** !#en Priority level reserved for system services.
!#zh 系统服务的优先级。 */
- static PRIORITY_SYSTEM: number;
+ static PRIORITY_SYSTEM: number;
/** !#en Minimum priority level for user scheduling.
!#zh 用户调度最低优先级。 */
- static PRIORITY_NON_SYSTEM: number;
- }
+ static PRIORITY_NON_SYSTEM: number;
+ }
/** !#en cc.VideoPlayer is a component for playing videos, you can use it for showing videos in your game. Because different platforms have different authorization, API and control methods for VideoPlayer component. And have not yet formed a unified standard, only Web, iOS, and Android platforms are currently supported.
!#zh Video 组件,用于在游戏中播放视频。由于不同平台对于 VideoPlayer 组件的授权、API、控制方式都不同,还没有形成统一的标准,所以目前只支持 Web、iOS 和 Android 平台。 */
- export class VideoPlayer extends Component {
+ 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;
+ resourceType: VideoPlayer.ResourceType;
/** !#en The remote URL of video.
!#zh 远程视频的 URL */
- remoteURL: string;
+ remoteURL: string;
/** !#en The local video full path.
!#zh 本地视频的 URL */
- clip: string;
+ 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;
+ currentTime: number;
/** !#en The volume of the video.
!#zh 视频的音量(0.0 ~ 1.0) */
- volume: number;
+ volume: number;
/** !#en Mutes the VideoPlayer. Mute sets the volume=0, Un-Mute restore the original volume.
!#zh 是否静音视频。静音时设置音量为 0,取消静音是恢复原来的音量。 */
- mute: boolean;
+ mute: boolean;
/** !#en Whether keep the aspect ration of the original video.
!#zh 是否保持视频原来的宽高比 */
- keepAspectRatio: boolean;
+ keepAspectRatio: boolean;
/** !#en Whether play video in fullscreen mode.
!#zh 是否全屏播放视频 */
- isFullscreen: boolean;
+ 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;
+ 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[];
+ 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 如果视频被暂停播放了,调用这个接口可以继续播放。如果视频被停止播放了,调用这个接口可以从头开始播放。
+ !#zh 如果视频被暂停播放了,调用这个接口可以继续播放。如果视频被停止播放了,调用这个接口可以从头开始播放。
*/
- play(): void;
+ play(): void;
/**
!#en If a video is paused, call this method to resume playing.
- !#zh 如果一个视频播放被暂停播放了,调用这个接口可以继续播放。
+ !#zh 如果一个视频播放被暂停播放了,调用这个接口可以继续播放。
*/
- resume(): void;
+ resume(): void;
/**
!#en If a video is playing, call this method to pause playing.
- !#zh 如果一个视频正在播放,调用这个接口可以暂停播放。
+ !#zh 如果一个视频正在播放,调用这个接口可以暂停播放。
*/
- pause(): void;
+ pause(): void;
/**
!#en If a video is playing, call this method to stop playing immediately.
- !#zh 如果一个视频正在播放,调用这个接口可以立马停止播放。
+ !#zh 如果一个视频正在播放,调用这个接口可以立马停止播放。
*/
- stop(): void;
+ stop(): void;
/**
!#en Gets the duration of the video
- !#zh 获取视频文件的播放总时长
+ !#zh 获取视频文件的播放总时长
*/
- getDuration(): number;
+ getDuration(): number;
/**
!#en Determine whether video is playing or not.
- !#zh 判断当前视频是否处于播放状态
+ !#zh 判断当前视频是否处于播放状态
*/
- isPlaying(): boolean;
+ 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.
@@ -4635,19 +4635,19 @@ declare namespace cc {
!#zh
如果你不再使用 VideoPlayer,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
-
- @example
+
+ @example
```js
videoplayer.node.parent = null; // or videoplayer.node.removeFromParent(false);
// when you don't need videoplayer anymore
videoplayer.node.destroy();
- ```
+ ```
*/
- destroy(): boolean;
- }
+ destroy(): boolean;
+ }
/** Class for particle asset handling. */
- export class ParticleAsset extends Asset {
- }
+ export class ParticleAsset extends Asset {
+ }
/** Particle System base class.
Attributes of a Particle System:
- emmision rate of the particles
@@ -4682,226 +4682,226 @@ declare namespace cc {
- 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 {
+ export class ParticleSystem extends RenderComponent implements BlendFunc {
/** !#en Play particle in edit mode.
!#zh 在编辑器模式下预览粒子,启用后选中粒子时,粒子将自动播放。 */
- preview: boolean;
+ preview: boolean;
/** !#en
If set custom to true, then use custom properties insteadof read particle file.
!#zh 是否自定义粒子属性。 */
- custom: boolean;
+ custom: boolean;
/** !#en The plist file.
!#zh plist 格式的粒子配置文件。 */
- file: ParticleAsset;
+ file: ParticleAsset;
/** !#en SpriteFrame used for particles display
!#zh 用于粒子呈现的 SpriteFrame */
- spriteFrame: SpriteFrame;
+ spriteFrame: SpriteFrame;
/** !#en Texture of Particle System, readonly, please use spriteFrame to setup new texture。
!#zh 粒子贴图,只读属性,请使用 spriteFrame 属性来替换贴图。 */
- texture: string;
+ texture: string;
/** !#en Current quantity of particles that are being simulated.
!#zh 当前播放的粒子数量。 */
- particleCount: number;
+ particleCount: number;
/** !#en Indicate whether the system simulation have stopped.
!#zh 指示粒子播放是否完毕。 */
- stopped: boolean;
+ stopped: boolean;
/** !#en If set to true, the particle system will automatically start playing on onLoad.
!#zh 如果设置为 true 运行时会自动发射粒子。 */
- playOnLoad: boolean;
+ playOnLoad: boolean;
/** !#en Indicate whether the owner node will be auto-removed when it has no particles left.
!#zh 粒子播放完毕后自动销毁所在的节点。 */
- autoRemoveOnFinish: boolean;
+ autoRemoveOnFinish: boolean;
/** !#en Indicate whether the particle system is activated.
!#zh 是否激活粒子。 */
- active: boolean;
+ active: boolean;
/** !#en Maximum particles of the system.
!#zh 粒子最大数量。 */
- totalParticles: number;
+ totalParticles: number;
/** !#en How many seconds the emitter wil run. -1 means 'forever'.
!#zh 发射器生存时间,单位秒,-1表示持续发射。 */
- duration: number;
+ duration: number;
/** !#en Emission rate of the particles.
!#zh 每秒发射的粒子数目。 */
- emissionRate: number;
+ emissionRate: number;
/** !#en Life of each particle setter.
!#zh 粒子的运行时间。 */
- life: number;
+ life: number;
/** !#en Variation of life.
!#zh 粒子的运行时间变化范围。 */
- lifeVar: number;
+ lifeVar: number;
/** !#en Start color of each particle.
!#zh 粒子初始颜色。 */
- startColor: Color;
+ startColor: Color;
/** !#en Variation of the start color.
!#zh 粒子初始颜色变化范围。 */
- startColorVar: Color;
+ startColorVar: Color;
/** !#en Ending color of each particle.
!#zh 粒子结束颜色。 */
- endColor: Color;
+ endColor: Color;
/** !#en Variation of the end color.
!#zh 粒子结束颜色变化范围。 */
- endColorVar: Color;
+ endColorVar: Color;
/** !#en Angle of each particle setter.
!#zh 粒子角度。 */
- angle: number;
+ angle: number;
/** !#en Variation of angle of each particle setter.
!#zh 粒子角度变化范围。 */
- angleVar: number;
+ angleVar: number;
/** !#en Start size in pixels of each particle.
!#zh 粒子的初始大小。 */
- startSize: number;
+ startSize: number;
/** !#en Variation of start size in pixels.
!#zh 粒子初始大小的变化范围。 */
- startSizeVar: number;
+ startSizeVar: number;
/** !#en End size in pixels of each particle.
!#zh 粒子结束时的大小。 */
- endSize: number;
+ endSize: number;
/** !#en Variation of end size in pixels.
!#zh 粒子结束大小的变化范围。 */
- endSizeVar: number;
+ endSizeVar: number;
/** !#en Start angle of each particle.
!#zh 粒子开始自旋角度。 */
- startSpin: number;
+ startSpin: number;
/** !#en Variation of start angle.
!#zh 粒子开始自旋角度变化范围。 */
- startSpinVar: number;
+ startSpinVar: number;
/** !#en End angle of each particle.
!#zh 粒子结束自旋角度。 */
- endSpin: number;
+ endSpin: number;
/** !#en Variation of end angle.
!#zh 粒子结束自旋角度变化范围。 */
- endSpinVar: number;
+ endSpinVar: number;
/** !#en Source position of the emitter.
!#zh 发射器位置。 */
- sourcePos: Vec2;
+ sourcePos: Vec2;
/** !#en Variation of source position.
!#zh 发射器位置的变化范围。(横向和纵向) */
- posVar: Vec2;
+ posVar: Vec2;
/** !#en Particles movement type.
!#zh 粒子位置类型。 */
- positionType: ParticleSystem.PositionType;
+ positionType: ParticleSystem.PositionType;
/** !#en Particles emitter modes.
!#zh 发射器类型。 */
- emitterMode: ParticleSystem.EmitterMode;
+ emitterMode: ParticleSystem.EmitterMode;
/** !#en Gravity of the emitter.
!#zh 重力。 */
- gravity: Vec2;
+ gravity: Vec2;
/** !#en Speed of the emitter.
!#zh 速度。 */
- speed: number;
+ speed: number;
/** !#en Variation of the speed.
!#zh 速度变化范围。 */
- speedVar: number;
+ speedVar: number;
/** !#en Tangential acceleration of each particle. Only available in 'Gravity' mode.
!#zh 每个粒子的切向加速度,即垂直于重力方向的加速度,只有在重力模式下可用。 */
- tangentialAccel: number;
+ tangentialAccel: number;
/** !#en Variation of the tangential acceleration.
!#zh 每个粒子的切向加速度变化范围。 */
- tangentialAccelVar: number;
+ tangentialAccelVar: number;
/** !#en Acceleration of each particle. Only available in 'Gravity' mode.
!#zh 粒子径向加速度,即平行于重力方向的加速度,只有在重力模式下可用。 */
- radialAccel: number;
+ radialAccel: number;
/** !#en Variation of the radial acceleration.
!#zh 粒子径向加速度变化范围。 */
- radialAccelVar: number;
+ radialAccelVar: number;
/** !#en Indicate whether the rotation of each particle equals to its direction. Only available in 'Gravity' mode.
!#zh 每个粒子的旋转是否等于其方向,只有在重力模式下可用。 */
- rotationIsDir: boolean;
+ rotationIsDir: boolean;
/** !#en Starting radius of the particles. Only available in 'Radius' mode.
!#zh 初始半径,表示粒子出生时相对发射器的距离,只有在半径模式下可用。 */
- startRadius: number;
+ startRadius: number;
/** !#en Variation of the starting radius.
!#zh 初始半径变化范围。 */
- startRadiusVar: number;
+ startRadiusVar: number;
/** !#en Ending radius of the particles. Only available in 'Radius' mode.
!#zh 结束半径,只有在半径模式下可用。 */
- endRadius: number;
+ endRadius: number;
/** !#en Variation of the ending radius.
!#zh 结束半径变化范围。 */
- endRadiusVar: number;
+ endRadiusVar: number;
/** !#en Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode.
!#zh 粒子每秒围绕起始点的旋转角度,只有在半径模式下可用。 */
- rotatePerS: number;
+ rotatePerS: number;
/** !#en Variation of the degress to rotate a particle around the source pos per second.
!#zh 粒子每秒围绕起始点的旋转角度变化范围。 */
- rotatePerSVar: number;
+ rotatePerSVar: number;
/** !#en The Particle emitter lives forever.
!#zh 表示发射器永久存在 */
- static DURATION_INFINITY: number;
+ 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;
+ 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;
+ static START_RADIUS_EQUAL_TO_END_RADIUS: number;
/**
!#en Stop emitting particles. Running particles will continue to run until they die.
!#zh 停止发射器发射粒子,发射出去的粒子将继续运行,直至粒子生命结束。
-
- @example
+
+ @example
```js
// stop particle system.
myParticleSystem.stopSystem();
- ```
+ ```
*/
- stopSystem(): void;
+ stopSystem(): void;
/**
!#en Kill all living particles.
!#zh 杀死所有存在的粒子,然后重新启动粒子发射器。
-
- @example
+
+ @example
```js
// play particle system.
myParticleSystem.resetSystem();
- ```
+ ```
*/
- resetSystem(): void;
+ resetSystem(): void;
/**
!#en Whether or not the system is full.
- !#zh 发射器中粒子是否大于等于设置的总粒子数量。
+ !#zh 发射器中粒子是否大于等于设置的总粒子数量。
*/
- isFull(): boolean;
+ 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
+ @param rect rect
*/
- setTextureWithRect(texture: Texture2D, rect: Rect): void;
+ setTextureWithRect(texture: Texture2D, rect: Rect): void;
/** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost.
!#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */
- srcBlendFactor: macro.BlendFactor;
+ srcBlendFactor: macro.BlendFactor;
/** !#en specify the destination Blend Factor.
!#zh 指定目标的混合模式 */
- dstBlendFactor: macro.BlendFactor;
- }
+ dstBlendFactor: macro.BlendFactor;
+ }
/** cc.TMXLayerInfo contains the information about the layers like:
- Layer name
- Layer size
- Layer opacity at creation time (it can be modified at runtime)
- Whether the layer is visible (if it's not visible, then the CocosNode won't be created)
This information is obtained from the TMX file. */
- export class TMXLayerInfo {
+ export class TMXLayerInfo {
/** Properties of the layer info. */
- properties: any;
- }
+ properties: any;
+ }
/** cc.TMXImageLayerInfo contains the information about the image layers.
This information is obtained from the TMX file. */
- export class TMXImageLayerInfo {
- }
+ export class TMXImageLayerInfo {
+ }
/**
- Tileset name
- Tileset spacing
@@ -4909,137 +4909,137 @@ declare namespace cc {
- 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)
@@ -5069,20 +5069,20 @@ declare namespace cc {
@param posOrX position or x
@param flagsOrY flags or y
@param flags flags
-
- @example
+
+ @example
```js
tiledLayer.setTileGIDAt(1001, 10, 10, 1)
- ```
+ ```
*/
- setTileGIDAt(gid: number, posOrX: Vec2|number, flagsOrY: number, flags?: number): void;
+ setTileGIDAt(gid: number, posOrX: Vec2 | number, flagsOrY: number, flags?: number): void;
/**
!#en
Returns the tiles data.An array fill with GIDs.
!#zh
- 返回 tiles 数据. 由GID构成的一个数组.
+ 返回 tiles 数据. 由GID构成的一个数组.
*/
- getTiles(): number[];
+ getTiles(): number[];
/**
!#en
Returns the tile gid at a given tile coordinate.
@@ -5092,35 +5092,35 @@ declare namespace cc {
如果它返回 0,则表示该 tile 为空。
@param pos or x
@param y y
-
- @example
+
+ @example
```js
let tileGid = tiledLayer.getTileGIDAt(0, 0);
- ```
+ ```
*/
- getTileGIDAt(pos: Vec2|number, y?: number): number;
+ getTileGIDAt(pos: Vec2 | number, y?: number): number;
/**
!#en Layer orientation, which is the same as the map orientation.
!#zh 获取 Layer 方向(同地图方向)。
-
- @example
+
+ @example
```js
let orientation = tiledLayer.getLayerOrientation();
cc.log("Layer Orientation: " + orientation);
- ```
+ ```
*/
- getLayerOrientation(): number;
+ getLayerOrientation(): number;
/**
!#en properties from the layer. They can be added using Tiled.
!#zh 获取 layer 的属性,可以使用 Tiled 编辑器添加属性。
-
- @example
+
+ @example
```js
let properties = tiledLayer.getProperties();
cc.log("Properties: " + properties);
- ```
+ ```
*/
- getProperties(): any;
+ getProperties(): any;
/**
!#en
Get the TiledTile with the tile coordinate.
@@ -5134,14 +5134,14 @@ declare namespace cc {
@param x x
@param y y
@param forceCreate forceCreate
-
- @example
+
+ @example
```js
let tile = tiledLayer.getTiledTileAt(100, 100, true);
cc.log(tile);
- ```
+ ```
*/
- getTiledTileAt(x: number, y: number, forceCreate: boolean): TiledTile;
+ getTiledTileAt(x: number, y: number, forceCreate: boolean): TiledTile;
/**
!#en
Change tile to TiledTile at the specified coordinate.
@@ -5149,301 +5149,301 @@ declare namespace cc {
将指定的 tile 坐标替换为指定的 TiledTile。
@param x x
@param y y
- @param tiledTile tiledTile
+ @param tiledTile tiledTile
*/
- setTiledTileAt(x: number, y: number, tiledTile: TiledTile): TiledTile;
+ setTiledTileAt(x: number, y: number, tiledTile: TiledTile): TiledTile;
/**
!#en Return texture.
!#zh 获取纹理。
- @param index The index of textures
+ @param index The index of textures
*/
- getTexture(index: any): Texture2D;
+ getTexture(index: any): Texture2D;
/**
!#en Return texture.
- !#zh 获取纹理。
+ !#zh 获取纹理。
*/
- getTextures(): Texture2D;
+ getTextures(): Texture2D;
/**
!#en Set the texture.
!#zh 设置纹理。
- @param texture texture
+ @param texture texture
*/
- setTexture(texture: Texture2D): void;
+ setTexture(texture: Texture2D): void;
/**
!#en Set the texture.
!#zh 设置纹理。
- @param textures textures
+ @param textures textures
*/
- setTexture(textures: Texture2D): void;
+ setTexture(textures: Texture2D): void;
/**
!#en Gets layer size.
!#zh 获得层大小。
-
- @example
+
+ @example
```js
let size = tiledLayer.getLayerSize();
cc.log("layer size: " + size);
- ```
+ ```
*/
- getLayerSize(): Size;
+ getLayerSize(): Size;
/**
!#en Size of the map's tile (could be different from the tile's size).
!#zh 获取 tile 的大小( tile 的大小可能会有所不同)。
-
- @example
+
+ @example
```js
let mapTileSize = tiledLayer.getMapTileSize();
cc.log("MapTile size: " + mapTileSize);
- ```
+ ```
*/
- getMapTileSize(): Size;
+ getMapTileSize(): Size;
/**
!#en Gets Tile set first information for the layer.
!#zh 获取 layer 索引位置为0的 Tileset 信息。
- @param index The index of tilesets
+ @param index The index of tilesets
*/
- getTileSet(index: any): TMXTilesetInfo;
+ getTileSet(index: any): TMXTilesetInfo;
/**
!#en Gets tile set all information for the layer.
- !#zh 获取 layer 所有的 Tileset 信息。
+ !#zh 获取 layer 所有的 Tileset 信息。
*/
- getTileSet(): TMXTilesetInfo;
+ getTileSet(): TMXTilesetInfo;
/**
!#en Sets tile set information for the layer.
!#zh 设置 layer 的 tileset 信息。
- @param tileset tileset
+ @param tileset tileset
*/
- setTileSet(tileset: TMXTilesetInfo): void;
+ setTileSet(tileset: TMXTilesetInfo): void;
/**
!#en Sets Tile set information for the layer.
!#zh 设置 layer 的 Tileset 信息。
- @param tilesets tilesets
+ @param tilesets tilesets
*/
- setTileSets(tilesets: TMXTilesetInfo): void;
- }
+ setTileSets(tilesets: TMXTilesetInfo): void;
+ }
/** !#en Renders a TMX Tile Map in the scene.
!#zh 在场景中渲染一个 tmx 格式的 Tile Map。 */
- export class TiledMap extends Component {
+ export class TiledMap extends Component {
/** !#en The TiledMap Asset.
!#zh TiledMap 资源。 */
- tmxAsset: TiledMapAsset;
+ tmxAsset: TiledMapAsset;
/**
!#en Gets the map size.
!#zh 获取地图大小。
-
- @example
+
+ @example
```js
let mapSize = tiledMap.getMapSize();
cc.log("Map Size: " + mapSize);
- ```
+ ```
*/
- getMapSize(): Size;
+ getMapSize(): Size;
/**
!#en Gets the tile size.
!#zh 获取地图背景中 tile 元素的大小。
-
- @example
+
+ @example
```js
let tileSize = tiledMap.getTileSize();
cc.log("Tile Size: " + tileSize);
- ```
+ ```
*/
- getTileSize(): Size;
+ getTileSize(): Size;
/**
!#en map orientation.
!#zh 获取地图方向。
-
- @example
+
+ @example
```js
let mapOrientation = tiledMap.getMapOrientation();
cc.log("Map Orientation: " + mapOrientation);
- ```
+ ```
*/
- getMapOrientation(): number;
+ getMapOrientation(): number;
/**
!#en object groups.
!#zh 获取所有的对象层。
-
- @example
+
+ @example
```js
let objGroups = titledMap.getObjectGroups();
for (let i = 0; i < objGroups.length; ++i) {
- cc.log("obj: " + objGroups[i]);
+ cc.log("obj: " + objGroups[i]);
}
- ```
+ ```
*/
- getObjectGroups(): TiledObjectGroup[];
+ getObjectGroups(): TiledObjectGroup[];
/**
!#en Return the TMXObjectGroup for the specific group.
!#zh 获取指定的 TMXObjectGroup。
@param groupName groupName
-
- @example
+
+ @example
```js
let group = titledMap.getObjectGroup("Players");
cc.log("ObjectGroup: " + group);
- ```
+ ```
*/
- getObjectGroup(groupName: string): TiledObjectGroup;
+ getObjectGroup(groupName: string): TiledObjectGroup;
/**
!#en enable or disable culling
!#zh 开启或关闭裁剪。
- @param value value
+ @param value value
*/
- enableCulling(value: any): void;
+ enableCulling(value: any): void;
/**
!#en Gets the map properties.
!#zh 获取地图的属性。
-
- @example
+
+ @example
```js
let properties = titledMap.getProperties();
for (let i = 0; i < properties.length; ++i) {
- cc.log("Properties: " + properties[i]);
+ cc.log("Properties: " + properties[i]);
}
- ```
+ ```
*/
- getProperties(): any[];
+ getProperties(): any[];
/**
!#en Return All layers array.
!#zh 返回包含所有 layer 的数组。
-
- @example
+
+ @example
```js
let layers = titledMap.getLayers();
for (let i = 0; i < layers.length; ++i) {
- cc.log("Layers: " + layers[i]);
+ cc.log("Layers: " + layers[i]);
}
- ```
+ ```
*/
- getLayers(): TiledLayer[];
+ getLayers(): TiledLayer[];
/**
!#en return the cc.TiledLayer for the specific layer.
!#zh 获取指定名称的 layer。
@param layerName layerName
-
- @example
+
+ @example
```js
let layer = titledMap.getLayer("Player");
cc.log(layer);
- ```
+ ```
*/
- getLayer(layerName: string): TiledLayer;
+ getLayer(layerName: string): TiledLayer;
/**
!#en Return the value for the specific property name.
!#zh 通过属性名称,获取指定的属性。
@param propertyName propertyName
-
- @example
+
+ @example
```js
let property = titledMap.getProperty("info");
cc.log("Property: " + property);
- ```
+ ```
*/
- getProperty(propertyName: string): string;
+ getProperty(propertyName: string): string;
/**
!#en Return properties dictionary for tile GID.
!#zh 通过 GID ,获取指定的属性。
@param GID GID
-
- @example
+
+ @example
```js
let properties = titledMap.getPropertiesForGID(GID);
cc.log("Properties: " + properties);
- ```
+ ```
*/
- getPropertiesForGID(GID: number): any;
- }
+ getPropertiesForGID(GID: number): any;
+ }
/** Class for tiled map asset handling. */
- export class TiledMapAsset extends Asset {
- textures: Texture2D[];
- textureNames: string[];
- textureSizes: Size[];
- imageLayerTextures: Texture2D[];
- imageLayerTextureNames: string[];
- }
+ export class TiledMapAsset extends Asset {
+ textures: Texture2D[];
+ textureNames: string[];
+ textureSizes: Size[];
+ imageLayerTextures: Texture2D[];
+ imageLayerTextureNames: string[];
+ }
/** !#en Renders the TMX object group.
!#zh 渲染 tmx object group。 */
- export class TiledObjectGroup extends Component {
+ export class TiledObjectGroup extends Component {
/**
!#en Offset position of child objects.
!#zh 获取子对象的偏移位置。
-
- @example
+
+ @example
```js
let offset = tMXObjectGroup.getPositionOffset();
- ```
+ ```
*/
- getPositionOffset(): Vec2;
+ getPositionOffset(): Vec2;
/**
!#en List of properties stored in a dictionary.
!#zh 以映射的形式获取属性列表。
-
- @example
+
+ @example
```js
let offset = tMXObjectGroup.getProperties();
- ```
+ ```
*/
- getProperties(): any;
+ getProperties(): any;
/**
!#en Gets the Group name.
!#zh 获取组名称。
-
- @example
+
+ @example
```js
let groupName = tMXObjectGroup.getGroupName;
- ```
+ ```
*/
- getGroupName(): string;
+ getGroupName(): string;
/**
!#en
Return the object for the specific object name.
It will return the 1st object found on the array for the given name.
!#zh 获取指定的对象。
@param objectName objectName
-
- @example
+
+ @example
```js
let object = tMXObjectGroup.getObject("Group");
- ```
+ ```
*/
- getObject(objectName: string): any;
+ getObject(objectName: string): any;
/**
!#en Gets the objects.
!#zh 获取对象数组。
-
- @example
+
+ @example
```js
let objects = tMXObjectGroup.getObjects();
- ```
+ ```
*/
- getObjects(): any[];
- }
+ getObjects(): any[];
+ }
/** !#en TiledTile can control the specified map tile.
It will apply the node rotation, scale, translate to the map tile.
You can change the TiledTile's gid to change the map tile's style.
!#zh TiledTile 可以单独对某一个地图块进行操作。
他会将节点的旋转,缩放,平移操作应用在这个地图块上,并可以通过更换当前地图块的 gid 来更换地图块的显示样式。 */
- export class TiledTile extends Component {
+ export class TiledTile extends Component {
/** !#en Specify the TiledTile horizontal coordinate,use map tile as the unit.
!#zh 指定 TiledTile 的横向坐标,以地图块为单位 */
- x: number;
+ x: number;
/** !#en Specify the TiledTile vertical coordinate,use map tile as the unit.
!#zh 指定 TiledTile 的纵向坐标,以地图块为单位 */
- y: number;
+ y: number;
/** !#en Specify the TiledTile gid.
!#zh 指定 TiledTile 的 gid 值 */
- gid: number;
- }
+ gid: number;
+ }
/** !#en cc.WebView is a component for display web pages in the game. Because different platforms have different authorization, API and control methods for WebView component. And have not yet formed a unified standard, only Web, iOS, and Android platforms are currently supported.
!#zh WebView 组件,用于在游戏中显示网页。由于不同平台对于 WebView 组件的授权、API、控制方式都不同,还没有形成统一的标准,所以目前只支持 Web、iOS 和 Android 平台。 */
- export class WebView extends Component {
+ 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;
+ url: string;
/** !#en The webview's event callback , it will be triggered when certain webview event occurs.
!#zh WebView 的回调事件,当网页加载过程中,加载完成后或者加载出错时都会回调此函数 */
- webviewLoadedEvents: Component.EventHandler[];
+ webviewLoadedEvents: Component.EventHandler[];
/**
!#en
Set javascript interface scheme (see also setOnJSCallback).
@@ -5453,9 +5453,9 @@ declare namespace cc {
设置 JavaScript 接口方案(与 'setOnJSCallback' 配套使用)。
注意:只支持 Android 和 iOS ,Web 端用法请前往官方文档查看。
详情请参阅官方文档
- @param scheme scheme
+ @param scheme scheme
*/
- setJavascriptInterfaceScheme(scheme: string): void;
+ setJavascriptInterfaceScheme(scheme: string): void;
/**
!#en
This callback called when load URL that start with javascript
@@ -5466,9 +5466,9 @@ declare namespace cc {
当加载 URL 以 JavaScript 接口方案开始时调用这个回调函数。
注意:只支持 Android 和 iOS,Web 端用法请前往官方文档查看。
详情请参阅官方文档
- @param callback callback
+ @param callback callback
*/
- setOnJSCallback(callback: Function): void;
+ setOnJSCallback(callback: Function): void;
/**
!#en
Evaluates JavaScript in the context of the currently displayed page.
@@ -5477,9 +5477,9 @@ declare namespace cc {
!#zh
执行 WebView 内部页面脚本(详情请参阅官方文档)
注意:需要自行解决跨域问题
- @param str str
+ @param str str
*/
- evaluateJS(str: string): void;
+ 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.
@@ -5487,49 +5487,49 @@ declare namespace cc {
!#zh
如果你不再使用 WebView,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
-
- @example
+
+ @example
```js
webview.node.parent = null; // or webview.node.removeFromParent(false);
// when you don't need webview anymore
webview.node.destroy();
- ```
+ ```
*/
- destroy(): boolean;
- }
+ destroy(): boolean;
+ }
/** !#en
cc.NodePool is the cache pool designed for node type.
It can helps you to improve your game performance for objects which need frequent release and recreate operations
-
+
It's recommended to create cc.NodePool instances by node type, the type corresponds to node type in game design, not the class,
for example, a prefab is a specific node type.
When you create a node pool, you can pass a Component which contains `unuse`, `reuse` functions to control the content of node.
-
+
Some common use case is :
- 1. Bullets in game (die very soon, massive creation and recreation, no side effect on other objects)
- 2. Blocks in candy crash (massive creation and recreation)
- etc...
+ 1. Bullets in game (die very soon, massive creation and recreation, no side effect on other objects)
+ 2. Blocks in candy crash (massive creation and recreation)
+ etc...
!#zh
cc.NodePool 是用于管理节点对象的对象缓存池。
它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁
以前 cocos2d-x 中的 cc.pool 和新的节点事件注册系统不兼容,因此请使用 cc.NodePool 来代替。
-
+
新的 NodePool 需要实例化之后才能使用,每种不同的节点对象池需要一个不同的对象池实例,这里的种类对应于游戏中的节点设计,一个 prefab 相当于一个种类的节点。
在创建缓冲池时,可以传入一个包含 unuse, reuse 函数的组件类型用于节点的回收和复用逻辑。
-
+
一些常见的用例是:
- 1.在游戏中的子弹(死亡很快,频繁创建,对其他对象无副作用)
- 2.糖果粉碎传奇中的木块(频繁创建)。
- 等等.... */
- export class NodePool {
+ 1.在游戏中的子弹(死亡很快,频繁创建,对其他对象无副作用)
+ 2.糖果粉碎传奇中的木块(频繁创建)。
+ 等等.... */
+ export class NodePool {
/**
!#en
Constructor for creating a pool for a specific node template (usually a prefab). You can pass a component (type or name) argument for handling event for reusing and recycling node.
!#zh
使用构造函数来创建一个节点专用的对象池,您可以传递一个组件类型或名称,用于处理节点回收和复用时的事件逻辑。
@param poolHandlerComp !#en The constructor or the class name of the component to control the unuse/reuse logic. !#zh 处理节点回收和复用事件逻辑的组件类型或名称。
-
- @example
+
+ @example
```js
properties: {
template: cc.Prefab
@@ -5538,22 +5538,22 @@ declare namespace cc {
// MyTemplateHandler is a component with 'unuse' and 'reuse' to handle events when node is reused or recycled.
this.myPool = new cc.NodePool('MyTemplateHandler');
}
- ```
+ ```
*/
- constructor(poolHandlerComp?: {prototype: Component}|string);
+ constructor(poolHandlerComp?: { prototype: Component } | string);
/** !#en The pool handler component, it could be the class name or the constructor.
!#zh 缓冲池处理组件,用于节点的回收和复用逻辑,这个属性可以是组件类名或组件的构造函数。 */
- poolHandlerComp: Function|string;
+ poolHandlerComp: Function | string;
/**
!#en The current available size in the pool
- !#zh 获取当前缓冲池的可用对象数量
+ !#zh 获取当前缓冲池的可用对象数量
*/
- size(): number;
+ size(): number;
/**
!#en Destroy all cached nodes in the pool
- !#zh 销毁对象池中缓存的所有节点
+ !#zh 销毁对象池中缓存的所有节点
*/
- clear(): void;
+ clear(): void;
/**
!#en Put a new Node into the pool.
It will automatically remove the node from its parent without cleanup.
@@ -5562,379 +5562,379 @@ declare namespace cc {
这个函数会自动将目标节点从父节点上移除,但是不会进行 cleanup 操作。
这个函数会调用 poolHandlerComp 的 unuse 函数,如果组件和函数都存在的话。
@param obj obj
-
- @example
+
+ @example
```js
let myNode = cc.instantiate(this.template);
this.myPool.put(myNode);
- ```
+ ```
*/
- put(obj: Node): void;
+ put(obj: Node): void;
/**
!#en Get a obj from pool, if no available object in pool, null will be returned.
This function will invoke the reuse function of poolHandlerComp if exist.
!#zh 获取对象池中的对象,如果对象池没有可用对象,则返回空。
这个函数会调用 poolHandlerComp 的 reuse 函数,如果组件和函数都存在的话。
@param params !#en Params to pass to 'reuse' method in poolHandlerComp !#zh 向 poolHandlerComp 中的 'reuse' 函数传递的参数
-
- @example
+
+ @example
```js
let newNode = this.myPool.get();
- ```
+ ```
*/
- get(...params: any[]): Node;
- }
+ get(...params: any[]): Node;
+ }
/** !#en
Camera is usefull when making reel game or other games which need scroll screen.
Using camera will be more efficient than moving node to scroll screen.
Camera
!#zh
摄像机在制作卷轴或是其他需要移动屏幕的游戏时比较有用,使用摄像机将会比移动节点来移动屏幕更加高效。 */
- export class Camera extends Component {
+ export class Camera extends Component {
/** !#en
The camera zoom ratio, only support 2D camera.
!#zh
摄像机缩放比率, 只支持 2D camera。 */
- zoomRatio: number;
+ 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;
+ fov: number;
/** !#en
The viewport size of the Camera when set to orthographic projection.
!#zh
摄像机在正交投影模式下的视窗大小。 */
- orthoSize: number;
+ orthoSize: number;
/** !#en
The near clipping plane.
!#zh
摄像机的近剪裁面。 */
- nearClip: number;
+ nearClip: number;
/** !#en
The far clipping plane.
!#zh
摄像机的远剪裁面。 */
- farClip: number;
+ farClip: number;
/** !#en
Is the camera orthographic (true) or perspective (false)?
!#zh
设置摄像机的投影模式是正交还是透视模式。 */
- ortho: boolean;
+ ortho: boolean;
/** !#en
Four values (0 ~ 1) that indicate where on the screen this camera view will be drawn.
!#zh
决定摄像机绘制在屏幕上哪个位置,值为(0 ~ 1)。 */
- rect: Rect;
+ rect: Rect;
/** !#en
This is used to render parts of the scene selectively.
!#zh
决定摄像机会渲染场景的哪一部分。 */
- cullingMask: number;
+ cullingMask: number;
/** !#en
Determining what to clear when camera rendering.
!#zh
决定摄像机渲染时会清除哪些状态。 */
- clearFlags: Camera.ClearFlags;
+ clearFlags: Camera.ClearFlags;
/** !#en
The color with which the screen will be cleared.
!#zh
摄像机用于清除屏幕的背景色。 */
- backgroundColor: Color;
+ 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;
+ 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;
+ targetTexture: RenderTexture;
/** !#en
Sets the camera's render stages.
!#zh
设置摄像机渲染的阶段 */
- renderStages: number;
+ renderStages: number;
/** !#en Whether auto align camera viewport to screen
!#zh 是否自动将摄像机的视口对准屏幕 */
- alignWithScreen: boolean;
+ 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;
+ static main: Camera;
/** !#en
All enabled cameras.
!#zh
当前激活的所有摄像机。 */
- static cameras: Camera[];
+ static cameras: Camera[];
/**
!#en
Get the first camera which the node belong to.
!#zh
获取节点所在的第一个摄像机。
- @param node node
+ @param node node
*/
- static findCamera(node: Node): Camera;
+ 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
+ @param out the matrix to receive the result
*/
- getScreenToWorldMatrix2D(out: Mat4): Mat4;
+ 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
+ @param out the matrix to receive the result
*/
- getWorldToScreenMatrix2D(out: Mat4): Mat4;
+ getWorldToScreenMatrix2D(out: Mat4): Mat4;
/**
!#en
Convert point from screen to world.
!#zh
将坐标从屏幕坐标系转换到世界坐标系。
@param screenPosition screenPosition
- @param out out
+ @param out out
*/
- getScreenToWorldPoint(screenPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3;
+ getScreenToWorldPoint(screenPosition: Vec3 | Vec2, out?: Vec3 | Vec2): Vec3;
/**
!#en
Convert point from world to screen.
!#zh
将坐标从世界坐标系转化到屏幕坐标系。
@param worldPosition worldPosition
- @param out out
+ @param out out
*/
- getWorldToScreenPoint(worldPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3;
+ getWorldToScreenPoint(worldPosition: Vec3 | Vec2, out?: Vec3 | Vec2): Vec3;
/**
!#en
Get a ray from screen position
!#zh
从屏幕坐标获取一条射线
- @param screenPos screenPos
+ @param screenPos screenPos
*/
- getRay(screenPos: Vec2): geomUtils.Ray;
+ getRay(screenPos: Vec2): geomUtils.Ray;
/**
!#en
Check whether the node is in the camera.
!#zh
检测节点是否被此摄像机影响
- @param node the node which need to check
+ @param node the node which need to check
*/
- containsNode(node: Node): boolean;
+ containsNode(node: Node): boolean;
/**
!#en
Render the camera manually.
!#zh
手动渲染摄像机。
- @param rootNode rootNode
+ @param rootNode rootNode
*/
- render(rootNode?: Node): void;
+ 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
+ @param node the node which should transform
*/
- getNodeToCameraTransform(node: Node): AffineTransform;
+ 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
+ @param out the point to receive the result
*/
- getCameraToWorldPoint(point: Vec2, out?: Vec2): Vec2;
+ 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
+ @param out the point to receive the result
*/
- getWorldToCameraPoint(point: Vec2, out?: Vec2): Vec2;
+ getWorldToCameraPoint(point: Vec2, out?: Vec2): Vec2;
/**
!#en
Get the camera to world matrix
!#zh
获取摄像机坐标系到世界坐标系的矩阵
- @param out the matrix to receive the result
+ @param out the matrix to receive the result
*/
- getCameraToWorldMatrix(out: Mat4): Mat4;
+ getCameraToWorldMatrix(out: Mat4): Mat4;
/**
!#en
Get the world to camera matrix
!#zh
获取世界坐标系到摄像机坐标系的矩阵
- @param out the matrix to receive the result
+ @param out the matrix to receive the result
*/
- getWorldToCameraMatrix(out: Mat4): Mat4;
- }
+ getWorldToCameraMatrix(out: Mat4): Mat4;
+ }
/** !#en The Light Component
-
+
!#zh 光源组件 */
- export class Light extends Component {
- }
+ export class Light extends Component {
+ }
/** !#en
This module controls asset's behaviors and information, include loading, releasing etc. it is a singleton
All member can be accessed with `cc.assetManager`.
-
+
!#zh
此模块管理资源的行为和信息,包括加载,释放等,这是一个单例,所有成员能够通过 `cc.assetManager` 调用 */
- export class AssetManager {
+ export class AssetManager {
/** !#en
Normal loading pipeline
-
+
!#zh
正常加载管线 */
- pipeline: cc.AssetManager.Pipeline;
+ pipeline: cc.AssetManager.Pipeline;
/** !#en
Fetching pipeline
-
+
!#zh
下载管线 */
- fetchPipeline: cc.AssetManager.Pipeline;
+ fetchPipeline: cc.AssetManager.Pipeline;
/** !#en
Url transformer
-
+
!#zh
Url 转换器 */
- transformPipeline: cc.AssetManager.Pipeline;
+ transformPipeline: cc.AssetManager.Pipeline;
/** !#en
The collection of bundle which is already loaded, you can remove cache with {{#crossLink "AssetManager/removeBundle:method"}}{{/crossLink}}
-
+
!#zh
已加载 bundle 的集合, 你能通过 {{#crossLink "AssetManager/removeBundle:method"}}{{/crossLink}} 来移除缓存 */
- bundles: AssetManager.Cache
-
+
You may want to override:
- createNode
- getset functions of _nativeAsset
@@ -6278,52 +6278,52 @@ declare namespace cc {
- cc.Object._deserialize
!#zh
Creator 中的资源基类。
-
+
您可能需要重写:
- createNode
- _nativeAsset 的 getset 方法
- cc.Object._serialize
- cc.Object._deserialize
*/
- export class Asset extends Object {
+ export class Asset extends Object {
/** `cc.Asset.url` is deprecated, please use {{#crossLink "Asset/nativeUrl:property"}}{{/crossLink}} instead */
- url: string;
+ url: string;
/** !#en
Whether the asset is loaded or not.
!#zh
该资源是否已经成功加载。 */
- loaded: boolean;
+ loaded: boolean;
/** !#en
Returns the url of this asset's native object, if none it will returns an empty string.
!#zh
返回该资源对应的目标平台资源的 URL,如果没有将返回一个空字符串。 */
- nativeUrl: string;
+ nativeUrl: string;
/** !#en
The number of reference
-
+
!#zh
引用的数量 */
- refCount: number;
+ 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;
+ static preventDeferredLoadDependents: boolean;
/** !#en Indicates whether its native object should be preloaded from native url.
!#zh 禁止预加载原生对象。 */
- static preventPreloadNativeObject: boolean;
+ 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()` 方法。
+ 当资源要表示为文本值时或在字符串连接时引用时,JavaScript 会自动调用 `toString()` 方法。
*/
- toString(): string;
+ toString(): string;
/**
!#en
Create a new node using this asset in the scene.
@@ -6331,85 +6331,85 @@ declare namespace cc {
!#zh
使用该资源在场景中创建一个新节点。
如果这类资源没有相应的节点类型,该方法应该是空的。
- @param callback callback
+ @param callback callback
*/
- createNode(callback: (error: string, node: any) => void): void;
+ createNode(callback: (error: string, node: any) => void): void;
/**
!#en
Add references of asset
-
+
!#zh
- 增加资源的引用
+ 增加资源的引用
*/
- addRef(): cc.Asset;
+ addRef(): cc.Asset;
/**
!#en
Reduce references of asset and it will be auto released when refCount equals 0.
-
+
!#zh
- 减少资源的引用并尝试进行自动释放。
+ 减少资源的引用并尝试进行自动释放。
*/
- decRef(): cc.Asset;
- }
+ decRef(): cc.Asset;
+ }
/** Predefined constants */
- export class macro {
+ export class macro {
/** `cc.macro.DOWNLOAD_MAX_CONCURRENT` is deprecated now, please use {{#crossLink "Downloader/maxConcurrency:property"}}{{/crossLink}} instead */
- static DOWNLOAD_MAX_CONCURRENT: number;
+ static DOWNLOAD_MAX_CONCURRENT: number;
/** PI / 180 */
- static RAD: number;
+ static RAD: number;
/** One degree */
- static DEG: number;
- static REPEAT_FOREVER: number;
- static FLT_EPSILON: number;
+ static DEG: number;
+ static REPEAT_FOREVER: number;
+ static FLT_EPSILON: number;
/** Minimum z index value for node */
- static MIN_ZINDEX: number;
+ static MIN_ZINDEX: number;
/** Maximum z index value for node */
- static MAX_ZINDEX: number;
- static ONE: number;
- static ZERO: number;
- static SRC_ALPHA: number;
- static SRC_ALPHA_SATURATE: number;
- static SRC_COLOR: number;
- static DST_ALPHA: number;
- static DST_COLOR: number;
- static ONE_MINUS_SRC_ALPHA: number;
- static ONE_MINUS_SRC_COLOR: number;
- static ONE_MINUS_DST_ALPHA: number;
- static ONE_MINUS_DST_COLOR: number;
- static ONE_MINUS_CONSTANT_ALPHA: number;
- static ONE_MINUS_CONSTANT_COLOR: number;
+ static MAX_ZINDEX: number;
+ static ONE: number;
+ static ZERO: number;
+ static SRC_ALPHA: number;
+ static SRC_ALPHA_SATURATE: number;
+ static SRC_COLOR: number;
+ static DST_ALPHA: number;
+ static DST_COLOR: number;
+ static ONE_MINUS_SRC_ALPHA: number;
+ static ONE_MINUS_SRC_COLOR: number;
+ static ONE_MINUS_DST_ALPHA: number;
+ static ONE_MINUS_DST_COLOR: number;
+ static ONE_MINUS_CONSTANT_ALPHA: number;
+ static ONE_MINUS_CONSTANT_COLOR: number;
/** Oriented vertically */
- static ORIENTATION_PORTRAIT: number;
+ static ORIENTATION_PORTRAIT: number;
/** Oriented horizontally */
- static ORIENTATION_LANDSCAPE: number;
+ static ORIENTATION_LANDSCAPE: number;
/** Oriented automatically */
- static ORIENTATION_AUTO: number;
+ static ORIENTATION_AUTO: number;
/**
- - texCoord.left = (rect.x*2+1) / (texture.wide*2);
- - texCoord.right = texCoord.left + (rect.width*2-2)/(texture.wide*2);
-
+ - texCoord.left = (rect.x*2+1) / (texture.wide*2);
+ - texCoord.right = texCoord.left + (rect.width*2-2)/(texture.wide*2);
+
The same for bottom and top.
-
+
This formula prevents artifacts by using 99% of the texture.
The "correct" way to prevent artifacts is by expand the texture's border with the same color by 1 pixel
-
+
Affected component:
- - cc.TMXLayer
-
+ - cc.TMXLayer
+
Enabled by default. To disabled set it to 0.
To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h
To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h */
- static DIRECTOR_STATS_POSITION: Vec2;
+ static DIRECTOR_STATS_POSITION: Vec2;
/**
If you run 2 or more 'position' actions at the same time on a node, then end position will be the sum of all the positions.
If disabled, only the last run action will take effect.
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 {
+ export class JsonAsset extends Asset {
/** The loaded JSON object. */
- json: any;
- }
+ json: any;
+ }
/** !#en Class for LabelAtlas handling.
!#zh 艺术数字字体资源类。 */
- export class LabelAtlas extends BitmapFont {
- }
+ export class LabelAtlas extends BitmapFont {
+ }
/** !#en Class for prefab handling.
!#zh 预制资源类。 */
- export class Prefab extends Asset {
+ export class Prefab extends Asset {
/** the main cc.Node in the prefab */
- data: Node;
+ 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;
+ optimizationPolicy: Prefab.OptimizationPolicy;
/** !#en Indicates the raw assets of this prefab can be load after prefab loaded.
!#zh 指示该 Prefab 依赖的资源可否在 Prefab 加载后再延迟加载。 */
- asyncLoadAssets: boolean;
- readonly: boolean;
+ 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.
+ but you can re-call to refresh the create function once you modified the original prefab data in script.
*/
- compileCreateFunction(): void;
- }
+ compileCreateFunction(): void;
+ }
/** Render textures are textures that can be rendered to. */
- export class RenderTexture extends Texture2D {
+ export class RenderTexture extends Texture2D {
/**
!#en
Init the render texture with size.
@@ -6686,9 +6686,9 @@ declare namespace cc {
初始化 render texture
@param width width
@param height height
- @param depthStencilFormat depthStencilFormat
+ @param depthStencilFormat depthStencilFormat
*/
- initWithSize(width?: number, height?: number, depthStencilFormat?: number): void;
+ initWithSize(width?: number, height?: number, depthStencilFormat?: number): void;
/**
!#en
Get pixels from render texture, the pixels data stores in a RGBA Uint8Array.
@@ -6703,69 +6703,69 @@ declare namespace cc {
@param x x
@param y y
@param w w
- @param h h
+ @param h h
*/
- readPixels(data?: Uint8Array, x?: number, y?: number, w?: number, h?: number): Uint8Array;
- }
+ 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;
+ export class SceneAsset extends Asset {
+ scene: Scene;
/** !#en Indicates the raw assets of this scene can be load after scene launched.
!#zh 指示该场景依赖的资源可否在场景切换后再延迟加载。 */
- asyncLoadAssets: boolean;
- }
+ asyncLoadAssets: boolean;
+ }
/** !#en Class for script handling.
!#zh Script 资源类。 */
- export class _Script extends Asset {
- }
+ export class _Script extends Asset {
+ }
/** !#en Class for JavaScript handling.
!#zh JavaScript 资源类。 */
- export class _JavaScript extends Asset {
- }
+ export class _JavaScript extends Asset {
+ }
/** !#en Class for TypeScript handling.
!#zh TypeScript 资源类。 */
- export class TypeScript extends Asset {
- }
+ export class TypeScript extends Asset {
+ }
/** !#en Class for sprite atlas handling.
!#zh 精灵图集资源类。 */
- export class SpriteAtlas extends Asset {
+ export class SpriteAtlas extends Asset {
/**
- Returns the texture of the sprite atlas
+ Returns the texture of the sprite atlas
*/
- getTexture(): Texture2D;
+ getTexture(): Texture2D;
/**
Returns the sprite frame correspond to the given key in sprite atlas.
- @param key key
+ @param key key
*/
- getSpriteFrame(key: string): SpriteFrame;
+ getSpriteFrame(key: string): SpriteFrame;
/**
- Returns the sprite frames in sprite atlas.
+ Returns the sprite frames in sprite atlas.
*/
- getSpriteFrames(): SpriteFrame[];
- }
+ 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 {
+ export class SpriteFrame extends Asset implements EventTarget {
/** !#en Top border of the sprite
!#zh sprite 的顶部边框 */
- insetTop: number;
+ insetTop: number;
/** !#en Bottom border of the sprite
!#zh sprite 的底部边框 */
- insetBottom: number;
+ insetBottom: number;
/** !#en Left border of the sprite
!#zh sprite 的左边边框 */
- insetLeft: number;
+ insetLeft: number;
/** !#en Right border of the sprite
!#zh sprite 的左边边框 */
- insetRight: number;
+ insetRight: number;
/**
!#en
Constructor of SpriteFrame class.
@@ -6775,90 +6775,90 @@ declare namespace cc {
@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
+ @param originalSize The size of the frame in the texture
*/
- constructor(filename?: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size);
+ constructor(filename?: string | Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size);
/**
!#en Returns whether the texture have been loaded
- !#zh 返回是否已加载纹理
+ !#zh 返回是否已加载纹理
*/
- textureLoaded(): boolean;
+ textureLoaded(): boolean;
/**
!#en Returns whether the sprite frame is rotated in the texture.
- !#zh 获取 SpriteFrame 是否旋转
+ !#zh 获取 SpriteFrame 是否旋转
*/
- isRotated(): boolean;
+ isRotated(): boolean;
/**
!#en Set whether the sprite frame is rotated in the texture.
!#zh 设置 SpriteFrame 是否旋转
- @param bRotated bRotated
+ @param bRotated bRotated
*/
- setRotated(bRotated: boolean): void;
+ setRotated(bRotated: boolean): void;
/**
!#en Returns whether the sprite frame is flip x axis in the texture.
- !#zh 获取 SpriteFrame 是否反转 x 轴
+ !#zh 获取 SpriteFrame 是否反转 x 轴
*/
- isFlipX(): boolean;
+ isFlipX(): boolean;
/**
!#en Returns whether the sprite frame is flip y axis in the texture.
- !#zh 获取 SpriteFrame 是否反转 y 轴
+ !#zh 获取 SpriteFrame 是否反转 y 轴
*/
- isFlipY(): boolean;
+ isFlipY(): boolean;
/**
!#en Set whether the sprite frame is flip x axis in the texture.
!#zh 设置 SpriteFrame 是否翻转 x 轴
- @param flipX flipX
+ @param flipX flipX
*/
- setFlipX(flipX: boolean): void;
+ setFlipX(flipX: boolean): void;
/**
!#en Set whether the sprite frame is flip y axis in the texture.
!#zh 设置 SpriteFrame 是否翻转 y 轴
- @param flipY flipY
+ @param flipY flipY
*/
- setFlipY(flipY: boolean): void;
+ setFlipY(flipY: boolean): void;
/**
!#en Returns the rect of the sprite frame in the texture.
- !#zh 获取 SpriteFrame 的纹理矩形区域
+ !#zh 获取 SpriteFrame 的纹理矩形区域
*/
- getRect(): Rect;
+ getRect(): Rect;
/**
!#en Sets the rect of the sprite frame in the texture.
!#zh 设置 SpriteFrame 的纹理矩形区域
- @param rect rect
+ @param rect rect
*/
- setRect(rect: Rect): void;
+ setRect(rect: Rect): void;
/**
!#en Returns the original size of the trimmed image.
- !#zh 获取修剪前的原始大小
+ !#zh 获取修剪前的原始大小
*/
- getOriginalSize(): Size;
+ getOriginalSize(): Size;
/**
!#en Sets the original size of the trimmed image.
!#zh 设置修剪前的原始大小
- @param size size
+ @param size size
*/
- setOriginalSize(size: Size): void;
+ setOriginalSize(size: Size): void;
/**
!#en Returns the texture of the frame.
- !#zh 获取使用的纹理实例
+ !#zh 获取使用的纹理实例
*/
- getTexture(): Texture2D;
+ getTexture(): Texture2D;
/**
!#en Returns the offset of the frame in the texture.
- !#zh 获取偏移量
+ !#zh 获取偏移量
*/
- getOffset(): Vec2;
+ getOffset(): Vec2;
/**
!#en Sets the offset of the frame in the texture.
!#zh 设置偏移量
- @param offsets offsets
+ @param offsets offsets
*/
- setOffset(offsets: Vec2): void;
+ setOffset(offsets: Vec2): void;
/**
!#en Clone the sprite frame.
- !#zh 克隆 SpriteFrame
+ !#zh 克隆 SpriteFrame
*/
- clone(): SpriteFrame;
+ clone(): SpriteFrame;
/**
!#en Set SpriteFrame with Texture, rect, rotated, offset and originalSize.
!#zh 通过 Texture,rect,rotated,offset 和 originalSize 设置 SpriteFrame。
@@ -6866,9 +6866,9 @@ declare namespace cc {
@param rect rect
@param rotated rotated
@param offset offset
- @param originalSize originalSize
+ @param originalSize originalSize
*/
- setTexture(texture: Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size): boolean;
+ 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.
@@ -6876,32 +6876,32 @@ declare namespace cc {
You can call this method if you want to load the texture early.
!#zh 当加载中的场景或 Prefab 被标记为 `asyncLoadAssets` 时,用户在场景中由自定义组件关联到的所有 SpriteFrame 的贴图都不会被提前加载。
只有当 Sprite 组件要渲染这些 SpriteFrame 时,才会检查贴图是否加载。如果你希望加载过程提前,你可以手工调用这个方法。
-
- @example
+
+ @example
```js
if (spriteFrame.textureLoaded()) {
- this._onSpriteFrameLoaded();
+ this._onSpriteFrameLoaded();
}
else {
- spriteFrame.once('load', this._onSpriteFrameLoaded, this);
- spriteFrame.ensureLoadTexture();
+ spriteFrame.once('load', this._onSpriteFrameLoaded, this);
+ spriteFrame.ensureLoadTexture();
}
- ```
+ ```
*/
- ensureLoadTexture(): void;
+ 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` 来重新加载贴图。
+ 当你暂时不再使用这个 SpriteFrame 时,可以调用这个方法来保证引用的贴图对象能被 GC。然后当你要渲染 SpriteFrame 时,你需要手动调用 `ensureLoadTexture` 来重新加载贴图。
*/
- clearTexture(): void;
+ 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.
+ @param type The type of event.
*/
- hasEventListener(type: string): boolean;
+ hasEventListener(type: string): boolean;
/**
!#en
Register an callback of a specific event type on the EventTarget.
@@ -6910,17 +6910,17 @@ declare namespace cc {
注册事件目标的特定事件类型回调。这种类型的事件应该被 `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).
+ 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
+
+ @example
```js
eventTarget.on('fire', function () {
- cc.log("fire in the hole");
+ cc.log("fire in the hole");
}, node);
- ```
+ ```
*/
- on
@@ -7071,9 +7071,9 @@ declare namespace cc {
you should set texture.packable as false before getting Html element object.
!#zh 获取当前贴图对应的 HTML Image 或 Canvas 对象,只在 Web 平台下有效。
注意:
- texture 默认参与动态合图,如果需要获取到正确的 Html 元素对象,需要先设置 texture.packable 为 false
+ texture 默认参与动态合图,如果需要获取到正确的 Html 元素对象,需要先设置 texture.packable 为 false
*/
- getHtmlElementObj(): HTMLImageElement;
+ getHtmlElementObj(): HTMLImageElement;
/**
!#en
Destory this texture and immediately release its video memory. (Inherit from cc.Object.destroy)
@@ -7081,77 +7081,77 @@ declare namespace cc {
You can use cc.isValid(obj) to check whether the object is destroyed before accessing it.
!#zh
销毁该贴图,并立即释放它对应的显存。(继承自 cc.Object.destroy)
- 销毁后,该对象不再可用。您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。
+ 销毁后,该对象不再可用。您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。
*/
- destroy(): boolean;
+ destroy(): boolean;
/**
!#en
Pixel format of the texture.
- !#zh 获取纹理的像素格式。
+ !#zh 获取纹理的像素格式。
*/
- getPixelFormat(): number;
+ getPixelFormat(): number;
/**
!#en
Whether or not the texture has their Alpha premultiplied.
- !#zh 检查纹理在上传 GPU 时预乘选项是否开启。
+ !#zh 检查纹理在上传 GPU 时预乘选项是否开启。
*/
- hasPremultipliedAlpha(): boolean;
+ 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
+ @param premultiplied premultiplied
*/
- handleLoadedTexture(premultiplied?: boolean): void;
+ handleLoadedTexture(premultiplied?: boolean): void;
/**
!#en
Description of cc.Texture2D.
- !#zh cc.Texture2D 描述。
+ !#zh cc.Texture2D 描述。
*/
- description(): string;
+ description(): string;
/**
!#en
Release texture, please use destroy instead.
- !#zh 释放纹理,请使用 destroy 替代。
+ !#zh 释放纹理,请使用 destroy 替代。
*/
- releaseTexture(): void;
+ 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
+ @param wrapT wrapT
*/
- setWrapMode(wrapS: Texture2D.WrapMode, wrapT: Texture2D.WrapMode): void;
+ setWrapMode(wrapS: Texture2D.WrapMode, wrapT: Texture2D.WrapMode): void;
/**
!#en Sets the minFilter and magFilter options
!#zh 设置纹理贴图缩小和放大过滤器算法选项。
@param minFilter minFilter
- @param magFilter magFilter
+ @param magFilter magFilter
*/
- setFilters(minFilter: Texture2D.Filter, magFilter: Texture2D.Filter): void;
+ setFilters(minFilter: Texture2D.Filter, magFilter: Texture2D.Filter): void;
/**
!#en
Sets the flipY options
!#zh 设置贴图的纵向翻转选项。
- @param flipY flipY
+ @param flipY flipY
*/
- setFlipY(flipY: boolean): void;
+ setFlipY(flipY: boolean): void;
/**
!#en
Sets the premultiply alpha options
!#zh 设置贴图的预乘选项。
- @param premultiply premultiply
+ @param premultiply premultiply
*/
- setPremultiplyAlpha(premultiply: boolean): void;
+ 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.
+ @param type The type of event.
*/
- hasEventListener(type: string): boolean;
+ hasEventListener(type: string): boolean;
/**
!#en
Register an callback of a specific event type on the EventTarget.
@@ -7160,17 +7160,17 @@ declare namespace cc {
注册事件目标的特定事件类型回调。这种类型的事件应该被 `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).
+ 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
+
+ @example
```js
eventTarget.on('fire', function () {
- cc.log("fire in the hole");
+ cc.log("fire in the hole");
}, node);
- ```
+ ```
*/
- on
*/
- export class EventTarget extends CallbacksInvoker {
+ 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.
+ @param type The type of event.
*/
- hasEventListener(type: string): boolean;
+ hasEventListener(type: string): boolean;
/**
!#en
Register an callback of a specific event type on the EventTarget.
@@ -7619,17 +7619,17 @@ declare namespace cc {
注册事件目标的特定事件类型回调。这种类型的事件应该被 `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).
+ 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
+
+ @example
```js
eventTarget.on('fire', function () {
- cc.log("fire in the hole");
+ 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.
+ Gets current target of the event
+ 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 {
+ export class SystemEvent extends EventTarget {
/**
!#en whether enable accelerometer event
!#zh 是否启用加速度计事件
- @param isEnable isEnable
+ @param isEnable isEnable
*/
- setAccelerometerEnabled(isEnable: boolean): void;
+ setAccelerometerEnabled(isEnable: boolean): void;
/**
!#en set accelerometer interval value
!#zh 设置加速度计间隔值
- @param interval interval
+ @param interval interval
*/
- setAccelerometerInterval(interval: number): void;
- }
+ setAccelerometerInterval(interval: number): void;
+ }
/** !#en The animation component is used to play back animations.
-
+
Animation provide several events to register:
- play : Emit when begin playing animation
- stop : Emit when stop playing animation
@@ -7835,9 +7835,9 @@ declare namespace cc {
- resume : Emit when resume animation
- lastframe : If animation repeat count is larger than 1, emit when animation play to the last frame
- finished : Emit when finish playing animation
-
+
!#zh Animation 组件用于播放动画。
-
+
Animation 提供了一系列可注册的事件:
- play : 开始播放时
- stop : 停止播放时
@@ -7845,34 +7845,34 @@ declare namespace cc {
- resume : 恢复播放时
- lastframe : 假如动画循环次数大于 1,当动画播放到最后一帧时
- finished : 动画播放完成时 */
- export class Animation extends Component implements EventTarget {
+ export class Animation extends Component implements EventTarget {
/** !#en Animation will play the default clip when start game.
!#zh 在勾选自动播放或调用 play() 时默认播放的动画剪辑。 */
- defaultClip: AnimationClip;
+ defaultClip: AnimationClip;
/** !#en Current played clip.
!#zh 当前播放的动画剪辑。 */
- currentClip: AnimationClip;
+ currentClip: AnimationClip;
/** !#en Whether the animation should auto play the default clip when start game.
!#zh 是否在运行游戏后自动播放默认动画剪辑。 */
- playOnLoad: boolean;
+ playOnLoad: boolean;
/**
!#en Get all the clips used in this animation.
- !#zh 获取动画组件上的所有动画剪辑。
+ !#zh 获取动画组件上的所有动画剪辑。
*/
- getClips(): AnimationClip[];
+ getClips(): AnimationClip[];
/**
!#en Plays an animation and stop other animations.
!#zh 播放指定的动画,并且停止当前正在播放动画。如果没有指定动画,则播放默认动画。
@param name The name of animation to play. If no name is supplied then the default animation will be played.
@param startTime play an animation from startTime
-
- @example
+
+ @example
```js
var animCtrl = this.node.getComponent(cc.Animation);
animCtrl.play("linear");
- ```
+ ```
*/
- play(name?: string, startTime?: number): AnimationState;
+ play(name?: string, startTime?: number): AnimationState;
/**
!#en
Plays an additive animation, it will not stop other animations.
@@ -7880,55 +7880,55 @@ declare namespace cc {
!#zh 播放指定的动画(将不会停止当前播放的动画)。如果没有指定动画,则播放默认动画。
@param name The name of animation to play. If no name is supplied then the default animation will be played.
@param startTime play an animation from startTime
-
- @example
+
+ @example
```js
// linear_1 and linear_2 at the same time playing.
var animCtrl = this.node.getComponent(cc.Animation);
animCtrl.playAdditive("linear_1");
animCtrl.playAdditive("linear_2");
- ```
+ ```
*/
- playAdditive(name?: string, startTime?: number): AnimationState;
+ playAdditive(name?: string, startTime?: number): AnimationState;
/**
!#en Stops an animation named name. If no name is supplied then stops all playing animations that were started with this Animation.
Stopping an animation also Rewinds it to the Start.
!#zh 停止指定的动画。如果没有指定名字,则停止当前正在播放的动画。
- @param name The animation to stop, if not supplied then stops all playing animations.
+ @param name The animation to stop, if not supplied then stops all playing animations.
*/
- stop(name?: string): void;
+ stop(name?: string): void;
/**
!#en Pauses an animation named name. If no name is supplied then pauses all playing animations that were started with this Animation.
!#zh 暂停当前或者指定的动画。如果没有指定名字,则暂停当前正在播放的动画。
- @param name The animation to pauses, if not supplied then pauses all playing animations.
+ @param name The animation to pauses, if not supplied then pauses all playing animations.
*/
- pause(name?: string): void;
+ pause(name?: string): void;
/**
!#en Resumes an animation named name. If no name is supplied then resumes all paused animations that were started with this Animation.
!#zh 重新播放指定的动画,如果没有指定名字,则重新播放当前正在播放的动画。
- @param name The animation to resumes, if not supplied then resumes all paused animations.
+ @param name The animation to resumes, if not supplied then resumes all paused animations.
*/
- resume(name?: string): void;
+ resume(name?: string): void;
/**
!#en Make an animation named name go to the specified time. If no name is supplied then make all animations go to the specified time.
!#zh 设置指定动画的播放时间。如果没有指定名字,则设置当前播放动画的播放时间。
@param time The time to go to
- @param name Specified animation name, if not supplied then make all animations go to the time.
+ @param name Specified animation name, if not supplied then make all animations go to the time.
*/
- setCurrentTime(time?: number, name?: string): void;
+ setCurrentTime(time?: number, name?: string): void;
/**
!#en Returns the animation state named name. If no animation with the specified name, the function will return null.
!#zh 获取当前或者指定的动画状态,如果未找到指定动画剪辑则返回 null。
- @param name name
+ @param name name
*/
- getAnimationState(name: string): AnimationState;
+ getAnimationState(name: string): AnimationState;
/**
!#en Adds a clip to the animation with name newName. If a clip with that name already exists it will be replaced with the new clip.
!#zh 添加动画剪辑,并且可以重新设置该动画剪辑的名称。
@param clip the clip to add
- @param newName newName
+ @param newName newName
*/
- addClip(clip: AnimationClip, newName?: string): AnimationState;
+ addClip(clip: AnimationClip, newName?: string): AnimationState;
/**
!#en
Remove clip from the animation list. This will remove the clip and any animation states based on it.
@@ -7939,17 +7939,17 @@ declare namespace cc {
如果依赖于 clip 的 AnimationState 正在播放或者 clip 是 defaultClip 的话,默认是不会删除 clip 的。
但是如果 force 参数为 true,则会强制停止该动画,然后移除该动画剪辑和相关的动画。这时候如果 clip 是 defaultClip,defaultClip 将会被重置为 null。
@param clip clip
- @param force If force is true, then will always remove the clip and any animation states based on it.
+ @param force If force is true, then will always remove the clip and any animation states based on it.
*/
- removeClip(clip: AnimationClip, force?: boolean): void;
+ removeClip(clip: AnimationClip, force?: boolean): void;
/**
!#en
Samples animations at the current state.
This is useful when you explicitly want to set up some animation state, and sample it once.
!#zh 对指定或当前动画进行采样。你可以手动将动画设置到某一个状态,然后采样一次。
- @param name name
+ @param name name
*/
- sample(name: string): void;
+ sample(name: string): void;
/**
!#en
Register animation event callback.
@@ -7961,27 +7961,27 @@ declare namespace cc {
当播放一个动画时,会自动将事件注册到对应的 AnimationState 上,停止播放时会将事件从这个 AnimationState 上取消注册。
@param type A string representing the event type to listen for.
@param callback The callback that will be invoked when the event is dispatched.
- The callback is ignored if it is a duplicate (the callbacks are unique).
+ The callback is ignored if it is a duplicate (the callbacks are unique).
@param state state
@param target The target (this object) to invoke the callback, can be null
@param useCapture When set to true, the capture argument prevents callback
- from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
- When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
- Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
-
- @example
+ from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
+ When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
+ Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
+
+ @example
```js
onPlay: function (type, state) {
- // callback
+ // callback
}
-
+
// register event to all animation
animation.on('play', this.onPlay, this);
- ```
+ ```
*/
on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void;
on
Note: isPlaying is not supported for Native platforms.
!#zh
该音频剪辑是否正播放(只读)。
注意:Native 平台暂时不支持 isPlaying。 */
- isPlaying: boolean;
+ isPlaying: boolean;
/** !#en The clip of the audio source to play.
!#zh 要播放的音频剪辑。 */
- clip: AudioClip;
+ clip: AudioClip;
/** !#en The volume of the audio source.
!#zh 音频源的音量(0.0 ~ 1.0)。 */
- volume: number;
+ volume: number;
/** !#en Is the audio source mute?
!#zh 是否静音音频源。Mute 是设置音量为 0,取消静音是恢复原来的音量。 */
- mute: boolean;
+ mute: boolean;
/** !#en Is the audio source looping?
!#zh 音频源是否循环播放? */
- loop: boolean;
+ loop: boolean;
/** !#en If set to true, the audio source will automatically start playing on onEnable.
!#zh 如果设置为 true,音频源将在 onEnable 时自动播放。 */
- playOnLoad: boolean;
+ playOnLoad: boolean;
/** !#en If set to true and AudioClip is a deferred load resource, the component will preload AudioClip in the onLoad phase.
!#zh 如果设置为 true 且 AudioClip 为延迟加载资源,组件将在 onLoad 阶段预加载 AudioClip。 */
- preload: boolean;
+ preload: boolean;
/**
!#en Plays the clip.
- !#zh 播放音频剪辑。
+ !#zh 播放音频剪辑。
*/
- play(): void;
+ play(): void;
/**
!#en Stops the clip.
- !#zh 停止当前音频剪辑。
+ !#zh 停止当前音频剪辑。
*/
- stop(): void;
+ stop(): void;
/**
!#en Pause the clip.
- !#zh 暂停当前音频剪辑。
+ !#zh 暂停当前音频剪辑。
*/
- pause(): void;
+ pause(): void;
/**
!#en Resume the clip.
- !#zh 恢复播放。
+ !#zh 恢复播放。
*/
- resume(): void;
+ resume(): void;
/**
!#en Rewind playing music.
- !#zh 从头开始播放。
+ !#zh 从头开始播放。
*/
- rewind(): void;
+ rewind(): void;
/**
!#en Get current time
- !#zh 获取当前的播放时间
+ !#zh 获取当前的播放时间
*/
- getCurrentTime(): number;
+ getCurrentTime(): number;
/**
!#en Set current time
!#zh 设置当前的播放时间
- @param time time
+ @param time time
*/
- setCurrentTime(time: number): number;
+ setCurrentTime(time: number): number;
/**
!#en Get audio duration
- !#zh 获取当前音频的长度
+ !#zh 获取当前音频的长度
*/
- getDuration(): number;
- }
+ getDuration(): number;
+ }
/** !#en
This component will block all input events (mouse and touch) within the bounding box of the node, preventing the input from penetrating into the underlying node, typically for the background of the top UI.
This component does not have any API interface and can be added directly to the scene to take effect.
!#zh
该组件将拦截所属节点 bounding box 内的所有输入事件(鼠标和触摸),防止输入穿透到下层节点,一般用于上层 UI 的背景。
该组件没有任何 API 接口,直接添加到场景即可生效。 */
- export class BlockInputEvents extends Component {
- }
+ export class BlockInputEvents extends Component {
+ }
/** !#en
Button component. Can be pressed or clicked. Button has 4 Transition types:
-
+
- Button.Transition.NONE // Button will do nothing
- Button.Transition.COLOR // Button will change target's color
- Button.Transition.SPRITE // Button will change target Sprite's sprite
- Button.Transition.SCALE // Button will change target node's scale
-
+
The button can bind events (but you must be on the button's node to bind events).
The following events can be triggered on all platforms.
-
+
- cc.Node.EventType.TOUCH_START // Press
- cc.Node.EventType.TOUCH_MOVE // After pressing and moving
- cc.Node.EventType.TOUCH_END // After pressing and releasing
- cc.Node.EventType.TOUCH_CANCEL // Press to cancel
-
+
The following events are only triggered on the PC platform:
-
+
- cc.Node.EventType.MOUSE_DOWN
- cc.Node.EventType.MOUSE_MOVE
- cc.Node.EventType.MOUSE_ENTER
- cc.Node.EventType.MOUSE_LEAVE
- cc.Node.EventType.MOUSE_UP
- cc.Node.EventType.MOUSE_WHEEL
-
+
User can get the current clicked node with 'event.target' from event object which is passed as parameter in the callback function of click event.
-
+
!#zh
按钮组件。可以被按下,或者点击。
-
+
按钮可以通过修改 Transition 来设置按钮状态过渡的方式:
-
+
- Button.Transition.NONE // 不做任何过渡
- Button.Transition.COLOR // 进行颜色之间过渡
- Button.Transition.SPRITE // 进行精灵之间过渡
- Button.Transition.SCALE // 进行缩放过渡
-
+
按钮可以绑定事件(但是必须要在按钮的 Node 上才能绑定事件):
以下事件可以在全平台上都触发:
-
+
- cc.Node.EventType.TOUCH_START // 按下时事件
- cc.Node.EventType.TOUCH_MOVE // 按住移动后事件
- cc.Node.EventType.TOUCH_END // 按下后松开后事件
- cc.Node.EventType.TOUCH_CANCEL // 按下取消事件
-
+
以下事件只在 PC 平台上触发:
-
+
- cc.Node.EventType.MOUSE_DOWN // 鼠标按下时事件
- cc.Node.EventType.MOUSE_MOVE // 鼠标按住移动后事件
- cc.Node.EventType.MOUSE_ENTER // 鼠标进入目标事件
- cc.Node.EventType.MOUSE_LEAVE // 鼠标离开目标事件
- cc.Node.EventType.MOUSE_UP // 鼠标松开事件
- cc.Node.EventType.MOUSE_WHEEL // 鼠标滚轮事件
-
+
用户可以通过获取 __点击事件__ 回调函数的参数 event 的 target 属性获取当前点击对象。 */
- export class Button extends Component implements GraySpriteState {
+ export class Button extends Component implements GraySpriteState {
/** !#en
Whether the Button is disabled.
If true, the Button will trigger event and do transition.
!#zh
按钮事件是否被响应,如果为 false,则按钮将被禁用。 */
- interactable: boolean;
+ interactable: boolean;
/** !#en When this flag is true, Button target sprite will turn gray when interactable is false.
!#zh 如果这个标记为 true,当 button 的 interactable 属性为 false 的时候,会使用内置 shader 让 button 的 target 节点的 sprite 组件变灰 */
- enableAutoGrayEffect: boolean;
+ enableAutoGrayEffect: boolean;
/** !#en Transition type
!#zh 按钮状态改变时过渡方式。 */
- transition: Button.Transition;
+ transition: Button.Transition;
/** !#en Normal state color.
!#zh 普通状态下按钮所显示的颜色。 */
- normalColor: Color;
+ normalColor: Color;
/** !#en Pressed state color
!#zh 按下状态时按钮所显示的颜色。 */
- pressedColor: Color;
+ pressedColor: Color;
/** !#en Hover state color
!#zh 悬停状态下按钮所显示的颜色。 */
- hoverColor: Color;
+ hoverColor: Color;
/** !#en Disabled state color
!#zh 禁用状态下按钮所显示的颜色。 */
- disabledColor: Color;
+ disabledColor: Color;
/** !#en Color and Scale transition duration
!#zh 颜色过渡和缩放过渡时所需时间 */
- duration: number;
+ duration: number;
/** !#en When user press the button, the button will zoom to a scale.
The final scale of the button equals (button original scale * zoomScale)
!#zh 当用户点击按钮后,按钮会缩放到一个值,这个值等于 Button 原始 scale * zoomScale */
- zoomScale: number;
+ zoomScale: number;
/** !#en Normal state sprite
!#zh 普通状态下按钮所显示的 Sprite 。 */
- normalSprite: SpriteFrame;
+ normalSprite: SpriteFrame;
/** !#en Pressed state sprite
!#zh 按下状态时按钮所显示的 Sprite 。 */
- pressedSprite: SpriteFrame;
+ pressedSprite: SpriteFrame;
/** !#en Hover state sprite
!#zh 悬停状态下按钮所显示的 Sprite 。 */
- hoverSprite: SpriteFrame;
+ hoverSprite: SpriteFrame;
/** !#en Disabled state sprite
!#zh 禁用状态下按钮所显示的 Sprite 。 */
- disabledSprite: SpriteFrame;
+ disabledSprite: SpriteFrame;
/** !#en
Transition target.
When Button state changed:
@@ -8243,33 +8243,33 @@ declare namespace cc {
-如果 Transition type 选择 Button.Transition.NONE,按钮不做任何过渡。
-如果 Transition type 选择 Button.Transition.COLOR,按钮会对目标颜色进行颜色之间的过渡。
-如果 Transition type 选择 Button.Transition.Sprite,按钮会对目标 Sprite 进行 Sprite 之间的过渡。 */
- target: Node;
+ target: Node;
/** !#en If Button is clicked, it will trigger event's handler
!#zh 按钮的点击事件列表。 */
- clickEvents: Component.EventHandler[];
+ clickEvents: Component.EventHandler[];
/** !#en The normal material.
!#zh 正常状态的材质。 */
- normalMaterial: Material;
+ normalMaterial: Material;
/** !#en The gray material.
!#zh 置灰状态的材质。 */
- grayMaterial: Material;
- }
+ grayMaterial: Material;
+ }
/** !#zh 作为 UI 根节点,为所有子节点提供视窗四边的位置信息以供对齐,另外提供屏幕适配策略接口,方便从编辑器设置。
注:由于本节点的尺寸会跟随屏幕拉伸,所以 anchorPoint 只支持 (0.5, 0.5),否则适配不同屏幕时坐标会有偏差。 */
- export class Canvas extends Component {
+ export class Canvas extends Component {
/** !#en Current active canvas, the scene should only have one active canvas at the same time.
!#zh 当前激活的画布组件,场景同一时间只能有一个激活的画布。 */
- static instance: Canvas;
+ static instance: Canvas;
/** !#en The desigin resolution for current scene.
!#zh 当前场景设计分辨率。 */
- designResolution: Size;
+ designResolution: Size;
/** !#en TODO
!#zh: 是否优先将设计分辨率高度撑满视图高度。 */
- fitHeight: boolean;
+ fitHeight: boolean;
/** !#en TODO
!#zh: 是否优先将设计分辨率宽度撑满视图宽度。 */
- fitWidth: boolean;
- }
+ fitWidth: boolean;
+ }
/** !#en
Base class for everything attached to Node(Entity).
@@ -8279,38 +8279,38 @@ declare namespace cc {
所有附加到节点的基类。
注意:不允许使用组件的子类构造参数,因为组件是由引擎创建的。 */
- export class Component extends Object {
+ export class Component extends Object {
/** !#en The node this component is attached to. A component is always attached to a node.
!#zh 该组件被附加到的节点。组件总会附加到一个节点。 */
- node: Node;
+ node: Node;
/** !#en The uuid for editor.
!#zh 组件的 uuid,用于编辑器。 */
- uuid: string;
+ uuid: string;
/** !#en indicates whether this component is enabled or not.
!#zh 表示该组件自身是否启用。 */
- enabled: boolean;
+ enabled: boolean;
/** !#en indicates whether this component is enabled and its node is also active in the hierarchy.
!#zh 表示该组件是否被启用并且所在的节点也处于激活状态。 */
- enabledInHierarchy: boolean;
+ enabledInHierarchy: boolean;
/** !#en Returns a value which used to indicate the onLoad get called or not.
!#zh 返回一个值用来判断 onLoad 是否被调用过,不等于 0 时调用过,等于 0 时未调用。 */
- _isOnLoadCalled: number;
+ _isOnLoadCalled: number;
/**
!#en Update is called every frame, if the Component is enabled.
This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere.
!#zh 如果该组件启用,则每帧调用 update。
该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
- @param dt the delta time in seconds it took to complete the last frame
+ @param dt the delta time in seconds it took to complete the last frame
*/
- protected update(dt: number): void;
+ protected update(dt: number): void;
/**
!#en LateUpdate is called every frame, if the Component is enabled.
This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere.
!#zh 如果该组件启用,则每帧调用 LateUpdate。
该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
- @param dt the delta time in seconds it took to complete the last frame
+ @param dt the delta time in seconds it took to complete the last frame
*/
- protected lateUpdate(dt: number): void;
+ protected lateUpdate(dt: number): void;
/**
!#en
When attaching to an active node or its node first activated.
@@ -8318,9 +8318,9 @@ declare namespace cc {
This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere.
!#zh
当附加到一个激活的节点上或者其节点第一次激活时候调用。onLoad 总是会在任何 start 方法调用前执行,这能用于安排脚本的初始化顺序。
- 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
*/
- protected onLoad(): void;
+ protected onLoad(): void;
/**
!#en
Called before all scripts' update if the Component is enabled the first time.
@@ -8328,50 +8328,50 @@ declare namespace cc {
This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere.
!#zh
如果该组件第一次启用,则在所有组件的 update 之前调用。通常用于需要在所有组件的 onLoad 初始化完毕后执行的逻辑。
- 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
*/
- protected start(): void;
+ protected start(): void;
/**
!#en Called when this component becomes enabled and its node is active.
This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere.
!#zh 当该组件被启用,并且它的节点也激活时。
- 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
*/
- protected onEnable(): void;
+ protected onEnable(): void;
/**
!#en Called when this component becomes disabled or its node becomes inactive.
This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere.
!#zh 当该组件被禁用或节点变为无效时调用。
- 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
*/
- protected onDisable(): void;
+ protected onDisable(): void;
/**
!#en Called when this component will be destroyed.
This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere.
!#zh 当该组件被销毁时调用
- 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
+ 该方法为生命周期方法,父类未必会有实现。并且你只能在该方法内部调用父类的实现,不可在其它地方直接调用该方法。
*/
- protected onDestroy(): void;
- protected onFocusInEditor(): void;
- protected onLostFocusInEditor(): void;
+ protected onDestroy(): void;
+ protected onFocusInEditor(): void;
+ protected onLostFocusInEditor(): void;
/**
!#en Called to initialize the component or node’s properties when adding the component the first time or when the Reset command is used. This function is only called in editor.
- !#zh 用来初始化组件或节点的一些属性,当该组件被第一次添加到节点上或用户点击了它的 Reset 菜单时调用。这个回调只会在编辑器下调用。
+ !#zh 用来初始化组件或节点的一些属性,当该组件被第一次添加到节点上或用户点击了它的 Reset 菜单时调用。这个回调只会在编辑器下调用。
*/
- protected resetInEditor(): void;
+ protected resetInEditor(): void;
/**
!#en Adds a component class to the node. You can also add component to node by passing in the name of the script.
!#zh 向节点添加一个组件类,你还可以通过传入脚本的名称来添加组件。
@param typeOrClassName the constructor or the class name of the component to add
-
- @example
+
+ @example
```js
var sprite = node.addComponent(cc.Sprite);
var test = node.addComponent("Test");
- ```
+ ```
*/
- addComponent
@@ -8380,56 +8380,56 @@ declare namespace cc {
获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。
传入参数也可以是脚本的名称。
@param typeOrClassName typeOrClassName
-
- @example
+
+ @example
```js
// get sprite component.
var sprite = node.getComponent(cc.Sprite);
// get custom test calss.
var test = node.getComponent("Test");
- ```
+ ```
*/
- getComponent
will not be called during reset operation. Which means that only the properties with default value
will be reset by editor.
-
+
This function is only called in editor mode.
!#zh
onRestore 是用户在检查器菜单点击 Reset 时,对此组件执行撤消操作后调用的。
@@ -8472,9 +8472,9 @@ declare namespace cc {
同样的,编辑可能无法在极端情况下正确地重置您的组件。如果你需要支持组件重置菜单,则需要在该方法中手工同步组件属性到“内部状态”。一旦你实现这个方法,组件的所有 get set 都不会在重置操作时被调用。这意味着仅仅指定了默认值的属性将被编辑器重置。
- 此方法仅在编辑器下会被调用。
+ 此方法仅在编辑器下会被调用。
*/
- onRestore(): void;
+ onRestore(): void;
/**
!#en
Schedules a custom selector.
@@ -8486,138 +8486,138 @@ declare namespace cc {
@param interval Tick interval in seconds. 0 means tick every frame.
@param repeat The selector will be executed (repeat + 1) times, you can use cc.macro.REPEAT_FOREVER for tick infinitely.
@param delay The amount of time that the first tick will wait before execution. Unit: s
-
- @example
+
+ @example
```js
var timeCallback = function (dt) {
cc.log("time: " + dt);
}
this.schedule(timeCallback, 1);
- ```
+ ```
*/
- schedule(callback: Function, interval?: number, repeat?: number, delay?: number): void;
+ schedule(callback: Function, interval?: number, repeat?: number, delay?: number): void;
/**
!#en Schedules a callback function that runs only once, with a delay of 0 or larger.
!#zh 调度一个只运行一次的回调函数,可以指定 0 让回调函数在下一帧立即执行或者在一定的延时之后执行。
@param callback A function wrapped as a selector
@param delay The amount of time that the first tick will wait before execution. Unit: s
-
- @example
+
+ @example
```js
var timeCallback = function (dt) {
cc.log("time: " + dt);
}
this.scheduleOnce(timeCallback, 2);
- ```
+ ```
*/
- scheduleOnce(callback: Function, delay?: number): void;
+ scheduleOnce(callback: Function, delay?: number): void;
/**
!#en Unschedules a custom callback function.
!#zh 取消调度一个自定义的回调函数。
@param callback_fn A function wrapped as a selector
-
- @example
+
+ @example
```js
this.unschedule(_callback);
- ```
+ ```
*/
- unschedule(callback_fn: Function): void;
+ unschedule(callback_fn: Function): void;
/**
!#en
unschedule all scheduled callback functions: custom callback functions, and the 'update' callback function.
Actions are not affected by this method.
!#zh 取消调度所有已调度的回调函数:定制的回调函数以及 `update` 回调函数。动作不受此方法影响。
-
- @example
+
+ @example
```js
this.unscheduleAllCallbacks();
- ```
+ ```
*/
- unscheduleAllCallbacks(): void;
- }
+ unscheduleAllCallbacks(): void;
+ }
/** !#en The Label Component.
!#zh 文字标签组件 */
- export class Label extends RenderComponent {
+ export class Label extends RenderComponent {
/** !#en Content string of label.
!#zh 标签显示的文本内容。 */
- string: string;
+ string: string;
/** !#en Horizontal Alignment of label.
!#zh 文本内容的水平对齐方式。 */
- horizontalAlign: Label.HorizontalAlign;
+ horizontalAlign: Label.HorizontalAlign;
/** !#en Vertical Alignment of label.
!#zh 文本内容的垂直对齐方式。 */
- verticalAlign: Label.VerticalAlign;
+ verticalAlign: Label.VerticalAlign;
/** !#en The actual rendering font size in shrink mode
!#zh SHRINK 模式下面文本实际渲染的字体大小 */
- actualFontSize: number;
+ actualFontSize: number;
/** !#en Font size of label.
!#zh 文本字体大小。 */
- fontSize: number;
+ fontSize: number;
/** !#en Font family of label, only take effect when useSystemFont property is true.
!#zh 文本字体名称, 只在 useSystemFont 属性为 true 的时候生效。 */
- fontFamily: string;
+ fontFamily: string;
/** !#en Line Height of label.
!#zh 文本行高。 */
- lineHeight: number;
+ lineHeight: number;
/** !#en Overflow of label.
!#zh 文字显示超出范围时的处理方式。 */
- overflow: Label.Overflow;
+ overflow: Label.Overflow;
/** !#en Whether auto wrap label when string width is large than label width.
!#zh 是否自动换行。 */
- enableWrapText: boolean;
+ enableWrapText: boolean;
/** !#en The font of label.
!#zh 文本字体。 */
- font: Font;
+ font: Font;
/** !#en Whether use system font name or not.
!#zh 是否使用系统字体。 */
- useSystemFont: boolean;
+ useSystemFont: boolean;
/** !#en The spacing of the x axis between characters, only take Effect when using bitmap fonts.
!#zh 文字之间 x 轴的间距,仅在使用位图字体时生效。 */
- spacingX: number;
+ spacingX: number;
/** !#en The cache mode of label. This mode only supports system fonts.
!#zh 文本缓存模式, 该模式只支持系统字体。 */
- cacheMode: Label.CacheMode;
+ cacheMode: Label.CacheMode;
/** !#en Whether enable bold.
!#zh 是否启用黑体。 */
- enableBold: boolean;
+ enableBold: boolean;
/** !#en Whether enable italic.
!#zh 是否启用斜体。 */
- enableItalic: boolean;
+ enableItalic: boolean;
/** !#en Whether enable underline.
!#zh 是否启用下划线。 */
- enableUnderline: boolean;
+ enableUnderline: boolean;
/** !#en The height of underline.
!#zh 下划线高度。 */
- underlineHeight: number;
+ underlineHeight: number;
/**
!#zh 需要保证当前场景中没有使用CHAR缓存的Label才可以清除,否则已渲染的文字没有重新绘制会不显示
- !#en It can be cleared that need to ensure there is not use the CHAR cache in the current scene. Otherwise, the rendered text will not be displayed without repainting.
+ !#en It can be cleared that need to ensure there is not use the CHAR cache in the current scene. Otherwise, the rendered text will not be displayed without repainting.
*/
- static clearCharCache(): void;
- }
+ static clearCharCache(): void;
+ }
/** !#en Outline effect used to change the display, only for system fonts or TTF fonts
!#zh 描边效果组件,用于字体描边,只能用于系统字体 */
- export class LabelOutline extends Component {
+ export class LabelOutline extends Component {
/** !#en outline color
!#zh 改变描边的颜色 */
- color: Color;
+ color: Color;
/** !#en Change the outline width
!#zh 改变描边的宽度 */
- width: number;
- }
+ width: number;
+ }
/** !#en Shadow effect for Label component, only for system fonts or TTF fonts
!#zh 用于给 Label 组件添加阴影效果,只能用于系统字体或 ttf 字体 */
- export class LabelShadow extends Component {
+ export class LabelShadow extends Component {
/** !#en The shadow color
!#zh 阴影的颜色 */
- color: Color;
+ color: Color;
/** !#en Offset between font and shadow
!#zh 字体与阴影的偏移 */
- offset: Vec2;
+ offset: Vec2;
/** !#en A non-negative float specifying the level of shadow blur
!#zh 阴影的模糊程度 */
- blur: number;
- }
+ blur: number;
+ }
/** !#en
The Layout is a container component, use it to arrange child elements easily.
Note:
@@ -8629,78 +8629,78 @@ declare namespace cc {
注意:
1.不会考虑子节点的缩放和旋转。
2.对 Layout 设置后结果需要到下一帧才会更新,除非你设置完以后手动调用 {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 */
- export class Layout extends Component {
+ export class Layout extends Component {
/** !#en The layout type.
!#zh 布局类型 */
- type: Layout.Type;
+ type: Layout.Type;
/** !#en
The are three resize modes for Layout.
None, resize Container and resize children.
!#zh 缩放模式 */
- resizeMode: Layout.ResizeMode;
+ resizeMode: Layout.ResizeMode;
/** !#en The cell size for grid layout.
!#zh 每个格子的大小,只有布局类型为 GRID 的时候才有效。 */
- cellSize: Size;
+ cellSize: Size;
/** !#en
The start axis for grid layout. If you choose horizontal, then children will layout horizontally at first,
and then break line on demand. Choose vertical if you want to layout vertically at first .
!#zh 起始轴方向类型,可进行水平和垂直布局排列,只有布局类型为 GRID 的时候才有效。 */
- startAxis: Layout.AxisDirection;
+ startAxis: Layout.AxisDirection;
/** !#en The left padding of layout, it only effect the layout in one direction.
!#zh 容器内左边距,只会在一个布局方向上生效。 */
- paddingLeft: number;
+ paddingLeft: number;
/** !#en The right padding of layout, it only effect the layout in one direction.
!#zh 容器内右边距,只会在一个布局方向上生效。 */
- paddingRight: number;
+ paddingRight: number;
/** !#en The top padding of layout, it only effect the layout in one direction.
!#zh 容器内上边距,只会在一个布局方向上生效。 */
- paddingTop: number;
+ paddingTop: number;
/** !#en The bottom padding of layout, it only effect the layout in one direction.
!#zh 容器内下边距,只会在一个布局方向上生效。 */
- paddingBottom: number;
+ paddingBottom: number;
/** !#en The distance in x-axis between each element in layout.
!#zh 子节点之间的水平间距。 */
- spacingX: number;
+ spacingX: number;
/** !#en The distance in y-axis between each element in layout.
!#zh 子节点之间的垂直间距。 */
- spacingY: number;
+ spacingY: number;
/** !#en
Only take effect in Vertical layout mode.
This option changes the start element's positioning.
!#zh 垂直排列子节点的方向。 */
- verticalDirection: Layout.VerticalDirection;
+ verticalDirection: Layout.VerticalDirection;
/** !#en
Only take effect in Horizontal layout mode.
This option changes the start element's positioning.
!#zh 水平排列子节点的方向。 */
- horizontalDirection: Layout.HorizontalDirection;
+ horizontalDirection: Layout.HorizontalDirection;
/** !#en Adjust the layout if the children scaled.
!#zh 子节点缩放比例是否影响布局。 */
- affectedByScale: boolean;
+ affectedByScale: boolean;
/**
!#en Perform the layout update
!#zh 立即执行更新布局
-
- @example
+
+ @example
```js
layout.type = cc.Layout.HORIZONTAL;
layout.node.addChild(childNode);
cc.log(childNode.x); // not yet changed
layout.updateLayout();
cc.log(childNode.x); // changed
- ```
+ ```
*/
- updateLayout(): void;
- }
+ updateLayout(): void;
+ }
/** !#en The Mask Component
!#zh 遮罩组件 */
- export class Mask extends RenderComponent {
+ export class Mask extends RenderComponent {
/** !#en The mask type.
!#zh 遮罩类型 */
- type: Mask.Type;
+ type: Mask.Type;
/** !#en The mask image
!#zh 遮罩所需要的贴图 */
- spriteFrame: SpriteFrame;
+ spriteFrame: SpriteFrame;
/** !#en
The alpha threshold.(Not supported Canvas Mode)
The content is drawn only where the stencil have pixel with alpha greater than the alphaThreshold.
@@ -8712,15 +8712,15 @@ declare namespace cc {
只有当模板的像素的 alpha 大于等于 alphaThreshold 时,才会绘制内容。
该数值 0 ~ 1 之间的浮点数,默认值为 0.1
当被设置为 1 时,会丢弃所有蒙版像素,所以不会显示任何内容 */
- alphaThreshold: number;
+ alphaThreshold: number;
/** !#en Reverse mask (Not supported Canvas Mode)
!#zh 反向遮罩(不支持 Canvas 模式) */
- inverted: boolean;
+ inverted: boolean;
/** TODO: remove segments, not supported by graphics
!#en The segements for ellipse mask.
!#zh 椭圆遮罩的曲线细分数 */
- segements: number;
- }
+ segements: number;
+ }
/** !#en
cc.MotionStreak manages a Ribbon based on it's motion in absolute space.
You construct it with a fadeTime, minimum segment size, texture path, texture
@@ -8730,60 +8730,60 @@ declare namespace cc {
length is the how many pixels the texture is stretched across. The texture
is vertically aligned along the streak segment.
!#zh 运动轨迹,用于游戏对象的运动轨迹上实现拖尾渐隐效果。 */
- export class MotionStreak extends Component implements BlendFunc {
+ export class MotionStreak extends Component implements BlendFunc {
/** !#en
!#zh 在编辑器模式下预览拖尾效果。 */
- preview: boolean;
+ preview: boolean;
/** !#en The fade time to fade.
!#zh 拖尾的渐隐时间,以秒为单位。 */
- fadeTime: number;
+ fadeTime: number;
/** !#en The minimum segment size.
!#zh 拖尾之间最小距离。 */
- minSeg: number;
+ minSeg: number;
/** !#en The stroke's width.
!#zh 拖尾的宽度。 */
- stroke: number;
+ stroke: number;
/** !#en The texture of the MotionStreak.
!#zh 拖尾的贴图。 */
- texture: Texture2D;
+ texture: Texture2D;
/** !#en The color of the MotionStreak.
!#zh 拖尾的颜色 */
- color: Color;
+ color: Color;
/** !#en The fast Mode.
!#zh 是否启用了快速模式。当启用快速模式,新的点会被更快地添加,但精度较低。 */
- fastMode: boolean;
+ fastMode: boolean;
/**
!#en Remove all living segments of the ribbon.
!#zh 删除当前所有的拖尾片段。
-
- @example
+
+ @example
```js
// Remove all living segments of the ribbon.
myMotionStreak.reset();
- ```
+ ```
*/
- reset(): void;
+ reset(): void;
/** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost.
!#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */
- srcBlendFactor: macro.BlendFactor;
+ srcBlendFactor: macro.BlendFactor;
/** !#en specify the destination Blend Factor.
!#zh 指定目标的混合模式 */
- dstBlendFactor: macro.BlendFactor;
- }
+ dstBlendFactor: macro.BlendFactor;
+ }
/** !#en The PageView control
!#zh 页面视图组件 */
- export class PageView extends ScrollView {
+ export class PageView extends ScrollView {
/** !#en Specify the size type of each page in PageView.
!#zh 页面视图中每个页面大小类型 */
- sizeMode: PageView.SizeMode;
+ sizeMode: PageView.SizeMode;
/** !#en The page view direction
!#zh 页面视图滚动类型 */
- direction: PageView.Direction;
+ direction: PageView.Direction;
/** !#en
The scroll threshold value, when drag exceeds this value,
release the next page will automatically scroll, less than the restore
!#zh 滚动临界值,默认单位百分比,当拖拽超出该数值时,松开会自动滚动下一页,小于时则还原。 */
- scrollThreshold: number;
+ scrollThreshold: number;
/** !#en
Auto page turning velocity threshold. When users swipe the PageView quickly,
it will calculate a velocity based on the scroll distance and time,
@@ -8792,416 +8792,416 @@ declare namespace cc {
快速滑动翻页临界值。
当用户快速滑动时,会根据滑动开始和结束的距离与时间计算出一个速度值,
该值与此临界值相比较,如果大于临界值,则进行自动翻页。 */
- autoPageTurningThreshold: number;
+ autoPageTurningThreshold: number;
/** !#en Change the PageTurning event timing of PageView.
!#zh 设置 PageView PageTurning 事件的发送时机。 */
- pageTurningEventTiming: number;
+ pageTurningEventTiming: number;
/** !#en The Page View Indicator
!#zh 页面视图指示器组件 */
- indicator: PageViewIndicator;
+ indicator: PageViewIndicator;
/** !#en The time required to turn over a page. unit: second
!#zh 每个页面翻页时所需时间。单位:秒 */
- pageTurningSpeed: number;
+ pageTurningSpeed: number;
/** !#en PageView events callback
!#zh 滚动视图的事件回调函数 */
- pageEvents: Component.EventHandler[];
+ pageEvents: Component.EventHandler[];
/**
!#en Returns current page index
- !#zh 返回当前页面索引
+ !#zh 返回当前页面索引
*/
- getCurrentPageIndex(): number;
+ getCurrentPageIndex(): number;
/**
!#en Set current page index
!#zh 设置当前页面索引
- @param index index
+ @param index index
*/
- setCurrentPageIndex(index: number): void;
+ setCurrentPageIndex(index: number): void;
/**
!#en Returns all pages of pageview
- !#zh 返回视图中的所有页面
+ !#zh 返回视图中的所有页面
*/
- getPages(): Node[];
+ getPages(): Node[];
/**
!#en At the end of the current page view to insert a new view
!#zh 在当前页面视图的尾部插入一个新视图
- @param page page
+ @param page page
*/
- addPage(page: Node): void;
+ addPage(page: Node): void;
/**
!#en Inserts a page in the specified location
!#zh 将页面插入指定位置中
@param page page
- @param index index
+ @param index index
*/
- insertPage(page: Node, index: number): void;
+ insertPage(page: Node, index: number): void;
/**
!#en Removes a page from PageView.
!#zh 移除指定页面
- @param page page
+ @param page page
*/
- removePage(page: Node): void;
+ removePage(page: Node): void;
/**
!#en Removes a page at index of PageView.
!#zh 移除指定下标的页面
- @param index index
+ @param index index
*/
- removePageAtIndex(index: number): void;
+ removePageAtIndex(index: number): void;
/**
!#en Removes all pages from PageView
- !#zh 移除所有页面
+ !#zh 移除所有页面
*/
- removeAllPages(): void;
+ removeAllPages(): void;
/**
!#en Scroll PageView to index.
!#zh 滚动到指定页面
@param idx index of page.
- @param timeInSecond scrolling time
+ @param timeInSecond scrolling time
*/
- scrollToPage(idx: number, timeInSecond: number): void;
- }
+ scrollToPage(idx: number, timeInSecond: number): void;
+ }
/** !#en The Page View Indicator Component
!#zh 页面视图每页标记组件 */
- export class PageViewIndicator extends Component {
+ export class PageViewIndicator extends Component {
/** !#en The spriteFrame for each element.
!#zh 每个页面标记显示的图片 */
- spriteFrame: SpriteFrame;
+ spriteFrame: SpriteFrame;
/** !#en The location direction of PageViewIndicator.
!#zh 页面标记摆放方向 */
- direction: PageViewIndicator.Direction;
+ direction: PageViewIndicator.Direction;
/** !#en The cellSize for each element.
!#zh 每个页面标记的大小 */
- cellSize: Size;
+ cellSize: Size;
/** !#en The distance between each element.
!#zh 每个页面标记之间的边距 */
- spacing: number;
+ spacing: number;
/**
!#en Set Page View
!#zh 设置页面视图
- @param target target
+ @param target target
*/
- setPageView(target: PageView): void;
- }
+ setPageView(target: PageView): void;
+ }
/** !#en
Visual indicator of progress in some operation.
Displays a bar to the user representing how far the operation has progressed.
!#zh
进度条组件,可用于显示加载资源时的进度。 */
- export class ProgressBar extends Component {
+ export class ProgressBar extends Component {
/** !#en The targeted Sprite which will be changed progressively.
!#zh 用来显示进度条比例的 Sprite 对象。 */
- barSprite: Sprite;
+ barSprite: Sprite;
/** !#en The progress mode, there are two modes supported now: horizontal and vertical.
!#zh 进度条的模式 */
- mode: ProgressBar.Mode;
+ mode: ProgressBar.Mode;
/** !#en The total width or height of the bar sprite.
!#zh 进度条实际的总长度 */
- totalLength: number;
+ totalLength: number;
/** !#en The current progress of the bar sprite. The valid value is between 0-1.
!#zh 当前进度值,该数值的区间是 0-1 之间。 */
- progress: number;
+ progress: number;
/** !#en Whether reverse the progress direction of the bar sprite.
!#zh 进度条是否进行反方向变化。 */
- reverse: boolean;
- }
+ reverse: boolean;
+ }
/** !#en
Base class for components which supports rendering features.
!#zh
所有支持渲染的组件的基类 */
- export class RenderComponent extends Component {
+ export class RenderComponent extends Component {
/** !#en The materials used by this render component.
!#zh 渲染组件使用的材质。 */
- sharedMaterials: Material[];
+ sharedMaterials: Material[];
/**
!#en Get the material by index.
!#zh 根据指定索引获取材质
- @param index index
+ @param index index
*/
- getMaterial(index: number): MaterialVariant;
+ getMaterial(index: number): MaterialVariant;
/**
!#en Gets all the materials.
- !#zh 获取所有材质。
+ !#zh 获取所有材质。
*/
- getMaterials(): MaterialVariant[];
+ getMaterials(): MaterialVariant[];
/**
!#en Set the material by index.
!#zh 根据指定索引设置材质
@param index index
- @param material material
+ @param material material
*/
- setMaterial(index: number, material: Material): Material;
- }
+ setMaterial(index: number, material: Material): Material;
+ }
/** !#en The RichText Component.
!#zh 富文本组件 */
- export class RichText extends Component {
+ export class RichText extends Component {
/** !#en Content string of RichText.
!#zh 富文本显示的文本内容。 */
- string: string;
+ string: string;
/** !#en Horizontal Alignment of each line in RichText.
!#zh 文本内容的水平对齐方式。 */
- horizontalAlign: macro.TextAlignment;
+ horizontalAlign: macro.TextAlignment;
/** !#en Font size of RichText.
!#zh 富文本字体大小。 */
- fontSize: number;
+ fontSize: number;
/** !#en Custom System font of RichText
!#zh 富文本定制系统字体 */
- fontFamily: string;
+ fontFamily: string;
/** !#en Custom TTF font of RichText
!#zh 富文本定制字体 */
- font: TTFFont;
+ font: TTFFont;
/** !#en Whether use system font name or not.
!#zh 是否使用系统字体。 */
- useSystemFont: boolean;
+ useSystemFont: boolean;
/** !#en The cache mode of label. This mode only supports system fonts.
!#zh 文本缓存模式, 该模式只支持系统字体。 */
- cacheMode: Label.CacheMode;
+ cacheMode: Label.CacheMode;
/** !#en The maximize width of the RichText
!#zh 富文本的最大宽度 */
- maxWidth: number;
+ maxWidth: number;
/** !#en Line Height of RichText.
!#zh 富文本行高。 */
- lineHeight: number;
+ lineHeight: number;
/** !#en The image atlas for the img tag. For each src value in the img tag, there should be a valid spriteFrame in the image atlas.
!#zh 对于 img 标签里面的 src 属性名称,都需要在 imageAtlas 里面找到一个有效的 spriteFrame,否则 img tag 会判定为无效。 */
- imageAtlas: SpriteAtlas;
+ imageAtlas: SpriteAtlas;
/** !#en
Once checked, the RichText will block all input events (mouse and touch) within
the bounding box of the node, preventing the input from penetrating into the underlying node.
!#zh
选中此选项后,RichText 将阻止节点边界框中的所有输入事件(鼠标和触摸),从而防止输入事件穿透到底层节点。 */
- handleTouchEvent: boolean;
- }
+ handleTouchEvent: boolean;
+ }
/** !#en
This component is used to adjust the layout of current node to respect the safe area of a notched mobile device such as the iPhone X.
It is typically used for the top node of the UI interaction area. For specific usage, refer to the official [example-cases/02_ui/16_safeArea/SafeArea.fire](https://github.com/cocos-creator/example-cases).
-
+
The concept of safe area is to give you a fixed inner rectangle in which you can safely display content that will be drawn on screen.
You are strongly discouraged from providing controls outside of this area. But your screen background could embellish edges.
-
+
This component internally uses the API `cc.sys.getSafeAreaRect();` to obtain the safe area of the current iOS or Android device,
and implements the adaptation by using the Widget component and set anchor.
-
+
!#zh
该组件会将所在节点的布局适配到 iPhone X 等异形屏手机的安全区域内,通常用于 UI 交互区域的顶层节点,具体用法可参考官方范例 [example-cases/02_ui/16_safeArea/SafeArea.fire](https://github.com/cocos-creator/example-cases)。
-
+
该组件内部通过 API `cc.sys.getSafeAreaRect();` 获取到当前 iOS 或 Android 设备的安全区域,并通过 Widget 组件实现适配。 */
- export class SafeArea extends Component {
+ export class SafeArea extends Component {
/**
!#en Adapt to safe area
!#zh 立即适配安全区域
-
- @example
+
+ @example
```js
let safeArea = this.node.addComponent(cc.SafeArea);
safeArea.updateArea();
- ```
+ ```
*/
- updateArea(): void;
- }
+ updateArea(): void;
+ }
/** !#en
The Scrollbar control allows the user to scroll an image or other view that is too large to see completely
!#zh 滚动条组件 */
- export class Scrollbar extends Component {
+ export class Scrollbar extends Component {
/** !#en The "handle" part of the scrollbar.
!#zh 作为当前滚动区域位置显示的滑块 Sprite。 */
- handle: Sprite;
+ handle: Sprite;
/** !#en The direction of scrollbar.
!#zh ScrollBar 的滚动方向。 */
- direction: Scrollbar.Direction;
+ direction: Scrollbar.Direction;
/** !#en Whether enable auto hide or not.
!#zh 是否在没有滚动动作时自动隐藏 ScrollBar。 */
- enableAutoHide: boolean;
+ enableAutoHide: boolean;
/** !#en
The time to hide scrollbar when scroll finished.
Note: This value is only useful when enableAutoHide is true.
!#zh
没有滚动动作后经过多久会自动隐藏。
注意:只要当 “enableAutoHide” 为 true 时,才有效。 */
- autoHideTime: number;
- }
+ autoHideTime: number;
+ }
/** !#en
Layout container for a view hierarchy that can be scrolled by the user,
allowing it to be larger than the physical display.
-
+
!#zh
滚动视图组件 */
- export class ScrollView extends Component {
+ export class ScrollView extends Component {
/** !#en This is a reference to the UI element to be scrolled.
!#zh 可滚动展示内容的节点。 */
- content: Node;
+ content: Node;
/** !#en Enable horizontal scroll.
!#zh 是否开启水平滚动。 */
- horizontal: boolean;
+ horizontal: boolean;
/** !#en Enable vertical scroll.
!#zh 是否开启垂直滚动。 */
- vertical: boolean;
+ vertical: boolean;
/** !#en When inertia is set, the content will continue to move when touch ended.
!#zh 是否开启滚动惯性。 */
- inertia: boolean;
+ inertia: boolean;
/** !#en
It determines how quickly the content stop moving. A value of 1 will stop the movement immediately.
A value of 0 will never stop the movement until it reaches to the boundary of scrollview.
!#zh
开启惯性后,在用户停止触摸后滚动多快停止,0表示永不停止,1表示立刻停止。 */
- brake: number;
+ brake: number;
/** !#en When elastic is set, the content will be bounce back when move out of boundary.
!#zh 是否允许滚动内容超过边界,并在停止触摸后回弹。 */
- elastic: boolean;
+ elastic: boolean;
/** !#en The elapse time of bouncing back. A value of 0 will bounce back immediately.
!#zh 回弹持续的时间,0 表示将立即反弹。 */
- bounceDuration: number;
+ bounceDuration: number;
/** !#en The horizontal scrollbar reference.
!#zh 水平滚动的 ScrollBar。 */
- horizontalScrollBar: Scrollbar;
+ horizontalScrollBar: Scrollbar;
/** !#en The vertical scrollbar reference.
!#zh 垂直滚动的 ScrollBar。 */
- verticalScrollBar: Scrollbar;
+ verticalScrollBar: Scrollbar;
/** !#en Scrollview events callback
!#zh 滚动视图的事件回调函数 */
- scrollEvents: Component.EventHandler[];
+ scrollEvents: Component.EventHandler[];
/** !#en If cancelInnerEvents is set to true, the scroll behavior will cancel touch events on inner content nodes
It's set to true by default.
!#zh 如果这个属性被设置为 true,那么滚动行为会取消子节点上注册的触摸事件,默认被设置为 true。
注意,子节点上的 touchstart 事件仍然会触发,触点移动距离非常短的情况下 touchmove 和 touchend 也不会受影响。 */
- cancelInnerEvents: boolean;
+ cancelInnerEvents: boolean;
/**
!#en Scroll the content to the bottom boundary of ScrollView.
!#zh 视图内容将在规定时间内滚动到视图底部。
@param timeInSecond Scroll time in second, if you don't pass timeInSecond,
the content will jump to the bottom boundary immediately.
@param attenuated Whether the scroll acceleration attenuated, default is true.
-
- @example
+
+ @example
```js
// Scroll to the bottom of the view.
scrollView.scrollToBottom(0.1);
- ```
+ ```
*/
- scrollToBottom(timeInSecond?: number, attenuated?: boolean): void;
+ scrollToBottom(timeInSecond?: number, attenuated?: boolean): void;
/**
!#en Scroll the content to the top boundary of ScrollView.
!#zh 视图内容将在规定时间内滚动到视图顶部。
@param timeInSecond Scroll time in second, if you don't pass timeInSecond,
the content will jump to the top boundary immediately.
@param attenuated Whether the scroll acceleration attenuated, default is true.
-
- @example
+
+ @example
```js
// Scroll to the top of the view.
scrollView.scrollToTop(0.1);
- ```
+ ```
*/
- scrollToTop(timeInSecond?: number, attenuated?: boolean): void;
+ scrollToTop(timeInSecond?: number, attenuated?: boolean): void;
/**
!#en Scroll the content to the left boundary of ScrollView.
!#zh 视图内容将在规定时间内滚动到视图左边。
@param timeInSecond Scroll time in second, if you don't pass timeInSecond,
the content will jump to the left boundary immediately.
@param attenuated Whether the scroll acceleration attenuated, default is true.
-
- @example
+
+ @example
```js
// Scroll to the left of the view.
scrollView.scrollToLeft(0.1);
- ```
+ ```
*/
- scrollToLeft(timeInSecond?: number, attenuated?: boolean): void;
+ scrollToLeft(timeInSecond?: number, attenuated?: boolean): void;
/**
!#en Scroll the content to the right boundary of ScrollView.
!#zh 视图内容将在规定时间内滚动到视图右边。
@param timeInSecond Scroll time in second, if you don't pass timeInSecond,
the content will jump to the right boundary immediately.
@param attenuated Whether the scroll acceleration attenuated, default is true.
-
- @example
+
+ @example
```js
// Scroll to the right of the view.
scrollView.scrollToRight(0.1);
- ```
+ ```
*/
- scrollToRight(timeInSecond?: number, attenuated?: boolean): void;
+ scrollToRight(timeInSecond?: number, attenuated?: boolean): void;
/**
!#en Scroll the content to the top left boundary of ScrollView.
!#zh 视图内容将在规定时间内滚动到视图左上角。
@param timeInSecond Scroll time in second, if you don't pass timeInSecond,
the content will jump to the top left boundary immediately.
@param attenuated Whether the scroll acceleration attenuated, default is true.
-
- @example
+
+ @example
```js
// Scroll to the upper left corner of the view.
scrollView.scrollToTopLeft(0.1);
- ```
+ ```
*/
- scrollToTopLeft(timeInSecond?: number, attenuated?: boolean): void;
+ scrollToTopLeft(timeInSecond?: number, attenuated?: boolean): void;
/**
!#en Scroll the content to the top right boundary of ScrollView.
!#zh 视图内容将在规定时间内滚动到视图右上角。
@param timeInSecond Scroll time in second, if you don't pass timeInSecond,
the content will jump to the top right boundary immediately.
@param attenuated Whether the scroll acceleration attenuated, default is true.
-
- @example
+
+ @example
```js
// Scroll to the top right corner of the view.
scrollView.scrollToTopRight(0.1);
- ```
+ ```
*/
- scrollToTopRight(timeInSecond?: number, attenuated?: boolean): void;
+ scrollToTopRight(timeInSecond?: number, attenuated?: boolean): void;
/**
!#en Scroll the content to the bottom left boundary of ScrollView.
!#zh 视图内容将在规定时间内滚动到视图左下角。
@param timeInSecond Scroll time in second, if you don't pass timeInSecond,
the content will jump to the bottom left boundary immediately.
@param attenuated Whether the scroll acceleration attenuated, default is true.
-
- @example
+
+ @example
```js
// Scroll to the lower left corner of the view.
scrollView.scrollToBottomLeft(0.1);
- ```
+ ```
*/
- scrollToBottomLeft(timeInSecond?: number, attenuated?: boolean): void;
+ scrollToBottomLeft(timeInSecond?: number, attenuated?: boolean): void;
/**
!#en Scroll the content to the bottom right boundary of ScrollView.
!#zh 视图内容将在规定时间内滚动到视图右下角。
@param timeInSecond Scroll time in second, if you don't pass timeInSecond,
the content will jump to the bottom right boundary immediately.
@param attenuated Whether the scroll acceleration attenuated, default is true.
-
- @example
+
+ @example
```js
// Scroll to the lower right corner of the view.
scrollView.scrollToBottomRight(0.1);
- ```
+ ```
*/
- scrollToBottomRight(timeInSecond?: number, attenuated?: boolean): void;
+ scrollToBottomRight(timeInSecond?: number, attenuated?: boolean): void;
/**
!#en Scroll with an offset related to the ScrollView's top left origin, if timeInSecond is omitted, then it will jump to the
- specific offset immediately.
+ specific offset immediately.
!#zh 视图内容在规定时间内将滚动到 ScrollView 相对左上角原点的偏移位置, 如果 timeInSecond参数不传,则立即滚动到指定偏移位置。
@param offset A Vec2, the value of which each axis between 0 and maxScrollOffset
@param timeInSecond Scroll time in second, if you don't pass timeInSecond,
the content will jump to the specific offset of ScrollView immediately.
@param attenuated Whether the scroll acceleration attenuated, default is true.
-
- @example
+
+ @example
```js
// Scroll to middle position in 0.1 second in x-axis
let maxScrollOffset = this.getMaxScrollOffset();
scrollView.scrollToOffset(cc.v2(maxScrollOffset.x / 2, 0), 0.1);
- ```
+ ```
*/
- scrollToOffset(offset: Vec2, timeInSecond?: number, attenuated?: boolean): void;
+ scrollToOffset(offset: Vec2, timeInSecond?: number, attenuated?: boolean): void;
/**
!#en Get the positive offset value corresponds to the content's top left boundary.
- !#zh 获取滚动视图相对于左上角原点的当前滚动偏移
+ !#zh 获取滚动视图相对于左上角原点的当前滚动偏移
*/
- getScrollOffset(): Vec2;
+ getScrollOffset(): Vec2;
/**
!#en Get the maximize available scroll offset
- !#zh 获取滚动视图最大可以滚动的偏移量
+ !#zh 获取滚动视图最大可以滚动的偏移量
*/
- getMaxScrollOffset(): Vec2;
+ getMaxScrollOffset(): Vec2;
/**
!#en Scroll the content to the horizontal percent position of ScrollView.
!#zh 视图内容在规定时间内将滚动到 ScrollView 水平方向的百分比位置上。
@@ -9209,14 +9209,14 @@ declare namespace cc {
@param timeInSecond Scroll time in second, if you don't pass timeInSecond,
the content will jump to the horizontal percent position of ScrollView immediately.
@param attenuated Whether the scroll acceleration attenuated, default is true.
-
- @example
+
+ @example
```js
// Scroll to middle position.
scrollView.scrollToBottomRight(0.5, 0.1);
- ```
+ ```
*/
- scrollToPercentHorizontal(percent: number, timeInSecond?: number, attenuated?: boolean): void;
+ scrollToPercentHorizontal(percent: number, timeInSecond?: number, attenuated?: boolean): void;
/**
!#en Scroll the content to the percent position of ScrollView in any direction.
!#zh 视图内容在规定时间内进行垂直方向和水平方向的滚动,并且滚动到指定百分比位置上。
@@ -9224,17 +9224,17 @@ declare namespace cc {
@param timeInSecond Scroll time in second, if you don't pass timeInSecond,
the content will jump to the percent position of ScrollView immediately.
@param attenuated Whether the scroll acceleration attenuated, default is true.
-
- @example
+
+ @example
```js
// Vertical scroll to the bottom of the view.
scrollView.scrollTo(cc.v2(0, 1), 0.1);
-
+
// Horizontal scroll to view right.
scrollView.scrollTo(cc.v2(1, 0), 0.1);
- ```
+ ```
*/
- scrollTo(anchor: Vec2, timeInSecond?: number, attenuated?: boolean): void;
+ scrollTo(anchor: Vec2, timeInSecond?: number, attenuated?: boolean): void;
/**
!#en Scroll the content to the vertical percent position of ScrollView.
!#zh 视图内容在规定时间内滚动到 ScrollView 垂直方向的百分比位置上。
@@ -9243,185 +9243,185 @@ declare namespace cc {
the content will jump to the vertical percent position of ScrollView immediately.
@param attenuated Whether the scroll acceleration attenuated, default is true.
// Scroll to middle position.
- scrollView.scrollToPercentVertical(0.5, 0.1);
+ scrollView.scrollToPercentVertical(0.5, 0.1);
*/
- scrollToPercentVertical(percent: number, timeInSecond?: number, attenuated?: boolean): void;
+ scrollToPercentVertical(percent: number, timeInSecond?: number, attenuated?: boolean): void;
/**
!#en Stop auto scroll immediately
- !#zh 停止自动滚动, 调用此 API 可以让 Scrollview 立即停止滚动
+ !#zh 停止自动滚动, 调用此 API 可以让 Scrollview 立即停止滚动
*/
- stopAutoScroll(): void;
+ stopAutoScroll(): void;
/**
!#en Modify the content position.
!#zh 设置当前视图内容的坐标点。
- @param position The position in content's parent space.
+ @param position The position in content's parent space.
*/
- setContentPosition(position: Vec2): void;
+ setContentPosition(position: Vec2): void;
/**
!#en Query the content's position in its parent space.
- !#zh 获取当前视图内容的坐标点。
+ !#zh 获取当前视图内容的坐标点。
*/
- getContentPosition(): Vec2;
+ getContentPosition(): Vec2;
/**
!#en Query whether the user is currently dragging the ScrollView to scroll it
- !#zh 用户是否在拖拽当前滚动视图
+ !#zh 用户是否在拖拽当前滚动视图
*/
- isScrolling(): boolean;
+ isScrolling(): boolean;
/**
!#en Query whether the ScrollView is currently scrolling because of a bounceback or inertia slowdown.
- !#zh 当前滚动视图是否在惯性滚动
+ !#zh 当前滚动视图是否在惯性滚动
*/
- isAutoScrolling(): boolean;
- }
+ isAutoScrolling(): boolean;
+ }
/** !#en The Slider Control
!#zh 滑动器组件 */
- export class Slider extends Component {
+ export class Slider extends Component {
/** !#en The "handle" part of the slider
!#zh 滑动器滑块按钮部件 */
- handle: Button;
+ handle: Button;
/** !#en The slider direction
!#zh 滑动器方向 */
- direction: Slider.Direction;
+ direction: Slider.Direction;
/** !#en The current progress of the slider. The valid value is between 0-1
!#zh 当前进度值,该数值的区间是 0-1 之间 */
- progress: number;
+ progress: number;
/** !#en The slider slide events' callback array
!#zh 滑动器组件滑动事件回调函数数组 */
- slideEvents: Component.EventHandler[];
- }
+ slideEvents: Component.EventHandler[];
+ }
/** !#en Renders a sprite in the scene.
!#zh 该组件用于在场景中渲染精灵。 */
- export class Sprite extends RenderComponent implements BlendFunc {
+ export class Sprite extends RenderComponent implements BlendFunc {
/** !#en The sprite frame of the sprite.
!#zh 精灵的精灵帧 */
- spriteFrame: SpriteFrame;
+ spriteFrame: SpriteFrame;
/** !#en The sprite render type.
!#zh 精灵渲染类型 */
- type: Sprite.Type;
+ type: Sprite.Type;
/** !#en
The fill type, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
!#zh
精灵填充类型,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */
- fillType: Sprite.FillType;
+ fillType: Sprite.FillType;
/** !#en
The fill Center, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
!#zh
填充中心点,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */
- fillCenter: Vec2;
+ fillCenter: Vec2;
/** !#en
The fill Start, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
!#zh
填充起始点,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */
- fillStart: number;
+ fillStart: number;
/** !#en
The fill Range, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
!#zh
填充范围,仅渲染类型设置为 cc.Sprite.Type.FILLED 时有效。 */
- fillRange: number;
+ fillRange: number;
/** !#en specify the frame is trimmed or not.
!#zh 是否使用裁剪模式 */
- trim: boolean;
+ trim: boolean;
/** !#en specify the size tracing mode.
!#zh 精灵尺寸调整模式 */
- sizeMode: Sprite.SizeMode;
+ sizeMode: Sprite.SizeMode;
/**
Change the state of sprite.
- @param state NORMAL or GRAY State.
+ @param state NORMAL or GRAY State.
*/
- setState(state: Sprite.State): void;
+ setState(state: Sprite.State): void;
/**
- Gets the current state.
+ Gets the current state.
*/
- getState(): Sprite.State;
+ getState(): Sprite.State;
/** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost.
!#zh 指定原图的混合模式,这会克隆一个新的材质对象,注意这带来的开销 */
- srcBlendFactor: macro.BlendFactor;
+ srcBlendFactor: macro.BlendFactor;
/** !#en specify the destination Blend Factor.
!#zh 指定目标的混合模式 */
- dstBlendFactor: macro.BlendFactor;
- }
+ dstBlendFactor: macro.BlendFactor;
+ }
/** !#en The toggle component is a CheckBox, when it used together with a ToggleGroup, it
could be treated as a RadioButton.
!#zh Toggle 是一个 CheckBox,当它和 ToggleGroup 一起使用的时候,可以变成 RadioButton。 */
- export class Toggle extends Button implements GraySpriteState {
+ export class Toggle extends Button implements GraySpriteState {
/** !#en When this value is true, the check mark component will be enabled, otherwise
the check mark component will be disabled.
!#zh 如果这个设置为 true,则 check mark 组件会处于 enabled 状态,否则处于 disabled 状态。 */
- isChecked: boolean;
+ isChecked: boolean;
/** !#en The toggle group which the toggle belongs to, when it is null, the toggle is a CheckBox.
Otherwise, the toggle is a RadioButton.
!#zh Toggle 所属的 ToggleGroup,这个属性是可选的。如果这个属性为 null,则 Toggle 是一个 CheckBox,
否则,Toggle 是一个 RadioButton。 */
- toggleGroup: ToggleGroup;
+ toggleGroup: ToggleGroup;
/** !#en The image used for the checkmark.
!#zh Toggle 处于选中状态时显示的图片 */
- checkMark: Sprite;
+ checkMark: Sprite;
/** !#en If Toggle is clicked, it will trigger event's handler
!#zh Toggle 按钮的点击事件列表。 */
- checkEvents: Component.EventHandler[];
+ checkEvents: Component.EventHandler[];
/**
!#en Make the toggle button checked.
- !#zh 使 toggle 按钮处于选中状态
+ !#zh 使 toggle 按钮处于选中状态
*/
- check(): void;
+ check(): void;
/**
!#en Make the toggle button unchecked.
- !#zh 使 toggle 按钮处于未选中状态
+ !#zh 使 toggle 按钮处于未选中状态
*/
- uncheck(): void;
+ uncheck(): void;
/** !#en The normal material.
!#zh 正常状态的材质。 */
- normalMaterial: Material;
+ normalMaterial: Material;
/** !#en The gray material.
!#zh 置灰状态的材质。 */
- grayMaterial: Material;
- }
+ grayMaterial: Material;
+ }
/** !#en ToggleContainer is not a visiable UI component but a way to modify the behavior of a set of Toggles.
Toggles that belong to the same group could only have one of them to be switched on at a time.
Note: All the first layer child node containing the toggle component will auto be added to the container
!#zh ToggleContainer 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。
当一组 Toggle 属于同一个 ToggleContainer 的时候,任何时候只能有一个 Toggle 处于选中状态。
注意:所有包含 Toggle 组件的一级子节点都会自动被添加到该容器中 */
- export class ToggleContainer extends Component {
+ export class ToggleContainer extends Component {
/** !#en If this setting is true, a toggle could be switched off and on when pressed.
If it is false, it will make sure there is always only one toggle could be switched on
and the already switched on toggle can't be switched off.
!#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */
- allowSwitchOff: boolean;
+ allowSwitchOff: boolean;
/** !#en If Toggle is clicked, it will trigger event's handler
!#zh Toggle 按钮的点击事件列表。 */
- checkEvents: Component.EventHandler[];
+ checkEvents: Component.EventHandler[];
/** !#en Read only property, return the toggle items array reference managed by ToggleContainer.
!#zh 只读属性,返回 ToggleContainer 管理的 toggle 数组引用 */
- toggleItems: Toggle[];
- }
+ toggleItems: Toggle[];
+ }
/** !#en ToggleGroup is not a visiable UI component but a way to modify the behavior of a set of Toggles.
Toggles that belong to the same group could only have one of them to be switched on at a time.
!#zh ToggleGroup 不是一个可见的 UI 组件,它可以用来修改一组 Toggle 组件的行为。当一组 Toggle 属于同一个 ToggleGroup 的时候,
任何时候只能有一个 Toggle 处于选中状态。 */
- export class ToggleGroup extends Component {
+ export class ToggleGroup extends Component {
/** !#en If this setting is true, a toggle could be switched off and on when pressed.
If it is false, it will make sure there is always only one toggle could be switched on
and the already switched on toggle can't be switched off.
!#zh 如果这个设置为 true, 那么 toggle 按钮在被点击的时候可以反复地被选中和未选中。 */
- allowSwitchOff: boolean;
+ allowSwitchOff: boolean;
/** !#en Read only property, return the toggle items array reference managed by toggleGroup.
!#zh 只读属性,返回 toggleGroup 管理的 toggle 数组引用 */
- toggleItems: any[];
- }
+ 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 {
- }
+ 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.
@@ -9429,108 +9429,108 @@ declare namespace cc {
!#zh
Widget 组件,用于设置和适配其相对于父节点的边距,Widget 通常被用于 UI 界面,也可以用于其他地方。
Widget 会自动调整当前节点的坐标和宽高,不过目前调整后的结果要到下一帧才能在脚本里获取到,除非你先手动调用 {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}}。 */
- export class Widget extends Component {
+ export class Widget extends Component {
/** !#en Specifies an alignment target that can only be one of the parent nodes of the current node.
The default value is null, and when null, indicates the current parent.
!#zh 指定一个对齐目标,只能是当前节点的其中一个父节点,默认为空,为空时表示当前父节点。 */
- target: Node;
+ target: Node;
/** !#en Whether to align the top.
!#zh 是否对齐上边。 */
- isAlignTop: boolean;
+ isAlignTop: boolean;
/** !#en
Vertically aligns the midpoint, This will open the other vertical alignment options cancel.
!#zh
是否垂直方向对齐中点,开启此项会将垂直方向其他对齐选项取消。 */
- isAlignVerticalCenter: boolean;
+ isAlignVerticalCenter: boolean;
/** !#en Whether to align the bottom.
!#zh 是否对齐下边。 */
- isAlignBottom: boolean;
+ isAlignBottom: boolean;
/** !#en Whether to align the left.
!#zh 是否对齐左边 */
- isAlignLeft: boolean;
+ isAlignLeft: boolean;
/** !#en
Horizontal aligns the midpoint. This will open the other horizontal alignment options canceled.
!#zh
是否水平方向对齐中点,开启此选项会将水平方向其他对齐选项取消。 */
- isAlignHorizontalCenter: boolean;
+ isAlignHorizontalCenter: boolean;
/** !#en Whether to align the right.
!#zh 是否对齐右边。 */
- isAlignRight: boolean;
+ isAlignRight: boolean;
/** !#en
Whether the stretched horizontally, when enable the left and right alignment will be stretched horizontally,
the width setting is invalid (read only).
!#zh
当前是否水平拉伸。当同时启用左右对齐时,节点将会被水平拉伸,此时节点的宽度只读。 */
- isStretchWidth: boolean;
+ isStretchWidth: boolean;
/** !#en
Whether the stretched vertically, when enable the left and right alignment will be stretched vertically,
then height setting is invalid (read only)
!#zh
当前是否垂直拉伸。当同时启用上下对齐时,节点将会被垂直拉伸,此时节点的高度只读。 */
- isStretchHeight: boolean;
+ isStretchHeight: boolean;
/** !#en
The margins between the top of this node and the top of parent node,
the value can be negative, Only available in 'isAlignTop' open.
!#zh
本节点顶边和父节点顶边的距离,可填写负值,只有在 isAlignTop 开启时才有作用。 */
- top: number;
+ top: number;
/** !#en
The margins between the bottom of this node and the bottom of parent node,
the value can be negative, Only available in 'isAlignBottom' open.
!#zh
本节点底边和父节点底边的距离,可填写负值,只有在 isAlignBottom 开启时才有作用。 */
- bottom: number;
+ bottom: number;
/** !#en
The margins between the left of this node and the left of parent node,
the value can be negative, Only available in 'isAlignLeft' open.
!#zh
本节点左边和父节点左边的距离,可填写负值,只有在 isAlignLeft 开启时才有作用。 */
- left: number;
+ left: number;
/** !#en
The margins between the right of this node and the right of parent node,
the value can be negative, Only available in 'isAlignRight' open.
!#zh
本节点右边和父节点右边的距离,可填写负值,只有在 isAlignRight 开启时才有作用。 */
- right: number;
+ right: number;
/** !#en
Horizontal aligns the midpoint offset value,
the value can be negative, Only available in 'isAlignHorizontalCenter' open.
!#zh 水平居中的偏移值,可填写负值,只有在 isAlignHorizontalCenter 开启时才有作用。 */
- horizontalCenter: number;
+ horizontalCenter: number;
/** !#en
Vertical aligns the midpoint offset value,
the value can be negative, Only available in 'isAlignVerticalCenter' open.
!#zh 垂直居中的偏移值,可填写负值,只有在 isAlignVerticalCenter 开启时才有作用。 */
- verticalCenter: number;
+ verticalCenter: number;
/** !#en If true, horizontalCenter is pixel margin, otherwise is percentage (0 - 1) margin.
!#zh 如果为 true,"horizontalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */
- isAbsoluteHorizontalCenter: boolean;
+ isAbsoluteHorizontalCenter: boolean;
/** !#en If true, verticalCenter is pixel margin, otherwise is percentage (0 - 1) margin.
!#zh 如果为 true,"verticalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。 */
- isAbsoluteVerticalCenter: boolean;
+ isAbsoluteVerticalCenter: boolean;
/** !#en
If true, top is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height.
!#zh
如果为 true,"top" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */
- isAbsoluteTop: boolean;
+ isAbsoluteTop: boolean;
/** !#en
If true, bottom is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height.
!#zh
如果为 true,"bottom" 将会以像素作为边距,否则将会以相对父物体高度的百分比(0 到 1)作为边距。 */
- isAbsoluteBottom: boolean;
+ isAbsoluteBottom: boolean;
/** !#en
If true, left is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width.
!#zh
如果为 true,"left" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */
- isAbsoluteLeft: boolean;
+ isAbsoluteLeft: boolean;
/** !#en
If true, right is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width.
!#zh
如果为 true,"right" 将会以像素作为边距,否则将会以相对父物体宽度的百分比(0 到 1)作为边距。 */
- isAbsoluteRight: boolean;
+ isAbsoluteRight: boolean;
/** !#en Specifies the alignment mode of the Widget, which determines when the widget should refresh.
!#zh 指定 Widget 的对齐模式,用于决定 Widget 应该何时刷新。 */
- alignMode: Widget.AlignMode;
+ alignMode: Widget.AlignMode;
/**
!#en
Immediately perform the widget alignment. You need to manually call this method only if
@@ -9538,16 +9538,16 @@ declare namespace cc {
!#zh
立刻执行 widget 对齐操作。这个接口一般不需要手工调用。
只有当你需要在当前帧结束前获得 widget 对齐后的最新结果时才需要手动调用这个方法。
-
- @example
+
+ @example
```js
widget.top = 10; // change top margin
cc.log(widget.node.y); // not yet changed
widget.updateAlignment();
cc.log(widget.node.y); // changed
- ```
+ ```
*/
- updateAlignment(): void;
+ updateAlignment(): void;
/** !#en
When turned on, it will only be aligned once at the end of the onEnable frame,
then immediately disables the current component.
@@ -9557,8 +9557,8 @@ declare namespace cc {
开启后仅会在 onEnable 的当帧结束时对齐一次,然后立刻禁用当前组件。
这样便于脚本或动画继续控制当前节点。
注意:onEnable 时所在的那一帧仍然会进行对齐。 */
- isAlignOnce: boolean;
- }
+ isAlignOnce: boolean;
+ }
/** !#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.
@@ -9577,32 +9577,32 @@ declare namespace cc {
3. 子域的分辨率也可以被放大,以便获得更清晰的显示效果
4. 用户输入坐标会被自动转换到正确的子域视窗中
5. 子域内容贴图的更新由组件负责,用户不需要处理
*/
- export class SubContextView extends Component {
+ export class SubContextView extends Component {
/**
!#en Reset open data context size and viewport
- !#zh 重置开放数据域的尺寸和视窗
+ !#zh 重置开放数据域的尺寸和视窗
*/
- reset(): void;
+ reset(): void;
/**
!#en Update the sub context viewport manually, it should be called whenever the node's bounding box changes.
- !#zh 更新开放数据域相对于主域的 viewport,这个函数应该在节点包围盒改变时手动调用。
+ !#zh 更新开放数据域相对于主域的 viewport,这个函数应该在节点包围盒改变时手动调用。
*/
- updateSubContextViewport(): void;
- }
+ updateSubContextViewport(): void;
+ }
/** !#en WXSubContextView is deprecated since v2.4.1, please use SubContextView instead.
!#zh 自 v2.4.1 起,WXSubContextView 已经废弃,请使用 SubContextView */
- export class WXSubContextView extends Component {
- }
+ export class WXSubContextView extends Component {
+ }
/** !#en SwanSubContextView is deprecated since v2.4.1, please use SubContextView instead.
!#zh 自 v2.4.1 起,SwanSubContextView 已经废弃,请使用 SubContextView */
- export class SwanSubContextView extends Component {
- }
+ export class SwanSubContextView extends Component {
+ }
/** !#en Mesh Asset.
!#zh 网格资源。 */
- export class Mesh extends Asset implements EventTarget {
+ export class Mesh extends Asset implements EventTarget {
/** !#en Get ir set the sub meshes.
!#zh 设置或者获取子网格。 */
- subMeshes: InputAssembler[];
+ subMeshes: InputAssembler[];
/**
!#en
Init vertex buffer according to the vertex format.
@@ -9611,18 +9611,18 @@ declare namespace cc {
@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
+ @param index index
*/
- init(vertexFormat: gfx.VertexFormat, vertexCount: number, dynamic?: boolean, index?: boolean): void;
+ 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
+ @param values the vertex values
*/
- setVertices(name: string, values: Vec2[]|Vec3[]|Color[]|number[]|Uint8Array|Float32Array): void;
+ setVertices(name: string, values: Vec2[] | Vec3[] | Color[] | number[] | Uint8Array | Float32Array): void;
/**
!#en
Set the sub mesh indices.
@@ -9630,32 +9630,32 @@ declare namespace cc {
设置子网格索引。
@param indices the sub mesh indices.
@param index sub mesh index.
- @param dynamic whether or not to use dynamic buffer.
+ @param dynamic whether or not to use dynamic buffer.
*/
- setIndices(indices: number[]|Uint16Array|Uint8Array, index?: number, dynamic?: boolean): void;
+ setIndices(indices: number[] | Uint16Array | Uint8Array, index?: number, dynamic?: boolean): void;
/**
!#en
Set the sub mesh primitive type.
!#zh
设置子网格绘制线条的方式。
@param type type
- @param index index
+ @param index index
*/
- setPrimitiveType(type: number, index: number): void;
+ setPrimitiveType(type: number, index: number): void;
/**
!#en
Clear the buffer data.
!#zh
- 清除网格创建的内存数据。
+ 清除网格创建的内存数据。
*/
- clear(): void;
+ clear(): void;
/**
!#en Set mesh bounding box
!#zh 设置网格的包围盒
@param min min
- @param max max
+ @param max max
*/
- setBoundingBox(min: Vec3, max: Vec3): void;
+ setBoundingBox(min: Vec3, max: Vec3): void;
/**
!#en Read the specified attributes of the subgrid into the target buffer.
!#zh 读取子网格的指定属性到目标缓冲区中。
@@ -9663,22 +9663,22 @@ declare namespace cc {
@param attributeName attribute name.
@param buffer The target buffer.
@param stride The byte interval between adjacent attributes in the target buffer.
- @param offset The offset of the first attribute in the target buffer.
+ @param offset The offset of the first attribute in the target buffer.
*/
- copyAttribute(primitiveIndex: number, attributeName: string, buffer: ArrayBuffer, stride: number, offset: number): boolean;
+ 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.
+ @param outputArray The target array.
*/
- copyIndices(primitiveIndex: number, outputArray: DataView): boolean;
+ 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.
+ @param type The type of event.
*/
- hasEventListener(type: string): boolean;
+ hasEventListener(type: string): boolean;
/**
!#en
Register an callback of a specific event type on the EventTarget.
@@ -9687,17 +9687,17 @@ declare namespace cc {
注册事件目标的特定事件类型回调。这种类型的事件应该被 `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).
+ 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
+
+ @example
```js
eventTarget.on('fire', function () {
- cc.log("fire in the hole");
+ cc.log("fire in the hole");
}, node);
- ```
+ ```
*/
- on
!#zh
AffineTransform 类代表一个仿射变换矩阵。它基本上是由平移旋转,缩放转变所组成。
*/
- export class AffineTransform {
+ export class AffineTransform {
/**
!#en Create a AffineTransform object with all contents in the matrix.
!#zh 用在矩阵中的所有内容创建一个 AffineTransform 对象。
@@ -10062,9 +10062,9 @@ declare namespace cc {
@param c c
@param d d
@param tx tx
- @param ty ty
+ @param ty ty
*/
- static create(a: number, b: number, c: number, d: number, tx: number, ty: number): AffineTransform;
+ static create(a: number, b: number, c: number, d: number, tx: number, ty: number): AffineTransform;
/**
!#en
Create a identity transformation matrix:
@@ -10073,15 +10073,15 @@ declare namespace cc {
!#zh
单位矩阵:
[ 1, 0, 0,
- 0, 1, 0 ]
+ 0, 1, 0 ]
*/
- static identity(): AffineTransform;
+ static identity(): AffineTransform;
/**
!#en Clone a AffineTransform object from the specified transform.
!#zh 克隆指定的 AffineTransform 对象。
- @param t t
+ @param t t
*/
- static clone(t: AffineTransform): AffineTransform;
+ static clone(t: AffineTransform): AffineTransform;
/**
!#en
Concatenate a transform matrix to another
@@ -10093,25 +10093,25 @@ declare namespace cc {
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.
+ @param t2 The transform object to concatenate.
*/
- static concat(out: AffineTransform, t1: AffineTransform, t2: AffineTransform): AffineTransform;
+ 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
+ @param t t
*/
- static invert(out: AffineTransform, t: AffineTransform): AffineTransform;
+ 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
+ @param mat mat
*/
- static invert(out: AffineTransform, mat: Mat4): AffineTransform;
+ 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.
@@ -10119,27 +10119,27 @@ declare namespace cc {
@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.
+ @param t transform matrix.
*/
- static transformVec2(out: Vec2, point: Vec2|number, transOrY: AffineTransform|number, t?: AffineTransform): Vec2;
+ 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
+ @param t t
*/
- static transformSize(out: Size, size: Size, t: AffineTransform): Size;
+ 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
+ @param anAffineTransform anAffineTransform
*/
- static transformRect(out: Rect, rect: Rect, anAffineTransform: AffineTransform): Rect;
+ 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.
@@ -10149,29 +10149,29 @@ declare namespace cc {
@param out_tr out_tr
@param out_br out_br
@param rect rect
- @param anAffineTransform anAffineTransform
+ @param anAffineTransform anAffineTransform
*/
- static transformObb(out_bl: Vec2, out_tl: Vec2, out_tr: Vec2, out_br: Vec2, rect: Rect, anAffineTransform: AffineTransform): void;
- }
+ 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 {
+ export class _BaseNode extends Object implements EventTarget {
/** !#en Name of node.
!#zh 该节点名称。 */
- name: string;
+ name: string;
/** !#en The uuid for editor, will be stripped before building project.
!#zh 主要用于编辑器的 uuid,在编辑器下可用于持久化存储,在项目构建之后将变成自增的 id。 */
- uuid: string;
+ uuid: string;
/** !#en All children nodes.
!#zh 节点的所有子节点。 */
- children: Node[];
+ children: Node[];
/** !#en All children nodes.
!#zh 节点的子节点数量。 */
- childrenCount: number;
+ 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.
@@ -10180,39 +10180,39 @@ declare namespace cc {
当前节点的自身激活状态。
值得注意的是,一个节点的父节点如果不被激活,那么即使它自身设为激活,它仍然无法激活。
如果你想检查节点在场景中实际的激活状态可以使用 {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}}。 */
- active: boolean;
+ active: boolean;
/** !#en Indicates whether this node is active in the scene.
!#zh 表示此节点是否在场景中激活。 */
- activeInHierarchy: boolean;
+ activeInHierarchy: boolean;
/**
-
- @param name name
+
+ @param name name
*/
- constructor(name?: string);
+ constructor(name?: string);
/** !#en The parent of the node.
!#zh 该节点的父节点。 */
- parent: Node;
+ parent: Node;
/**
!#en Get parent of the node.
!#zh 获取该节点的父节点。
-
- @example
+
+ @example
```js
var parent = this.node.getParent();
- ```
+ ```
*/
- getParent(): Node;
+ getParent(): Node;
/**
!#en Set parent of the node.
!#zh 设置该节点的父节点。
@param value value
-
- @example
+
+ @example
```js
node.setParent(newNode);
- ```
+ ```
*/
- setParent(value: Node): void;
+ setParent(value: Node): void;
/**
!#en
Properties configuration function
@@ -10221,36 +10221,36 @@ declare namespace cc {
the property will be set via setter function.
!#zh 属性配置函数。在 attrs 的所有属性将被设置为节点属性。
@param attrs Properties to be set to node
-
- @example
+
+ @example
```js
var attrs = { key: 0, num: 100 };
node.attr(attrs);
- ```
+ ```
*/
- attr(attrs: any): 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
+
+ @example
```js
var child = node.getChildByUuid(uuid);
- ```
+ ```
*/
- getChildByUuid(uuid: string): Node;
+ 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
+
+ @example
```js
var child = node.getChildByName("Test Node");
- ```
+ ```
*/
- getChildByName(name: string): Node;
+ getChildByName(name: string): Node;
/**
!#en
Inserts a child to the node at a specified index.
@@ -10258,34 +10258,34 @@ declare namespace cc {
插入子节点到指定位置
@param child the child node to be inserted
@param siblingIndex the sibling index to place the child in
-
- @example
+
+ @example
```js
node.insertChild(child, 2);
- ```
+ ```
*/
- insertChild(child: Node, siblingIndex: number): void;
+ insertChild(child: Node, siblingIndex: number): void;
/**
!#en Get the sibling index.
!#zh 获取同级索引。
-
- @example
+
+ @example
```js
var index = node.getSiblingIndex();
- ```
+ ```
*/
- getSiblingIndex(): number;
+ getSiblingIndex(): number;
/**
!#en Set the sibling index of this node.
!#zh 设置节点同级索引。
@param index index
-
- @example
+
+ @example
```js
node.setSiblingIndex(1);
- ```
+ ```
*/
- setSiblingIndex(index: number): void;
+ 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.
@@ -10297,17 +10297,17 @@ declare namespace cc {
请不要在 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
+
+ @example
```js
node.walk(function (target) {
- console.log('Walked through node ' + target.name + ' for the first time');
+ 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');
+ 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;
+ walk(prefunc: (target: _BaseNode) => void, postfunc: (target: _BaseNode) => void): void;
/**
!#en
Remove itself from its parent node. If cleanup is `true`, then also remove all events and actions.
@@ -10318,14 +10318,14 @@ declare namespace cc {
因此建议调用这个 API 时总是传入 `false` 参数。
如果这个节点是一个孤节点,那么什么都不会发生。
@param cleanup true if all actions and callbacks on this node should be removed, false otherwise.
-
- @example
+
+ @example
```js
node.removeFromParent();
node.removeFromParent(false);
- ```
+ ```
*/
- removeFromParent(cleanup?: boolean): void;
+ removeFromParent(cleanup?: boolean): void;
/**
!#en
Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter.
cc.game.containerStrategy class is the root strategy class of container's scale strategy, it controls the behavior of how to scale the cc.game.container and cc.game.canvas object
*/ - export class ContainerStrategy { + export class ContainerStrategy { /** !#en Manipulation before appling the strategy !#zh 在应用策略之前的操作 - @param view The target view + @param view The target view */ - preApply(view: View): void; + preApply(view: View): void; /** !#en Function to apply this strategy !#zh 策略应用方法 @param view view - @param designedResolution designedResolution + @param designedResolution designedResolution */ - apply(view: View, designedResolution: Size): void; + apply(view: View, designedResolution: Size): void; /** !#en Manipulation after applying the strategy !#zh 策略调用之后的操作 - @param view The target view + @param view The target view */ - postApply(view: View): void; - } + postApply(view: View): void; + } /**cc.ContentStrategy class is the root strategy class of content's scale strategy, it controls the behavior of how to scale the scene and setup the viewport for the game
*/ - export class ContentStrategy { + export class ContentStrategy { /** !#en Manipulation before applying the strategy !#zh 策略应用前的操作 - @param view The target view + @param view The target view */ - preApply(view: View): void; + preApply(view: View): void; /** !#en Function to apply this strategy The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}}, The target view can then apply these value to itself, it's preferred not to modify directly its private variables !#zh 调用策略方法 @param view view - @param designedResolution designedResolution + @param designedResolution designedResolution */ - apply(view: View, designedResolution: Size): any; + apply(view: View, designedResolution: Size): any; /** !#en Manipulation after applying the strategy !#zh 策略调用之后的操作 - @param view The target view + @param view The target view */ - postApply(view: View): void; - } + postApply(view: View): void; + } /** undefined */ - export class EqualToFrame extends ContainerStrategy { - } + export class EqualToFrame extends ContainerStrategy { + } /** undefined */ - export class ProportionalToFrame extends ContainerStrategy { - } + export class ProportionalToFrame extends ContainerStrategy { + } /** undefined */ - export class EqualToWindow extends EqualToFrame { - } + export class EqualToWindow extends EqualToFrame { + } /** undefined */ - export class ProportionalToWindow extends ProportionalToFrame { - } + export class ProportionalToWindow extends ProportionalToFrame { + } /** undefined */ - export class OriginalContainer extends ContainerStrategy { - } + export class OriginalContainer extends ContainerStrategy { + } /**cc.ResolutionPolicy class is the root strategy class of scale strategy, its main task is to maintain the compatibility with Cocos2d-x
*/ - export class ResolutionPolicy { + export class ResolutionPolicy { /** - + @param containerStg The container strategy - @param contentStg The content strategy + @param contentStg The content strategy */ - constructor(containerStg: ContainerStrategy, contentStg: ContentStrategy); + constructor(containerStg: ContainerStrategy, contentStg: ContentStrategy); /** !#en Manipulation before applying the resolution policy !#zh 策略应用前的操作 - @param view The target view + @param view The target view */ - preApply(view: View): void; + preApply(view: View): void; /** !#en Function to apply this resolution policy The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}}, The target view can then apply these value to itself, it's preferred not to modify directly its private variables !#zh 调用策略方法 @param view The target view - @param designedResolution The user defined design resolution + @param designedResolution The user defined design resolution */ - apply(view: View, designedResolution: Size): any; + apply(view: View, designedResolution: Size): any; /** !#en Manipulation after appyling the strategy !#zh 策略应用之后的操作 - @param view The target view + @param view The target view */ - postApply(view: View): void; + postApply(view: View): void; /** !#en Setup the container's scale strategy !#zh 设置容器的适配策略 - @param containerStg containerStg + @param containerStg containerStg */ - setContainerStrategy(containerStg: ContainerStrategy): void; + setContainerStrategy(containerStg: ContainerStrategy): void; /** !#en Setup the content's scale strategy !#zh 设置内容的适配策略 - @param contentStg contentStg + @param contentStg contentStg */ - setContentStrategy(contentStg: ContentStrategy): void; + setContentStrategy(contentStg: ContentStrategy): void; /** The entire application is visible in the specified area without trying to preserve the original aspect ratio.