demo/creator.d.ts

32074 lines
1.1 MiB
TypeScript
Raw Normal View History

2024-03-22 00:57:47 -07:00
/** !#en
The main namespace of Cocos2d-JS, all engine core classes, functions, properties and constants are defined in this namespace.
!#zh
Cocos */
declare namespace cc {
/** The current version of Cocos2d being used.<br/>
Please DO NOT remove this String, it is an important flag for bug tracking.<br/>
If you post a bug to forum, please attach this flag. */
export var ENGINE_VERSION: string;
/**
!#en
Creates the speed action which changes the speed of an action, making it take longer (speed > 1)
or less (speed < 1) time. <br/>
Useful to simulate 'slow motion' or 'fast forward' effect.
!#zh
@param action action
@param speed speed
@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;
/**
!#en Create a follow action which makes its target follows another node.
!#zh
@param followedNode followedNode
@param rect rect
@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;
/**
Points setter
@param points points
*/
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
```js
//create a cc.CardinalSplineTo
var action1 = cc.cardinalSplineTo(3, array, 0);
```
*/
export function cardinalSplineTo(duration: number, points: any[], tension: number): ActionInterval;
/**
update position of target
@param newPos newPos
*/
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
*/
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
```js
var action1 = cc.catmullRomTo(3, array);
```
*/
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
```js
var action1 = cc.catmullRomBy(3, array);
```
*/
export function catmullRomBy(dt: number, points: any[]): ActionInterval;
/**
!#en
Creates the action easing object with the rate parameter. <br />
From slow to fast.
!#zh easeIn
@param rate rate
@example
```js
action.easing(cc.easeIn(3.0));
```
*/
export function easeIn(rate: number): any;
/**
!#en
Creates the action easing object with the rate parameter. <br />
From fast to slow.
!#zh easeOut
@param rate rate
@example
```js
action.easing(cc.easeOut(3.0));
```
*/
export function easeOut(rate: number): any;
/**
!#en
Creates the action easing object with the rate parameter. <br />
Slow to fast then to slow.
!#zh easeInOut
@param rate rate
@example
```js
action.easing(cc.easeInOut(3.0));
```
*/
export function easeInOut(rate: number): any;
/**
!#en
Creates the action easing object with the rate parameter. <br />
Reference easeInExpo: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
easeExponentialIn <br />
EaseExponentialIn <br />
easeInExpohttp://www.zhihu.com/question/21981571/answer/19925418
@example
```js
action.easing(cc.easeExponentialIn());
```
*/
export function easeExponentialIn(): any;
/**
!#en
Creates the action easing object. <br />
Reference easeOutExpo: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
easeExponentialOut <br />
EaseExponentialOut 退<br />
easeOutExpohttp://www.zhihu.com/question/21981571/answer/19925418
@example
```js
action.easing(cc.easeExponentialOut());
```
*/
export function easeExponentialOut(): any;
/**
!#en
Creates an EaseExponentialInOut action easing object. <br />
Reference easeInOutExpo: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
easeExponentialInOut <br />
EaseExponentialInOut 退<br />
easeInOutExpohttp://www.zhihu.com/question/21981571/answer/19925418
@example
```js
action.easing(cc.easeExponentialInOut());
```
*/
export function easeExponentialInOut(): any;
/**
!#en
Creates an EaseSineIn action. <br />
Reference easeInSine: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
EaseSineIn <br />
EaseSineIn <br />
easeInSinehttp://www.zhihu.com/question/21981571/answer/19925418
@example
```js
action.easing(cc.easeSineIn());
```
*/
export function easeSineIn(): any;
/**
!#en
Creates an EaseSineOut action easing object. <br />
Reference easeOutSine: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
EaseSineOut <br />
EaseSineIn 退<br />
easeOutSinehttp://www.zhihu.com/question/21981571/answer/19925418
@example
```js
action.easing(cc.easeSineOut());
```
*/
export function easeSineOut(): any;
/**
!#en
Creates the action easing object. <br />
Reference easeInOutSine: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
easeSineInOut <br />
EaseSineIn 退<br />
easeInOutSinehttp://www.zhihu.com/question/21981571/answer/19925418
@example
```js
action.easing(cc.easeSineInOut());
```
*/
export function easeSineInOut(): any;
/**
!#en
Creates the action easing object with the period in radians (default is 0.3). <br />
Reference easeInElastic: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
easeElasticIn <br />
EaseElasticIn 线<br />
easeInElastichttp://www.zhihu.com/question/21981571/answer/19925418
@param period period
@example
```js
// example
action.easing(cc.easeElasticIn(3.0));
```
*/
export function easeElasticIn(period: number): any;
/**
!#en
Creates the action easing object with the period in radians (default is 0.3). <br />
Reference easeOutElastic: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
easeElasticOut <br />
EaseElasticOut 线退<br />
easeOutElastichttp://www.zhihu.com/question/21981571/answer/19925418
@param period period
@example
```js
// example
action.easing(cc.easeElasticOut(3.0));
```
*/
export function easeElasticOut(period: number): any;
/**
!#en
Creates the action easing object with the period in radians (default is 0.3). <br />
Reference easeInOutElastic: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
easeElasticInOut <br />
EaseElasticInOut 线退<br />
easeInOutElastichttp://www.zhihu.com/question/21981571/answer/19925418
@param period period
@example
```js
// example
action.easing(cc.easeElasticInOut(3.0));
```
*/
export function easeElasticInOut(period: number): any;
/**
!#en
Creates the action easing object. <br />
Eased bounce effect at the beginning.
!#zh
easeBounceIn <br />
EaseBounceIn
@example
```js
// example
action.easing(cc.easeBounceIn());
```
*/
export function easeBounceIn(): any;
/**
!#en
Creates the action easing object. <br />
Eased bounce effect at the ending.
!#zh
easeBounceOut <br />
EaseBounceOut 退
@example
```js
// example
action.easing(cc.easeBounceOut());
```
*/
export function easeBounceOut(): any;
/**
!#en
Creates the action easing object. <br />
Eased bounce effect at the begining and ending.
!#zh
easeBounceInOut <br />
EaseBounceInOut 退
@example
```js
// example
action.easing(cc.easeBounceInOut());
```
*/
export function easeBounceInOut(): any;
/**
!#en
Creates the action easing object. <br />
In the opposite direction to move slowly, and then accelerated to the right direction.
!#zh
easeBackIn <br />
easeBackIn <br />
@example
```js
// example
action.easing(cc.easeBackIn());
```
*/
export function easeBackIn(): any;
/**
!#en
Creates the action easing object. <br />
Fast moving more than the finish, and then slowly back to the finish.
!#zh
easeBackOut <br />
easeBackOut
@example
```js
// example
action.easing(cc.easeBackOut());
```
*/
export function easeBackOut(): any;
/**
!#en
Creates the action easing object. <br />
Begining of cc.EaseBackIn. Ending of cc.EaseBackOut.
!#zh
easeBackInOut <br />
@example
```js
// example
action.easing(cc.easeBackInOut());
```
*/
export function easeBackInOut(): any;
/**
!#en
Creates the action easing object. <br />
Into the 4 reference point. <br />
To calculate the motion curve.
!#zh
easeBezierAction <br />
EaseBezierAction 线
@param p0 The first bezier parameter
@param p1 The second bezier parameter
@param p2 The third bezier parameter
@param p3 The fourth bezier parameter
@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;
/**
!#en
Creates the action easing object. <br />
Reference easeInQuad: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
easeQuadraticActionIn <br />
EaseQuadraticIn<br />
easeInQuadhttp://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.easeQuadraticActionIn());
```
*/
export function easeQuadraticActionIn(): any;
/**
!#en
Creates the action easing object. <br />
Reference easeOutQuad: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
easeQuadraticActionOut <br />
EaseQuadraticOut 退<br />
easeOutQuadhttp://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.easeQuadraticActionOut());
```
*/
export function easeQuadraticActionOut(): any;
/**
!#en
Creates the action easing object. <br />
Reference easeInOutQuad: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
easeQuadraticActionInOut <br />
EaseQuadraticInOut 退<br />
easeInOutQuadhttp://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.easeQuadraticActionInOut());
```
*/
export function easeQuadraticActionInOut(): any;
/**
!#en
Creates the action easing object. <br />
Reference easeIntQuart: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
easeQuarticActionIn <br />
EaseQuarticIn <br />
easeIntQuarthttp://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.easeQuarticActionIn());
```
*/
export function easeQuarticActionIn(): any;
/**
!#en
Creates the action easing object. <br />
Reference easeOutQuart: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
easeQuarticActionOut <br />
EaseQuarticOut 退<br />
easeOutQuarthttp://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.QuarticActionOut());
```
*/
export function easeQuarticActionOut(): any;
/**
!#en
Creates the action easing object. <br />
Reference easeInOutQuart: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
easeQuarticActionInOut <br />
EaseQuarticInOut 退<br />
easeInOutQuarthttp://www.zhihu.com/question/21981571/answer/19925418
*/
export function easeQuarticActionInOut(): any;
/**
!#en
Creates the action easing object. <br />
Reference easeInQuint: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
easeQuinticActionIn <br />
EaseQuinticIn <br />
easeInQuinthttp://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.easeQuinticActionIn());
```
*/
export function easeQuinticActionIn(): any;
/**
!#en
Creates the action easing object. <br />
Reference easeOutQuint: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
easeQuinticActionOut <br />
EaseQuinticOut 退
easeOutQuinthttp://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.easeQuadraticActionOut());
```
*/
export function easeQuinticActionOut(): any;
/**
!#en
Creates the action easing object. <br />
Reference easeInOutQuint: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
easeQuinticActionInOut <br />
EaseQuinticInOut退<br />
easeInOutQuinthttp://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.easeQuinticActionInOut());
```
*/
export function easeQuinticActionInOut(): any;
/**
!#en
Creates the action easing object. <br />
Reference easeInCirc: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
easeCircleActionIn <br />
EaseCircleIn线<br />
easeInCirchttp://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.easeCircleActionIn());
```
*/
export function easeCircleActionIn(): any;
/**
!#en
Creates the action easing object. <br />
Reference easeOutCirc: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
easeCircleActionOut <br />
EaseCircleOut线退<br />
easeOutCirchttp://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
actioneasing(cc.easeCircleActionOut());
```
*/
export function easeCircleActionOut(): any;
/**
!#en
Creates the action easing object. <br />
Reference easeInOutCirc: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
easeCircleActionInOut <br />
EaseCircleInOut 线退<br />
easeInOutCirchttp://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.easeCircleActionInOut());
```
*/
export function easeCircleActionInOut(): any;
/**
!#en
Creates the action easing object. <br />
Reference easeInCubic: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
easeCubicActionIn <br />
EaseCubicIn <br />
easeInCubichttp://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.easeCubicActionIn());
```
*/
export function easeCubicActionIn(): any;
/**
!#en
Creates the action easing object. <br />
Reference easeOutCubic: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
easeCubicActionOut <br />
EaseCubicOut 退<br />
easeOutCubichttp://www.zhihu.com/question/21981571/answer/19925418
@example
```js
//example
action.easing(cc.easeCubicActionOut());
```
*/
export function easeCubicActionOut(): any;
/**
!#en
Creates the action easing object. <br />
Reference easeInOutCubic: <br />
http://www.zhihu.com/question/21981571/answer/19925418
!#zh
easeCubicActionInOut <br />
EaseCubicInOut退<br />
easeInOutCubichttp://www.zhihu.com/question/21981571/answer/19925418
*/
export function easeCubicActionInOut(): any;
/**
!#en Show the Node.
!#zh
@example
```js
// example
var showAction = cc.show();
```
*/
export function show(): ActionInstant;
/**
!#en Hide the node.
!#zh
@example
```js
// example
var hideAction = cc.hide();
```
*/
export function hide(): ActionInstant;
/**
!#en Toggles the visibility of a node.
!#zh
@example
```js
// example
var toggleVisibilityAction = cc.toggleVisibility();
```
*/
export function toggleVisibility(): ActionInstant;
/**
!#en Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing.
!#zh
@param isNeedCleanUp isNeedCleanUp
@example
```js
// example
var removeSelfAction = cc.removeSelf();
```
*/
export function removeSelf(isNeedCleanUp ?: boolean): ActionInstant;
/**
!#en Destroy self
!#zh
@example
```js
var destroySelfAction = cc.destroySelf();
```
*/
export function destroySelf(): ActionInstant;
/**
!#en Create a FlipX action to flip or unflip the target.
!#zh X
@param flip Indicate whether the target should be flipped or not
@example
```js
var flipXAction = cc.flipX(true);
```
*/
export function flipX(flip: boolean): ActionInstant;
/**
!#en Create a FlipY action to flip or unflip the target.
!#zh Y
@param flip flip
@example
```js
var flipYAction = cc.flipY(true);
```
*/
export function flipY(flip: boolean): ActionInstant;
/**
!#en Creates a Place action with a position.
!#zh
@param pos pos
@param y y
@example
```js
// example
var placeAction = cc.place(cc.v2(200, 200));
var placeAction = cc.place(200, 200);
```
*/
export function place(pos: Vec2|number, y?: number): ActionInstant;
/**
!#en Creates the action with the callback.
!#zh
@param selector selector
@param selectorTarget selectorTarget
@param data data for function, it accepts all data types.
@example
```js
// example
// CallFunc without data
var finish = cc.callFunc(this.removeSprite, this);
// CallFunc with data
var finish = cc.callFunc(this.removeFromParentAndCleanup, this._grossini, true);
```
*/
export function callFunc(selector: Function, selectorTarget?: any, data?: any): ActionInstant;
/**
!#en
Helper constructor to create an array of sequenceable actions
The created action will run actions sequentially, one after another.
!#zh
@param actionOrActionArray actionOrActionArray
@param tempArray tempArray
@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;
/**
!#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
```js
// example
var rep = cc.repeat(cc.sequence(jump2, jump1), 5);
```
*/
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
```js
// example
var repeat = cc.repeatForever(cc.rotateBy(1.0, 360));
```
*/
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
```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;
/**
!#en
Rotates a Node object to a certain angle by modifying its angle property. <br/>
The direction will be decided by the shortest angle.
!#zh angle
@param duration duration in seconds
@param dstAngle dstAngle in degrees.
@example
```js
// example
var rotateTo = cc.rotateTo(2, 61.0);
```
*/
export function rotateTo(duration: number, dstAngle: number): ActionInterval;
/**
!#en
Rotates a Node object clockwise a number of degrees by modifying its angle property.
Relative to its properties to modify.
!#zh
@param duration duration in seconds
@param deltaAngle deltaAngle in degrees
@example
```js
// example
var actionBy = cc.rotateBy(2, 360);
```
*/
export function rotateBy(duration: number, deltaAngle: number): ActionInterval;
/**
!#en
Moves a Node object x,y pixels by modifying its position property. <br/>
x and y are relative to the position of the object. <br/>
Several MoveBy actions can be concurrently called, and the resulting <br/>
movement will be the sum of individual movements.
!#zh
@param duration duration in seconds
@param deltaPos deltaPos
@param deltaY deltaY
@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;
/**
!#en
Moves a Node object to the position x,y. x and y are absolute coordinates by modifying its position property. <br/>
Several MoveTo actions can be concurrently called, and the resulting <br/>
movement will be the sum of individual movements.
!#zh
@param duration duration in seconds
@param position position
@param y y
@example
```js
// example
var actionBy = cc.moveTo(2, cc.v2(80, 80));
```
*/
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.
Changes to the specified value.
!#zh
@param t time in seconds
@param sx sx
@param sy sy
@example
```js
// example
var actionTo = cc.skewTo(2, 37.2, -37.2);
```
*/
export function skewTo(t: number, sx: number, sy: number): ActionInterval;
/**
!#en
Skews a Node object by skewX and skewY degrees. <br />
Relative to its property modification.
!#zh
@param t time in seconds
@param sx sx skew in degrees for X axis
@param sy sy skew in degrees for Y axis
@example
```js
// example
var actionBy = cc.skewBy(2, 0, -90);
```
*/
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.
Relative to its movement.
!#zh
@param duration duration
@param position position
@param y y
@param height height
@param jumps jumps
@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;
/**
!#en
Moves a Node object to a parabolic position simulating a jump movement by modifying its position property. <br />
Jump to the specified location.
!#zh
@param duration duration
@param position position
@param y y
@param height height
@param jumps jumps
@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;
/**
!#en
An action that moves the target with a cubic Bezier curve by a certain distance.
Relative to its movement.
!#zh 线
@param t time in seconds
@param c Array of points
@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;
/**
!#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
```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;
/**
!#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
```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;
/**
!#en
Scales a Node object a zoom factor by modifying it's scale property.
Relative to its changes.
!#zh
@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
```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;
/**
!#en Blinks a Node object by modifying it's visible property.
!#zh
@param duration duration in seconds
@param blinks blinks in times
@example
```js
// example
var action = cc.blink(2, 10);
```
*/
export function blink(duration: number, blinks: number): ActionInterval;
/**
!#en
Fades an object that implements the cc.RGBAProtocol protocol.
It modifies the opacity from the current value to a custom one.
!#zh
@param duration duration
@param opacity 0-255, 0 is transparent
@example
```js
// example
var action = cc.fadeTo(1.0, 0);
```
*/
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
```js
//example
var action = cc.fadeIn(1.0);
```
*/
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
```js
// example
var action = cc.fadeOut(1.0);
```
*/
export function fadeOut(d: number): ActionInterval;
/**
!#en Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one.
!#zh
@param duration duration
@param red 0-255
@param green 0-255
@param blue 0-255
@example
```js
// example
var action = cc.tintTo(2, 255, 0, 255);
```
*/
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.
Relative to their own color change.
!#zh
@param duration duration in seconds
@param deltaRed deltaRed
@param deltaGreen deltaGreen
@param deltaBlue deltaBlue
@example
```js
// example
var action = cc.tintBy(2, -127, -255, -127);
```
*/
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
```js
// example
var delay = cc.delayTime(1);
```
*/
export function delayTime(d: number): ActionInterval;
/**
!#en Executes an action in reverse order, from time=duration to time=0.
!#zh
@param action action
@example
```js
// example
var reverse = cc.reverseTime(this);
```
*/
export function reverseTime(action: FiniteTimeAction): ActionInterval;
/**
!#en Create an action with the specified action and forced target.
!#zh
@param target target
@param action action
*/
export function targetedAction(target: Node, action: FiniteTimeAction): ActionInterval;
/**
@param target the target to animate
*/
export function tween<T> (target?: T) : Tween<T>;
/** !#en This is a Easing instance.
!#zh Easing */
export var easing: Easing;
/**
!#en
Outputs an error message to the Cocos Creator Console (editor) or Web Console (runtime).<br/>
- In Cocos Creator, error is red.<br/>
- In Chrome, error have a red icon along with red message text.<br/>
!#zh
Cocos Creator Console Console <br/>
- Cocos Creator <br/>
- Chrome <br/>
@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.
*/
export function error(msg: any, ...subst: any[]): void;
/**
!#en
Outputs a warning message to the Cocos Creator Console (editor) or Web Console (runtime).
- In Cocos Creator, warning is yellow.
- In Chrome, warning have a yellow warning icon with the message text.
!#zh
Cocos Creator Console Web Console <br/>
- Cocos Creator <br/>
- Chrome <br/>
@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.
*/
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.
*/
export function log(msg: string|any, ...subst: any[]): void;
/** !#en Director
!#zh */
export var director: Director;
/** !#en This is a Game instance.
!#zh Game */
export var game: Game;
/**
!#en
Rotates a Node object to a certain angle by modifying its quternion property. <br/>
The direction will be decided by the shortest angle.
!#zh quternion
@param duration duration in seconds
@param dstAngleX dstAngleX in degrees.
@param dstAngleY dstAngleY in degrees.
@param dstAngleZ dstAngleZ in degrees.
@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;
/**
!#en
Rotates a Node object counter clockwise a number of degrees by modifying its quaternion property.
Relative to its properties to modify.
!#zh 3D
@param duration duration in seconds
@param deltaAngleX deltaAngleX in degrees
@param deltaAngleY deltaAngleY in degrees
@param deltaAngleZ deltaAngleZ in degrees
@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;
/** !#en
cc.resources is a bundle and controls all asset under assets/resources
!#zh
cc.resources bundle assets/resources */
export var resources: AssetManager.Bundle;
/** !#en The System event singleton for global usage
!#zh 便使 */
export var systemEvent: SystemEvent;
/**
Finds a node by hierarchy path, the path is case-sensitive.
It will traverse the hierarchy by splitting the path using '/' character.
This function will still returns the node even if it is inactive.
It is recommended to not use this function every frame instead cache the result at startup.
@param path path
@param referenceNode referenceNode
*/
export function find(path: string, referenceNode?: Node): Node;
/**
!#en Defines a CCClass using the given specification, please see [Class](/docs/editors_and_tools/creator-chapters/scripting/class.html) for details.
!#zh CCClass[](/docs/creator/scripting/class.html)
@param options options
@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,
getBounds: function (spriteList) {
// compute bounds...
}
},
properties {
width: {
default: 128,
type: cc.Integer,
tooltip: 'The width of sprite'
},
height: 128,
size: {
get: function () {
return cc.v2(this.width, this.height);
}
}
},
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;
/**
!#en
Define an enum type. <br/>
If a enum item has a value of -1, it will be given an Integer number according to it's order in the list.<br/>
Otherwise it will use the value specified by user who writes the enum definition.
!#zh
<br/>
-1 + 1
@param obj a JavaScript literal object containing enum names and values, or a TypeScript enum type
@example
```js
// JavaScript:
var WrapMode = cc.Enum({
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,
});
var AtlasSizeList = cc.Enum({
128: 128,
256: 256,
512: 512,
1024: 1024,
});
// TypeScript:
// If used in TypeScript, just define a TypeScript enum:
enum Direction {
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;
}
```
*/
export function Enum<T>(obj: T): T;
/**
@param touches touches
*/
export function handleTouchesBegin(touches: any[]): void;
/**
@param touches touches
*/
export function handleTouchesMove(touches: any[]): void;
/**
@param touches touches
*/
export function handleTouchesEnd(touches: any[]): void;
/**
@param touches touches
*/
export function handleTouchesCancel(touches: any[]): void;
/**
@param touches touches
*/
export function getSetOfTouchesEndOrCancel(touches: any[]): any[];
/**
@param touch touch
*/
export function getPreTouch(touch: Touch): Touch;
/**
@param touch touch
*/
export function setPreTouch(touch: Touch): void;
/**
@param tx tx
@param ty ty
@param pos pos
*/
export function getTouchByXY(tx: number, ty: number, pos: Vec2): Touch;
/**
@param location location
@param pos pos
@param eventType eventType
*/
export function getMouseEvent(location: Vec2, pos: Vec2, eventType: number): Event.EventMouse;
/**
@param event event
@param pos pos
*/
export function getPointByEvent(event: Touch, pos: Vec2): Vec2;
/**
@param event event
@param pos pos
*/
export function getTouchesByEvent(event: Touch, pos: Vec2): any[];
/**
@param element element
*/
export function registerSystemEvent(element: HTMLElement): void;
/**
@param dt dt
*/
export function update(dt: number): void;
/**
!#en
Checks whether the object is non-nil and not yet destroyed.<br>
When an object's `destroy` is called, it is actually destroyed after the end of this frame.
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 <br>
`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
```js
var node = new cc.Node();
cc.log(cc.isValid(node)); // true
node.destroy();
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;
/** !#en cc.view is the shared view object.
!#zh cc.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;
/** 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;
/** Indicates that the elements in array should be type double. */
export var Float: string;
/** Indicates that the elements in array should be type boolean. */
export var Boolean: string;
/** Indicates that the elements in array should be type 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
*/
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
```js
// instantiate node from prefab
var scene = cc.director.getScene();
var node = cc.instantiate(prefabAsset);
node.parent = scene;
// clone node
var scene = cc.director.getScene();
var node = cc.instantiate(targetNode);
node.parent = scene;
```
*/
export function instantiate(original: Prefab): Node;
export function instantiate<T>(original: T): T;
/**
!#en
The convenience method to create a new {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}}
Alpha channel is optional. Default value is 255.
!#zh
{{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}}
Alpha 255
@param r r
@param g g
@param b b
@param a a
@example
```js
-----------------------
// 1. All channels seperately as parameters
var color1 = new cc.Color(255, 255, 255, 255);
// 2. Convert a hex string to a color
var color2 = new cc.Color("#000000");
// 3. An color object as parameter
var color3 = new cc.Color({r: 255, g: 255, b: 255, a: 255});
```
*/
export function color(r?: number, g?: number, b?: number, a?: number): Color;
/**
!#en The convenience method to create a new {{#crossLink "Mat4"}}cc.Mat4{{/crossLink}}.
!#zh 便 {{#crossLink "Mat4"}}cc.Mat4{{/crossLink}}
@param m00 Component in column 0, row 0 position (index 0)
@param m01 Component in column 0, row 1 position (index 1)
@param m02 Component in column 0, row 2 position (index 2)
@param m03 Component in column 0, row 3 position (index 3)
@param m10 Component in column 1, row 0 position (index 4)
@param m11 Component in column 1, row 1 position (index 5)
@param m12 Component in column 1, row 2 position (index 6)
@param m13 Component in column 1, row 3 position (index 7)
@param m20 Component in column 2, row 0 position (index 8)
@param m21 Component in column 2, row 1 position (index 9)
@param m22 Component in column 2, row 2 position (index 10)
@param m23 Component in column 2, row 3 position (index 11)
@param m30 Component in column 3, row 0 position (index 12)
@param m31 Component in column 3, row 1 position (index 13)
@param m32 Component in column 3, row 2 position (index 14)
@param m33 Component in column 3, row 3 position (index 15)
*/
export function mat4(m00?: number, m01?: number, m02?: number, m03?: number, m10?: number, m11?: number, m12?: number, m13?: number, m20?: number, m21?: number, m22?: number, m23?: number, m30?: number, m31?: number, m32?: number, m33?: number): Mat4;
/**
!#en The convenience method to create a new {{#crossLink "Quat"}}cc.Quat{{/crossLink}}.
!#zh 便 {{#crossLink "Quat"}}cc.Quat{{/crossLink}}
@param x x
@param y y
@param z z
@param w w
*/
export function quat(x?: number|any, y?: number, z?: number, w?: number): Quat;
/**
!#en
The convenience method to create a new Rect.
see {{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}}
!#zh
{{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}}
@param x x
@param y y
@param w w
@param h h
@example
```js
var a = new cc.Rect(0 , 0, 10, 0);
```
*/
export function rect(x?: number, y?: number, w?: number, h?: number): Rect;
/**
!#en
Helper function that creates a cc.Size.<br/>
Please use cc.p or cc.v2 instead, it will soon replace cc.Size.
!#zh
cc.Size <br/>
使 cc.p cc.v2 cc.Size
@param w width or a size object
@param h height
@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;
/**
Clamps a value between a minimum float and maximum float value.
@param val val
@param min min
@param max max
*/
export function clamp(val: number, min: number, max: number): number;
/**
Clamps a value between 0 and 1.
@param val val
*/
export function clamp01(val: number): number;
/**
@param from from
@param to to
@param ratio the interpolation coefficient
*/
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
*/
export function randomRange(min: number, max: number): number;
/**
Returns a random integer between min (inclusive) and max (exclusive).
@param min min
@param max max
*/
export function randomRangeInt(min: number, max: number): number;
/**
Linear congruential generator using Hull-Dobell Theorem.
@param seed the random seed
*/
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
*/
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
*/
export function pseudoRandomRangeInt(seed: number, min: number, max: number): number;
/**
Returns the next power of two for the value
@param val val
*/
export function nextPow2(val: number): number;
/**
Returns float remainder for t / length
@param t time start at 0
@param length time of one cycle
*/
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
*/
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
*/
export function repeat(from: number, to: number, value: number): number;
/**
Returns -1, 0, +1 depending on sign of x.
@param v v
*/
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
```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;
/**
!#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
```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;
/** !#en The matrix storage */
export var matrix: any[];
/**
!#en Get an element
@param i i
@param j j
*/
export function get(i: number, j: number): number;
/**
!#en Set an element
@param i i
@param j j
@param value value
*/
export function set(i: number, j: number, value: boolean): void;
/**
!#en Sets all elements to zero
*/
export function reset(): void;
/** !#en Base class cc.Action for action classes.
!#zh Action */
export class Action {
/**
!#en
to copy object with deep copy.
returns a clone of action.
!#zh
*/
clone(): Action;
/**
!#en
return true if the action has finished.
!#zh true
*/
isDone(): boolean;
/**
!#en get the target.
!#zh
*/
getTarget(): Node;
/**
!#en The action will modify the target properties.
!#zh
@param target target
*/
setTarget(target: Node): void;
/**
!#en get the original target.
!#zh
*/
getOriginalTarget(): Node;
/**
!#en get tag number.
!#zh
*/
getTag(): number;
/**
!#en set tag number.
!#zh
@param tag tag
*/
setTag(tag: number): void;
/** !#en Default Action tag.
!#zh */
static TAG_INVALID: number;
}
/** !#en
Base class actions that do have a finite time duration. <br/>
Possible actions: <br/>
- An action with a duration of 0 seconds. <br/>
- An action with a duration of 35.5 seconds.
Infinite time actions are valid
!#zh duration */
export class FiniteTimeAction extends Action {
/**
!#en get duration of the action. (seconds).
!#zh
*/
getDuration(): number;
/**
!#en set duration of the action. (seconds).
!#zh
@param duration duration
*/
setDuration(duration: number): void;
/**
!#en
Returns a reversed action. <br />
For example: <br />
- The action will be x coordinates of 0 move to 100. <br />
- The reversed action will be x of 100 move to 0.
- Will be rewritten
!#zh
*/
reverse(): void;
/**
!#en
to copy object with deep copy.
returns a clone of action.
!#zh
*/
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 {
}
/** !#en
<p> An interval action is an action that takes place within a certain period of time. <br/>
It has an start time, and a finish time. The finish time is the parameter<br/>
duration plus the start time.</p>
<p>These CCActionInterval actions have some interesting properties, like:<br/>
- They can run normally (default) <br/>
- They can run reversed with the reverse method <br/>
- They can run with the time altered with the Accelerate, AccelDeccel and Speed actions. </p>
<p>For example, you can simulate a Ping Pong effect running the action normally and<br/>
then running it again in Reverse mode. </p>
!#zh FiniteTimeAction */
export class ActionInterval extends FiniteTimeAction {
/**
!#en Implementation of ease motion.
!#zh
@param easeObj easeObj
@example
```js
action.easing(cc.easeIn(3.0));
```
*/
easing(easeObj: any): ActionInterval;
/**
!#en
Repeats an action a number of times.
To repeat an action forever use the CCRepeatForever action.
!#zh 使 RepeatForever
@param times times
*/
repeat(times: number): ActionInterval;
/**
!#en
Repeats an action for ever. <br/>
To repeat the an action for a limited number of times use the Repeat action. <br/>
!#zh 使 Repeat
*/
repeatForever(): ActionInterval;
}
/** !#en
cc.ActionManager is a class that can manage actions.<br/>
Normally you won't need to use this class directly. 99% of the cases you will use the CCNode interface,
which uses this class's singleton object.
But there are some cases where you might need to use this class. <br/>
Examples:<br/>
- When you want to run an action where the target is different from a CCNode.<br/>
- When you want to pause / resume the actions<br/>
!#zh
cc.ActionManager <br/>
使99%使 CCNode <br/>
使 <br/>
- CCNode <br/>
- / <br/> */
export class ActionManager {
/**
!#en
Adds an action with a target.<br/>
If the target is already present, then the action will be added to the existing target.
If the target is not present, a new instance of this target will be created either paused or not, and the action will be added to the newly created target.
When the target is paused, the queued actions won't be 'ticked'.
!#zh
<br/>
<br/>
<br/>
paused true
@param action action
@param target target
@param paused paused
*/
addAction(action: Action, target: Node, paused: boolean): void;
/**
!#en Removes all actions from all the targets.
!#zh
*/
removeAllActions(): void;
/**
!#en
Removes all actions from a certain target. <br/>
All the actions that belongs to the target will be removed.
!#zh
<br/>
@param target target
@param forceDelete forceDelete
*/
removeAllActionsFromTarget(target: Node, forceDelete: boolean): void;
/**
!#en Removes an action given an action reference.
!#zh
@param action action
*/
removeAction(action: Action): void;
/**
!#en Removes an action given its tag and the target.
!#zh
@param tag tag
@param target target
*/
removeActionByTag(tag: number, target?: Node): void;
/**
!#en Gets an action given its tag an a target.
!#zh
@param tag tag
@param target target
*/
getActionByTag(tag: number, target: Node): Action;
/**
!#en
Returns the numbers of actions that are running in a certain target. <br/>
Composable actions are counted as 1 action. <br/>
Example: <br/>
- If you are running 1 Sequence of 7 actions, it will return 1. <br/>
- If you are running 7 Sequences of 2 actions, it will return 7.
!#zh
<br/>
<br/>
<br/>
- 7 Sequence 1<br/>
- 2 Sequence 5 7<br/>
@param target target
*/
getNumberOfRunningActionsInTarget(target: Node): number;
/**
!#en Pauses the target: all running actions and newly added actions will be paused.
!#zh
@param target target
*/
pauseTarget(target: Node): void;
/**
!#en Resumes the target. All queued actions will be resumed.
!#zh
@param target target
*/
resumeTarget(target: Node): void;
/**
!#en Pauses all running actions, returning a list of targets whose actions were paused.
!#zh
*/
pauseAllRunningActions(): any[];
/**
!#en Resume a set of targets (convenience function to reverse a pauseAllRunningActions or pauseTargets call).
!#zh pauseAllRunningActions 便
@param targetsToResume targetsToResume
*/
resumeTargets(targetsToResume: any[]): void;
/**
!#en Pause a set of targets.
!#zh
@param targetsToPause targetsToPause
*/
pauseTargets(targetsToPause: any[]): void;
/**
!#en
purges the shared action manager. It releases the retained instance. <br/>
because it uses this, so it can not be static.
!#zh
<br/>
使 this
*/
purgeSharedManager(): void;
/**
!#en The ActionManager update
!#zh ActionManager
@param dt delta time in seconds
*/
update(dt: number): void;
}
/** !#en
Tween provide a simple and flexible way to create action. Tween's api is more flexible than `cc.Action`:
- Support creating an action sequence in chained api.
- Support animate any objects' any properties, not limited to node's properties. By contrast, `cc.Action` needs to create a new action class to support new node property.
- Support working with `cc.Action`.
- Support easing and progress function.
!#zh
Tween action Cocos `cc.Action``cc.Tween`
-
- `cc.Action` action
- `cc.Action`
- {{#crossLink "Easing"}}{{/crossLink}} 或者 progress 函数。 */
export class Tween<T = any> {
/**
@param target target
*/
constructor(target?: any);
/**
!#en Stop all tweens
!#zh
*/
static stopAll(): void;
/**
!#en Stop all tweens by tag
!#zh
@param tag tag
*/
static stopAllByTag(tag: number): void;
/**
!#en Stop all tweens by target
!#zh
@param target target
*/
static stopAllByTarget(target: any): void;
/**
!#en
Insert an action or tween to this sequence
!#zh
action tween
@param other other
*/
then(other: Action|Tween<T>): Tween<T>;
/**
!#en
Set tween target
!#zh
tween target
@param target target
*/
target(target: any): Tween<T>;
/**
!#en
Start this tween
!#zh
tween
*/
start(): Tween<T>;
/**
!#en
Stop this tween
!#zh
tween
*/
stop(): Tween<T>;
/**
!#en Sets tween tag
!#zh
@param tag tag
*/
tag(tag: number): Tween<T>;
/**
!#en
Clone a tween
!#zh
tween
@param target target
*/
clone(target?: any): Tween<T>;
/**
!#en
Integrate all previous actions to an action.
!#zh
action action
*/
union(): Tween;
/**
!#en Sets target's position property according to the bezier curve.
!#zh position
@param duration duration
@param c1 c1
@param c2 c2
@param to to
*/
bezierTo(duration: number, c1: Vec2, c2: Vec2, to: Vec2): Tween<T>;
/**
!#en Sets target's position property according to the bezier curve.
!#zh position
@param duration duration
@param c1 c1
@param c2 c2
@param to to
*/
bezierBy(duration: number, c1: Vec2, c2: Vec2, to: Vec2): Tween<T>;
/**
!#en Flips target's scaleX
!#zh scaleX
*/
flipX(): Tween<T>;
/**
!#en Flips target's scaleY
!#zh scaleY
*/
flipY(): Tween<T>;
/**
!#en Blinks target by set target's opacity property
!#zh opacity
@param duration duration
@param times times
@param opts opts
*/
blink(duration: number, times: number, opts?: {progress?: Function; easing?: Function|string; }): Tween<T>;
/**
!#en
Add an action which calculate with absolute value
!#zh
action
@param duration duration
@param props {scale: 2, position: cc.v3(100, 100, 100)}
@param opts opts
*/
to <OPTS extends Partial<{progress: Function, easing: Function|String}>> (duration: number, props: ConstructorType<T>, opts?: OPTS) : Tween<T>;
/**
!#en
Add an action which calculate with relative value
!#zh
action
@param duration duration
@param props {scale: 2, position: cc.v3(100, 100, 100)}
@param opts opts
*/
by <OPTS extends Partial<{progress: Function, easing: Function|String}>> (duration: number, props: ConstructorType<T>, opts?: OPTS) : Tween<T>;
/**
!#en
Directly set target properties
!#zh
target
@param props props
*/
set (props: ConstructorType<T>) : Tween<T>;
/**
!#en
Add an delay action
!#zh
action
@param duration duration
*/
delay(duration: number): Tween<T>;
/**
!#en
Add an callback action
!#zh
action
@param callback callback
@param selectTarget selectTarget
*/
call(callback: Function, selectTarget?: object): Tween<T>;
/**
!#en
Add an hide action
!#zh
action
*/
hide(): Tween<T>;
/**
!#en
Add an show action
!#zh
action
*/
show(): Tween<T>;
/**
!#en
Add an removeSelf action
!#zh
action
*/
removeSelf(): Tween<T>;
/**
!#en
Add an sequence action
!#zh
action
@param action action
@param actions actions
*/
sequence(action: Action|Tween<T>, ...actions: (Action|Tween<T>)[]): Tween<T>;
/**
!#en
Add an parallel action
!#zh
action
@param action action
@param actions actions
*/
parallel(action: Action|Tween<T>, ...actions: (Action|Tween<T>)[]): Tween<T>;
/**
!#en
Add an repeat action. This action will integrate before actions to a sequence action as their parameters.
!#zh
action action
@param repeatTimes repeatTimes
@param action action
*/
repeat(repeatTimes: number, action?: Action|Tween<T>): Tween<T>;
/**
!#en
Add an repeat forever action. This action will integrate before actions to a sequence action as their parameters.
!#zh
action action
@param action action
*/
repeatForever(action?: Action|Tween<T>): Tween<T>;
/**
!#en
Add an reverse time action. This action will integrate before actions to a sequence action as their parameters.
!#zh
action action
@param action action
*/
reverseTime(action?: Action|Tween<T>): Tween<T>;
}
/** !#en `cc.audioEngine` is the singleton object, it provide simple audio APIs.
!#zh
cc.audioengine<br/>
audioID audioID <br/>
使使 `cc.audioEngine.uncache(filePath);` <br/>
<br/>
Android <br/>
WebAudio */
export class audioEngine {
/**
!#en Play audio.
!#zh
@param clip The audio clip to play.
@param loop Whether the music loop or not.
@param volume Volume size.
@example
```js
cc.resources.load(path, cc.AudioClip, null, function (err, clip) {
var audioID = cc.audioEngine.play(clip, false, 0.5);
});
```
*/
static play(clip: AudioClip, loop: boolean, volume: number): number;
/**
!#en Set audio loop.
!#zh
@param audioID audio id.
@param loop Whether cycle.
@example
```js
cc.audioEngine.setLoop(id, true);
```
*/
static setLoop(audioID: number, loop: boolean): void;
/**
!#en Get audio cycle state.
!#zh
@param audioID audio id.
@example
```js
cc.audioEngine.isLoop(id);
```
*/
static isLoop(audioID: number): boolean;
/**
!#en Set the volume of audio.
!#zh 0.0 ~ 1.0
@param audioID audio id.
@param volume Volume must be in 0.0~1.0 .
@example
```js
cc.audioEngine.setVolume(id, 0.5);
```
*/
static setVolume(audioID: number, volume: number): void;
/**
!#en The volume of the music max value is 1.0,the min value is 0.0 .
!#zh 0.0 ~ 1.0
@param audioID audio id.
@example
```js
var volume = cc.audioEngine.getVolume(id);
```
*/
static getVolume(audioID: number): number;
/**
!#en Set current time
!#zh
@param audioID audio id.
@param sec current time.
@example
```js
cc.audioEngine.setCurrentTime(id, 2);
```
*/
static setCurrentTime(audioID: number, sec: number): boolean;
/**
!#en Get current time
!#zh
@param audioID audio id.
@example
```js
var time = cc.audioEngine.getCurrentTime(id);
```
*/
static getCurrentTime(audioID: number): number;
/**
!#en Get audio duration
!#zh
@param audioID audio id.
@example
```js
var time = cc.audioEngine.getDuration(id);
```
*/
static getDuration(audioID: number): number;
/**
!#en Get audio state
!#zh
@param audioID audio id.
@example
```js
var state = cc.audioEngine.getState(id);
```
*/
static getState(audioID: number): audioEngine.AudioState;
/**
!#en Set Audio finish callback
!#zh
@param audioID audio id.
@param callback loaded callback.
@example
```js
cc.audioEngine.setFinishCallback(id, function () {});
```
*/
static setFinishCallback(audioID: number, callback: Function): void;
/**
!#en Pause playing audio.
!#zh
@param audioID The return value of function play.
@example
```js
cc.audioEngine.pause(audioID);
```
*/
static pause(audioID: number): void;
/**
!#en Pause all playing audio
!#zh
@example
```js
cc.audioEngine.pauseAll();
```
*/
static pauseAll(): void;
/**
!#en Resume playing audio.
!#zh
@param audioID The return value of function play.
@example
```js
cc.audioEngine.resume(audioID);
```
*/
static resume(audioID: number): void;
/**
!#en Resume all playing audio.
!#zh
@example
```js
cc.audioEngine.resumeAll();
```
*/
static resumeAll(): void;
/**
!#en Stop playing audio.
!#zh
@param audioID The return value of function play.
@example
```js
cc.audioEngine.stop(audioID);
```
*/
static stop(audioID: number): void;
/**
!#en Stop all playing audio.
!#zh
@example
```js
cc.audioEngine.stopAll();
```
*/
static stopAll(): void;
/**
!#en Set up an audio can generate a few examples.
!#zh
@param num a number of instances to be created from within an audio
@example
```js
cc.audioEngine.setMaxAudioInstance(20);
```
*/
static setMaxAudioInstance(num: number): void;
/**
!#en Getting audio can produce several examples.
!#zh
@example
```js
cc.audioEngine.getMaxAudioInstance();
```
*/
static getMaxAudioInstance(): number;
/**
!#en Unload the preloaded audio from internal buffer.
!#zh
@param clip clip
@example
```js
cc.audioEngine.uncache(filePath);
```
*/
static uncache(clip: AudioClip): void;
/**
!#en Unload all audio from internal buffer.
!#zh
@example
```js
cc.audioEngine.uncacheAll();
```
*/
static uncacheAll(): void;
/**
!#en Play background music
!#zh
@param clip The audio clip to play.
@param loop Whether the music loop or not.
@example
```js
cc.resources.load(path, cc.AudioClip, null, function (err, clip) {
var audioID = cc.audioEngine.playMusic(clip, false);
});
```
*/
static playMusic(clip: AudioClip, loop: boolean): number;
/**
!#en Stop background music.
!#zh
@example
```js
cc.audioEngine.stopMusic();
```
*/
static stopMusic(): void;
/**
!#en Pause the background music.
!#zh
@example
```js
cc.audioEngine.pauseMusic();
```
*/
static pauseMusic(): void;
/**
!#en Resume playing background music.
!#zh
@example
```js
cc.audioEngine.resumeMusic();
```
*/
static resumeMusic(): void;
/**
!#en Get the volume(0.0 ~ 1.0).
!#zh 0.0 ~ 1.0
@example
```js
var volume = cc.audioEngine.getMusicVolume();
```
*/
static getMusicVolume(): number;
/**
!#en Set the background music volume.
!#zh 0.0 ~ 1.0
@param volume Volume must be in 0.0~1.0.
@example
```js
cc.audioEngine.setMusicVolume(0.5);
```
*/
static setMusicVolume(volume: number): void;
/**
!#en Background music playing state
!#zh
@example
```js
cc.audioEngine.isMusicPlaying();
```
*/
static isMusicPlaying(): boolean;
/**
!#en Play effect audio.
!#zh
@param clip The audio clip to play.
@param loop Whether the music loop or not.
@example
```js
cc.resources.load(path, cc.AudioClip, null, function (err, clip) {
var audioID = cc.audioEngine.playEffect(clip, false);
});
```
*/
static playEffect(clip: AudioClip, loop: boolean): number;
/**
!#en Set the volume of effect audio.
!#zh 0.0 ~ 1.0
@param volume Volume must be in 0.0~1.0.
@example
```js
cc.audioEngine.setEffectsVolume(0.5);
```
*/
static setEffectsVolume(volume: number): void;
/**
!#en The volume of the effect audio max value is 1.0,the min value is 0.0 .
!#zh 0.0 ~ 1.0
@example
```js
var volume = cc.audioEngine.getEffectsVolume();
```
*/
static getEffectsVolume(): number;
/**
!#en Pause effect audio.
!#zh
@param audioID audio id.
@example
```js
cc.audioEngine.pauseEffect(audioID);
```
*/
static pauseEffect(audioID: number): void;
/**
!#en Stop playing all the sound effects.
!#zh
@example
```js
cc.audioEngine.pauseAllEffects();
```
*/
static pauseAllEffects(): void;
/**
!#en Resume effect audio.
!#zh
@param audioID The return value of function play.
@example
```js
cc.audioEngine.resumeEffect(audioID);
```
*/
static resumeEffect(audioID: number): void;
/**
!#en Resume all effect audio.
!#zh
@example
```js
cc.audioEngine.resumeAllEffects();
```
*/
static resumeAllEffects(): void;
/**
!#en Stop playing the effect audio.
!#zh
@param audioID audio id.
@example
```js
cc.audioEngine.stopEffect(id);
```
*/
static stopEffect(audioID: number): void;
/**
!#en Stop playing all the effects.
!#zh
@example
```js
cc.audioEngine.stopAllEffects();
```
*/
static stopAllEffects(): void;
}
/** !#en Class for animation data handling.
!#zh */
export class AnimationClip extends Asset {
/** !#en Duration of this animation.
!#zh */
duration: number;
/** !#en FrameRate of this animation.
!#zh */
sample: number;
/** !#en Speed of this animation.
!#zh */
speed: number;
/** !#en WrapMode of this animation.
!#zh */
wrapMode: WrapMode;
/** !#en Curve data.
!#zh 线 */
curveData: any;
/** !#en Event data.
!#zh */
events: {frame: number, func: string, params: string[]}[];
/**
!#en Crate clip with a set of sprite frames
!#zh 使
@param spriteFrames spriteFrames
@param sample sample
@example
```js
var clip = cc.AnimationClip.createWithSpriteFrames(spriteFrames, 10);
```
*/
static createWithSpriteFrames(spriteFrames: SpriteFrame[], sample: number): AnimationClip;
}
/** !#en
This class provide easing methods for {{#crossLink "tween"}}{{/crossLink}} class.<br>
Demonstratio: https://easings.net/
!#zh
{{#crossLink "Tween"}}{{/crossLink}} <br>
https://easings.net/ */
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.
*/
quadIn(t: number): number;
/**
!#en Easing out with quadratic formula. From fast to slow.
!#zh 线
@param t The current time as a percentage of the total time.
*/
quadOut(t: number): number;
/**
!#en Easing in and out with quadratic formula. From slow to fast, then back to slow.
!#zh 线
@param t The current time as a percentage of the total time.
*/
quadInOut(t: number): number;
/**
!#en Easing in with cubic formula. From slow to fast.
!#zh 线
@param t The current time as a percentage of the total time.
*/
cubicIn(t: number): number;
/**
!#en Easing out with cubic formula. From slow to fast.
!#zh 线
@param t The current time as a percentage of the total time.
*/
cubicOut(t: number): number;
/**
!#en Easing in and out with cubic formula. From slow to fast, then back to slow.
!#zh 线
@param t The current time as a percentage of the total time.
*/
cubicInOut(t: number): number;
/**
!#en Easing in with quartic formula. From slow to fast.
!#zh 线
@param t The current time as a percentage of the total time.
*/
quartIn(t: number): number;
/**
!#en Easing out with quartic formula. From fast to slow.
!#zh 线
@param t The current time as a percentage of the total time.
*/
quartOut(t: number): number;
/**
!#en Easing in and out with quartic formula. From slow to fast, then back to slow.
!#zh 线
@param t The current time as a percentage of the total time.
*/
quartInOut(t: number): number;
/**
!#en Easing in with quintic formula. From slow to fast.
!#zh 线
@param t The current time as a percentage of the total time.
*/
quintIn(t: number): number;
/**
!#en Easing out with quintic formula. From fast to slow.
!#zh 线
@param t The current time as a percentage of the total time.
*/
quintOut(t: number): number;
/**
!#en Easing in and out with quintic formula. From slow to fast, then back to slow.
!#zh 线
@param t The current time as a percentage of the total time.
*/
quintInOut(t: number): number;
/**
!#en Easing in and out with sine formula. From slow to fast.
!#zh 线
@param t The current time as a percentage of the total time.
*/
sineIn(t: number): number;
/**
!#en Easing in and out with sine formula. From fast to slow.
!#zh 线
@param t The current time as a percentage of the total time.
*/
sineOut(t: number): number;
/**
!#en Easing in and out with sine formula. From slow to fast, then back to slow.
!#zh 线
@param t The current time as a percentage of the total time.
*/
sineInOut(t: number): number;
/**
!#en Easing in and out with exponential formula. From slow to fast.
!#zh 线
@param t The current time as a percentage of the total time.
*/
expoIn(t: number): number;
/**
!#en Easing in and out with exponential formula. From fast to slow.
!#zh 线
@param t The current time as a percentage of the total time.
*/
expoOut(t: number): number;
/**
!#en Easing in and out with exponential formula. From slow to fast.
!#zh 线
@param t The current time as a percentage of the total time, then back to slow.
*/
expoInOut(t: number): number;
/**
!#en Easing in and out with circular formula. From slow to fast.
!#zh
@param t The current time as a percentage of the total time.
*/
circIn(t: number): number;
/**
!#en Easing in and out with circular formula. From fast to slow.
!#zh
@param t The current time as a percentage of the total time.
*/
circOut(t: number): number;
/**
!#en Easing in and out with circular formula. From slow to fast.
!#zh 线
@param t The current time as a percentage of the total time, then back to slow.
*/
circInOut(t: number): number;
/**
!#en Easing in action with a spring oscillating effect.
!#zh
@param t The current time as a percentage of the total time.
*/
elasticIn(t: number): number;
/**
!#en Easing out action with a spring oscillating effect.
!#zh
@param t The current time as a percentage of the total time.
*/
elasticOut(t: number): number;
/**
!#en Easing in and out action with a spring oscillating effect.
!#zh
@param t The current time as a percentage of the total time.
*/
elasticInOut(t: number): number;
/**
!#en Easing in action with "back up" behavior.
!#zh 退
@param t The current time as a percentage of the total time.
*/
backIn(t: number): number;
/**
!#en Easing out action with "back up" behavior.
!#zh 退
@param t The current time as a percentage of the total time.
*/
backOut(t: number): number;
/**
!#en Easing in and out action with "back up" behavior.
!#zh 退
@param t The current time as a percentage of the total time.
*/
backInOut(t: number): number;
/**
!#en Easing in action with bouncing effect.
!#zh
@param t The current time as a percentage of the total time.
*/
bounceIn(t: number): number;
/**
!#en Easing out action with bouncing effect.
!#zh
@param t The current time as a percentage of the total time.
*/
bounceOut(t: number): number;
/**
!#en Easing in and out action with bouncing effect.
!#zh
@param t The current time as a percentage of the total time.
*/
bounceInOut(t: number): number;
/**
!#en Target will run action with smooth effect.
!#zh
@param t The current time as a percentage of the total time.
*/
smooth(t: number): number;
/**
!#en Target will run action with fade effect.
!#zh
@param t The current time as a percentage of the total time.
*/
fade(t: number): number;
}
/** !#en
The AnimationState gives full control over animation playback process.
In most cases the Animation Component is sufficient and easier to use. Use the AnimationState if you need full control.
!#zh
AnimationState <br/>
使使 AnimationState */
export class AnimationState extends Playable {
/**
@param clip clip
@param name name
*/
constructor(clip: AnimationClip, name?: string);
/** !#en The curves list.
!#zh 线 */
curves: any[];
/** !#en The start delay which represents the number of seconds from an animation's start time to the start of
the active interval.
!#zh */
delay: number;
/** !#en The animation's iteration count property.
A real number greater than or equal to zero (including positive infinity) representing the number of times
to repeat the animation node.
Values less than zero and NaN values are treated as the value 1.0 for the purpose of timing model
calculations.
!#zh , normalize time 2.52 */
repeatCount: number;
/** !#en The iteration duration of this animation in seconds. (length)
!#zh */
duration: number;
/** !#en The animation's playback speed. 1 is normal playback speed.
!#zh */
speed: number;
/** !#en
Wrapping mode of the playing animation.
Notice : dynamic change wrapMode will reset time and repeatCount property
!#zh
wrapMode time repeatCount */
wrapMode: WrapMode;
/** !#en The current time of this animation in seconds.
!#zh */
time: number;
/** !#en The clip that is being played by this animation state.
!#zh */
clip: AnimationClip;
/** !#en The name of the playing animation.
!#zh */
name: string;
}
/** undefined */
export class Playable {
/** !#en Is playing or paused in play mode?
!#zh */
isPlaying: boolean;
/** !#en Is currently paused? This can be true even if in edit mode(isPlaying == false).
!#zh */
isPaused: boolean;
/**
!#en Play this animation.
!#zh
*/
play(): void;
/**
!#en Stop this animation.
!#zh
*/
stop(): void;
/**
!#en Pause this animation.
!#zh
*/
pause(): void;
/**
!#en Resume this animation.
!#zh
*/
resume(): void;
/**
!#en Perform a single frame step.
!#zh
*/
step(): void;
}
/** !#en Specifies how time is treated when it is outside of the keyframe range of an Animation.
!#zh 使 */
export enum WrapMode {
Default = 0,
Normal = 0,
Reverse = 0,
Loop = 0,
LoopReverse = 0,
PingPong = 0,
PingPongReverse = 0,
}
/** !#en An object to boot the game.
!#zh */
export class debug {
/**
!#en Gets error message with the error id and possible parameters.
!#zh error id
@param errorId errorId
@param param param
*/
static getError(errorId: number, param?: any): string;
/**
!#en Returns whether or not to display the FPS informations.
!#zh FPS
*/
static isDisplayStats(): boolean;
/**
!#en Sets whether display the FPS on the bottom-left corner.
!#zh FPS
@param displayStats displayStats
*/
static setDisplayStats(displayStats: boolean): void;
}
/** !#en
<p>
ATTENTION: USE cc.director INSTEAD OF cc.Director.<br/>
cc.director is a singleton object which manage your game's logic flow.<br/>
Since the cc.director is a singleton, you don't need to call any constructor or create functions,<br/>
the standard way to use it is by calling:<br/>
- cc.director.methodName(); <br/>
It creates and handle the main Window and manages how and when to execute the Scenes.<br/>
<br/>
The cc.director is also responsible for:<br/>
- initializing the OpenGL context<br/>
- setting the OpenGL pixel format (default on is RGB565)<br/>
- setting the OpenGL buffer depth (default on is 0-bit)<br/>
- setting the color for clear screen (default one is BLACK)<br/>
- setting the projection (default one is 3D)<br/>
- setting the orientation (default one is Portrait)<br/>
<br/>
<br/>
The cc.director also sets the default OpenGL context:<br/>
- GL_TEXTURE_2D is enabled<br/>
- GL_VERTEX_ARRAY is enabled<br/>
- GL_COLOR_ARRAY is enabled<br/>
- GL_TEXTURE_COORD_ARRAY is enabled<br/>
</p>
<p>
cc.director also synchronizes timers with the refresh rate of the display.<br/>
Features and Limitations:<br/>
- Scheduled timers & drawing are synchronizes with the refresh rate of the display<br/>
- Only supports animation intervals of 1/60 1/30 & 1/15<br/>
</p>
!#zh
<p>
cc.director cc.Director<br/>
cc.director <br/>
cc.director <br/>
使<br/>
- cc.director.methodName();
<br/>
<br/>
<br/>
cc.director <br/>
- OpenGL <br/>
- OpenGL( RGB565)<br/>
- OpenGL ( 0-bit)<br/>
- ( )<br/>
- ( 3D)<br/>
- ( Portrait)<br/>
<br/>
cc.director OpenGL <br/>
- GL_TEXTURE_2D <br/>
- GL_VERTEX_ARRAY <br/>
- GL_COLOR_ARRAY <br/>
- GL_TEXTURE_COORD_ARRAY <br/>
</p>
<p>
cc.director
<br/>
: <br/>
- & <br/>
- 1/60 1/30 & 1/15<br/>
</p> */
export class Director extends EventTarget {
/**
!#en
Converts a view coordinate to an WebGL coordinate<br/>
Useful to convert (multi) touches coordinates to the current layout (portrait or landscape)<br/>
Implementation can be found in CCDirectorWebGL.
!#zh WebGL View
@param uiPoint uiPoint
*/
convertToGL(uiPoint: Vec2): Vec2;
/**
!#en
Converts an OpenGL coordinate to a view coordinate<br/>
Useful to convert node points to window points for calls such as glScissor<br/>
Implementation can be found in CCDirectorWebGL.
!#zh WebGL View
@param glPoint glPoint
*/
convertToUI(glPoint: Vec2): Vec2;
/**
End the life of director in the next frame
*/
end(): void;
/**
!#en
Returns the size of the WebGL view in points.<br/>
It takes into account any possible rotation (device orientation) of the window.
!#zh
*/
getWinSize(): Size;
/**
!#en
Returns the size of the OpenGL view in pixels.<br/>
It takes into account any possible rotation (device orientation) of the window.<br/>
On Mac winSize and winSizeInPixels return the same value.
(The pixel here refers to the resource resolution. If you want to get the physics resolution of device, you need to use cc.view.getFrameSize())
!#zh
cc.view.getFrameSize()
*/
getWinSizeInPixels(): Size;
/**
!#en Pause the director's ticker, only involve the game logic execution.
It won't pause the rendering process nor the event manager.
If you want to pause the entier game including rendering, audio and event,
please use {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}
!#zh UI
使 {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}
*/
pause(): void;
/**
!#en
Run a scene. Replaces the running scene with a new one or enter the first scene.<br/>
The new scene will be launched immediately.
!#zh
@param scene The need run scene.
@param onBeforeLoadScene The function invoked at the scene before loading.
@param onLaunched The function invoked at the scene after launch.
*/
runSceneImmediate(scene: Scene|SceneAsset, onBeforeLoadScene?: Function, onLaunched?: Function): void;
/**
!#en
Run a scene. Replaces the running scene with a new one or enter the first scene.
The new scene will be launched at the end of the current frame.
!#zh
@param scene The need run scene.
@param onBeforeLoadScene The function invoked at the scene before loading.
@param onLaunched The function invoked at the scene after launch.
*/
runScene(scene: Scene|SceneAsset, onBeforeLoadScene?: Function, onLaunched?: Function): void;
/**
!#en Loads the scene by its name.
!#zh
@param sceneName The name of the scene to load.
@param onLaunched callback, will be called after scene launched.
*/
loadScene(sceneName: string, onLaunched?: Function): boolean;
/**
!#en
Preloads the scene to reduces loading time. You can call this method at any time you want.
After calling this method, you still need to launch the scene by `cc.director.loadScene`.
It will be totally fine to call `cc.director.loadScene` at any time even if the preloading is not
yet finished, the scene will be launched after loaded automatically.
!#zh
`cc.director.loadScene`
`cc.director.loadScene`
@param sceneName The name of the scene to preload.
@param onProgress callback, will be called when the load progression change.
@param onLoaded callback, will be called after scene loaded.
*/
preloadScene(sceneName: string, onProgress?: (completedCount: number, totalCount: number, item: any) => void, onLoaded?: (error: Error) => void): void;
/**
!#en Resume game logic execution after pause, if the current scene is not paused, nothing will happen.
!#zh
*/
resume(): void;
/**
!#en
Enables or disables WebGL depth test.<br/>
Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js
!#zh / Canvas
@param on on
*/
setDepthTest(on: boolean): void;
/**
!#en
Set color for clear screen.<br/>
(Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js)
!#zh
<br/>
cc.macro.ENABLE_TRANSPARENT_CANVAS
@param clearColor clearColor
*/
setClearColor(clearColor: Color): void;
/**
!#en Returns current logic Scene.
!#zh
@example
```js
// This will help you to get the Canvas node in scene
cc.director.getScene().getChildByName('Canvas');
```
*/
getScene(): Scene;
/**
!#en Returns the FPS value. Please use {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} to control animation interval.
!#zh 使 {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}}
*/
getAnimationInterval(): number;
/**
Sets animation interval, this doesn't control the main loop.
To control the game's frame rate overall, please use {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}}
@param value The animation interval desired.
*/
setAnimationInterval(value: number): void;
/**
!#en Returns the delta time since last frame.
!#zh
*/
getDeltaTime(): number;
/**
!#en Returns the total passed time since game start, unit: ms
!#zh ms
*/
getTotalTime(): number;
/**
!#en Returns how many frames were called since the director started.
!#zh director
*/
getTotalFrames(): number;
/**
!#en Returns whether or not the Director is paused.
!#zh
*/
isPaused(): boolean;
/**
!#en Returns the cc.Scheduler associated with this director.
!#zh director cc.Scheduler
*/
getScheduler(): Scheduler;
/**
!#en Sets the cc.Scheduler associated with this director.
!#zh director cc.Scheduler
@param scheduler scheduler
*/
setScheduler(scheduler: Scheduler): void;
/**
!#en Returns the cc.ActionManager associated with this director.
!#zh director cc.ActionManager
*/
getActionManager(): ActionManager;
/**
!#en Sets the cc.ActionManager associated with this director.
!#zh director cc.ActionManager
@param actionManager actionManager
*/
setActionManager(actionManager: ActionManager): void;
/**
!#en Returns the cc.CollisionManager associated with this director.
!#zh director cc.CollisionManager
*/
getCollisionManager(): CollisionManager;
/**
!#en Returns the cc.PhysicsManager associated with this director.
!#zh director cc.PhysicsManager
*/
getPhysicsManager(): PhysicsManager;
/**
!#en Returns the cc.Physics3DManager associated with this director.
!#zh director cc.Physics3DManager
*/
getPhysics3DManager(): Physics3DManager;
/** !#en The event projection changed of cc.Director. This event will not get triggered since v2.0
!#zh cc.Director v2.0 */
static EVENT_PROJECTION_CHANGED: string;
/** !#en The event which will be triggered before loading a new scene.
!#zh */
static EVENT_BEFORE_SCENE_LOADING: string;
/** !#en The event which will be triggered before launching a new scene.
!#zh */
static EVENT_BEFORE_SCENE_LAUNCH: string;
/** !#en The event which will be triggered after launching a new scene.
!#zh */
static EVENT_AFTER_SCENE_LAUNCH: string;
/** !#en The event which will be triggered at the beginning of every frame.
!#zh */
static EVENT_BEFORE_UPDATE: string;
/** !#en The event which will be triggered after engine and components update logic.
!#zh update */
static EVENT_AFTER_UPDATE: string;
/** !#en The event is deprecated since v2.0, please use cc.Director.EVENT_BEFORE_DRAW instead
!#zh v2.0 使 cc.Director.EVENT_BEFORE_DRAW */
static EVENT_BEFORE_VISIT: string;
/** !#en The event is deprecated since v2.0, please use cc.Director.EVENT_BEFORE_DRAW instead
!#zh v2.0 使 cc.Director.EVENT_BEFORE_DRAW */
static EVENT_AFTER_VISIT: string;
/** !#en The event which will be triggered before the rendering process.
!#zh */
static EVENT_BEFORE_DRAW: string;
/** !#en The event which will be triggered after the rendering process.
!#zh */
static EVENT_AFTER_DRAW: string;
/** Constant for 2D projection (orthogonal projection) */
static PROJECTION_2D: number;
/** Constant for 3D projection with a fovy=60, znear=0.5f and zfar=1500. */
static PROJECTION_3D: number;
/** Constant for custom projection, if cc.Director's projection set to it, it calls "updateProjection" on the projection delegate. */
static PROJECTION_CUSTOM: number;
/** Constant for default projection of cc.Director, default projection is 2D projection */
static PROJECTION_DEFAULT: number;
}
/** !#en An object to boot the game.
!#zh */
export class Game extends EventTarget {
/** !#en Event triggered when game hide to background.
Please note that this event is not 100% guaranteed to be fired on Web platform,
on native platforms, it corresponds to enter background event, os status bar or notification center may not trigger this event.
!#zh
WEB 100%
*/
EVENT_HIDE: string;
/** !#en Event triggered when game back to foreground
Please note that this event is not 100% guaranteed to be fired on Web platform,
on native platforms, it corresponds to enter foreground event.
!#zh
WEB 100%
*/
EVENT_SHOW: string;
/** !#en Event triggered when game restart
!#zh restart */
EVENT_RESTART: string;
/** Event triggered after game inited, at this point all engine objects and game scripts are loaded */
EVENT_GAME_INITED: string;
/** Event triggered after engine inited, at this point you will be able to use all engine classes.
It was defined as EVENT_RENDERER_INITED in cocos creator v1.x and renamed in v2.0 */
EVENT_ENGINE_INITED: string;
/** Web Canvas 2d API as renderer backend */
RENDER_TYPE_CANVAS: number;
/** WebGL API as renderer backend */
RENDER_TYPE_WEBGL: number;
/** OpenGL API as renderer backend */
RENDER_TYPE_OPENGL: number;
/** !#en The outer frame of the game canvas, parent of game container.
!#zh container */
frame: any;
/** !#en The container of game canvas.
!#zh */
container: HTMLDivElement;
/** !#en The canvas of the game.
!#zh */
canvas: HTMLCanvasElement;
/** !#en The renderer backend of the game.
!#zh */
renderType: number;
/** !#en
The current game configuration, including:<br/>
1. debugMode<br/>
"debugMode" possible values :<br/>
0 - No message will be printed. <br/>
1 - cc.error, cc.assert, cc.warn, cc.log will print in console. <br/>
2 - cc.error, cc.assert, cc.warn will print in console. <br/>
3 - cc.error, cc.assert will print in console. <br/>
4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web.<br/>
5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web. <br/>
6 - cc.error, cc.assert will print on canvas, available only on web. <br/>
2. showFPS<br/>
Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide.<br/>
3. exposeClassName<br/>
Expose class name to chrome debug tools, the class intantiate performance is a little bit slower when exposed.<br/>
4. frameRate<br/>
"frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment.<br/>
5. id<br/>
"gameCanvas" sets the id of your canvas element on the web page, it's useful only on web.<br/>
6. renderMode<br/>
"renderMode" sets the renderer type, only useful on web :<br/>
0 - Automatically chosen by engine<br/>
1 - Forced to use canvas renderer<br/>
2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers<br/>
<br/>
Please DO NOT modify this object directly, it won't have any effect.<br/>
!#zh
<br/>
1. debugModedebug <br/>
"debugMode" <br/>
0 - <br/>
1 - cc.errorcc.assertcc.warncc.log console <br/>
2 - cc.errorcc.assertcc.warn console <br/>
3 - cc.errorcc.assert console <br/>
4 - cc.errorcc.assertcc.warncc.log canvas web <br/>
5 - cc.errorcc.assertcc.warn canvas web <br/>
6 - cc.errorcc.assert canvas web <br/>
2. showFPS FPS <br/>
showFPS true fps <br/>
3. exposeClassName <br/>
Chrome DevTools <br/>
4. frameRate () <br/>
frameRate FPS <br/>
5. id <br/>
"gameCanvas" Web Canvas Element ID web <br/>
6. renderMode <br/>
renderMode web <br/>
0 - <br/>
1 - 使 canvas
2 - 使 WebGL Android <br/>
<br/>
*/
config: any;
/**
!#en Callback when the scripts of engine have been load.
!#zh
*/
onStart(): void;
/**
!#en Set frame rate of game.
!#zh
@param frameRate frameRate
*/
setFrameRate(frameRate: number): void;
/**
!#en Get frame rate set for the game, it doesn't represent the real frame rate.
!#zh
*/
getFrameRate(): number;
/**
!#en Run the game frame by frame.
!#zh
*/
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
*/
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
*/
resume(): void;
/**
!#en Check whether the game is paused.
!#zh
*/
isPaused(): boolean;
/**
!#en Restart game.
!#zh
*/
restart(): void;
/**
!#en End game, it will close the game window
!#zh 退
*/
end(): void;
/**
!#en
Register an callback of a specific event type on the game object.
This type of event should be triggered via `emit`.
!#zh
game `emit`
@param type A string representing the event type to listen for.
@param callback The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null
*/
on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
/**
!#en
Register an callback of a specific event type on the game object,
the callback will remove itself after the first time it is triggered.
!#zh
game
@param type A string representing the event type to listen for.
@param callback The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null
*/
once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void;
/**
!#en Prepare game.
!#zh
@param cb cb
*/
prepare(cb: Function): void;
/**
!#en Run game with configuration object and onStart function.
!#zh onStart
@param config Pass configuration object or onStart function
@param onStart function to be executed after game initialized
*/
run(config: any, onStart: Function): void;
/**
!#en
Add a persistent root node to the game, the persistent node won't be destroyed during scene transition.<br/>
The target node must be placed in the root level of hierarchy, otherwise this API won't have any effect.
!#zh
<br/>
@param node The node to be made persistent
*/
addPersistRootNode(node: Node): void;
/**
!#en Remove a persistent root node.
!#zh
@param node The node to be removed from persistent node list
*/
removePersistRootNode(node: Node): void;
/**
!#en Check whether the node is a persistent root node.
!#zh
@param node The node to be checked
*/
isPersistRootNode(node: Node): boolean;
}
/** !#en
Class of all entities in Cocos Creator scenes.<br/>
For events supported by Node, please refer to {{#crossLink "Node.EventType"}}{{/crossLink}}
!#zh
Cocos Creator <br/>
{{#crossLink "Node.EventType"}}{{/crossLink}}。 */
export class Node extends _BaseNode {
/** !#en
Group index of node.<br/>
Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.<br/>
!#zh
<br/>
<br/> */
groupIndex: number;
/** !#en
Group of node.<br/>
Which Group this node belongs to will resolve that this node's collision components can collide with which other collision componentns.<br/>
!#zh
<br/>
<br/> */
group: string;
/** !#en The position (x, y) of the node in its parent's coordinates.
!#zh x, y */
position: Vec3;
/** !#en x axis position of node.
!#zh X */
x: number;
/** !#en y axis position of node.
!#zh Y */
y: number;
/** !#en z axis position of node.
!#zh Z */
z: number;
/** !#en Rotation of node.
!#zh */
rotation: number;
/** !#en
Angle of node, the positive value is anti-clockwise direction.
!#zh
*/
angle: number;
/** !#en The rotation as Euler angles in degrees, used in 3D node.
!#zh 3D */
eulerAngles: Vec3;
/** !#en Rotation on x axis.
!#zh X */
rotationX: number;
/** !#en Rotation on y axis.
!#zh Y */
rotationY: number;
/** !#en The local scale relative to the parent.
!#zh */
scale: number;
/** !#en Scale on x axis.
!#zh X */
scaleX: number;
/** !#en Scale on y axis.
!#zh Y */
scaleY: number;
/** !#en Scale on z axis.
!#zh Z */
scaleZ: number;
/** !#en Skew x
!#zh X */
skewX: number;
/** !#en Skew y
!#zh Y */
skewY: number;
/** !#en Opacity of node, default value is 255.
!#zh 255 */
opacity: number;
/** !#en Color of node, default value is white: (255, 255, 255).
!#zh 255255255 */
color: Color;
/** !#en Anchor point's position on x axis.
!#zh X */
anchorX: number;
/** !#en Anchor point's position on y axis.
!#zh Y */
anchorY: number;
/** !#en Width of node.
!#zh */
width: number;
/** !#en Height of node.
!#zh */
height: number;
/** !#en zIndex is the 'key' used to sort the node relative to its siblings.<br/>
The value of zIndex should be in the range between cc.macro.MIN_ZINDEX and cc.macro.MAX_ZINDEX.<br/>
The Node's parent will sort all its children based on the zIndex value and the arrival order.<br/>
Nodes with greater zIndex will be sorted after nodes with smaller zIndex.<br/>
If two nodes have the same zIndex, then the node that was added first to the children's array will be in front of the other node in the array.<br/>
Node's order in children list will affect its rendering order. Parent is always rendering before all children.
!#zh zIndex <br/>
zIndex cc.macro.MIN_ZINDEX cc.macro.MAX_ZINDEX
zIndex zIndex zIndex <br/>
children */
zIndex: number;
/** !#en
Switch 2D/3D node. The 2D nodes will run faster.
!#zh
2D/3D 2D */
is3DNode: boolean;
/** !#en Returns a normalized vector representing the up direction (Y axis) of the node in world space.
!#zh y */
up: Vec3;
/** !#en Returns a normalized vector representing the right direction (X axis) of the node in world space.
!#zh x */
right: Vec3;
/** !#en Returns a normalized vector representing the forward direction (Z axis) of the node in world space.
!#zh z */
forward: Vec3;
/**
@param name name
*/
constructor(name?: string);
/**
!#en
Register a callback of a specific event type on Node.<br/>
Use this method to register touch or mouse event permit propagation based on scene graph,<br/>
These kinds of event are triggered with dispatchEvent, the dispatch process has three steps:<br/>
1. Capturing phase: dispatch in capture targets (`_getCapturingTargets`), e.g. parents in node tree, from root to the real target<br/>
2. At target phase: dispatch to the listeners of the real target<br/>
3. Bubbling phase: dispatch in bubble targets (`_getBubblingTargets`), e.g. parents in node tree, from the real target to root<br/>
In any moment of the dispatching process, it can be stopped via `event.stopPropagation()` or `event.stopPropagationImmidiate()`.<br/>
It's the recommended way to register touch/mouse event for Node,<br/>
please do not use cc.eventManager directly for Node.<br/>
You can also register custom event and use `emit` to trigger custom event on Node.<br/>
For such events, there won't be capturing and bubbling phase, your event will be dispatched directly to its listeners registered on the same node.<br/>
You can also pass event callback parameters with `emit` by passing parameters after `type`.
!#zh
target this <br/>
dispatchEvent <br/>
1. `_getCapturingTargets` <br/>
2. <br/>
3. `_getBubblingTargets` <br/>
stopPropagation <br/>
使使 cc.eventManager<br/>
emit <br/>
emit type
@param type A string representing the event type to listen for.<br>See {{#crossLink "Node/EventTyupe/POSITION_CHANGED"}}Node Events{{/crossLink}} for all builtin events.
@param callback The callback that will be invoked when the event is dispatched. The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null
@param useCapture When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase.
@example
```js
this.node.on(cc.Node.EventType.TOUCH_START, this.memberFunction, this); // if "this" is component and the "memberFunction" declared in CCClass.
node.on(cc.Node.EventType.TOUCH_START, callback, this);
node.on(cc.Node.EventType.TOUCH_MOVE, callback, this);
node.on(cc.Node.EventType.TOUCH_END, callback, this);
node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this);
node.on(cc.Node.EventType.ANCHOR_CHANGED, callback);
node.on(cc.Node.EventType.COLOR_CHANGED, callback);
```
*/
on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
/**
!#en
Register an callback of a specific event type on the Node,
the callback will remove itself after the first time it is triggered.
!#zh
@param type A string representing the event type to listen for.
@param callback The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null
@example
```js
node.once(cc.Node.EventType.ANCHOR_CHANGED, callback);
```
*/
once<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
/**
!#en
Removes the callback previously registered with the same type, callback, target and or useCapture.
This method is merely an alias to removeEventListener.
!#zh useCapture
@param type A string representing the event type being removed.
@param callback The callback to remove.
@param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
@param useCapture When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase.
@example
```js
this.node.off(cc.Node.EventType.TOUCH_START, this.memberFunction, this);
node.off(cc.Node.EventType.TOUCH_START, callback, this.node);
node.off(cc.Node.EventType.ANCHOR_CHANGED, callback, this);
```
*/
off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
/**
!#en Removes all callbacks previously registered with the same target.
!#zh
@param target The target to be searched for all related callbacks
@example
```js
node.targetOff(target);
```
*/
targetOff(target: any): void;
/**
!#en Checks whether the EventTarget object has any callback registered for a specific type of event.
!#zh
@param type The type of event.
*/
hasEventListener(type: string): boolean;
/**
!#en
Trigger an event directly with the event name and necessary arguments.
!#zh
@param type event type
@param arg1 First argument in callback
@param arg2 Second argument in callback
@param arg3 Third argument in callback
@param arg4 Fourth argument in callback
@param arg5 Fifth argument in callback
@example
```js
eventTarget.emit('fire', event);
eventTarget.emit('fire', message, emitter);
```
*/
emit(type: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any): void;
/**
!#en
Dispatches an event into the event flow.
The event target is the EventTarget object upon which the dispatchEvent() method is called.
!#zh
@param event The Event object that is dispatched into the event flow
*/
dispatchEvent(event: Event): void;
/**
!#en Pause node related system events registered with the current Node. Node system events includes touch and mouse events.
If recursive is set to true, then this API will pause the node system events for the node and all nodes in its sub node tree.
Reference: http://docs.cocos2d-x.org/editors_and_tools/creator-chapters/scripting/internal-events/
!#zh
recursive true API
https://www.cocos.com/docs/creator/scripting/internal-events.html
@param recursive Whether to pause node system events on the sub node tree.
@example
```js
node.pauseSystemEvents(true);
```
*/
pauseSystemEvents(recursive: boolean): void;
/**
!#en Resume node related system events registered with the current Node. Node system events includes touch and mouse events.
If recursive is set to true, then this API will resume the node system events for the node and all nodes in its sub node tree.
Reference: http://docs.cocos2d-x.org/editors_and_tools/creator-chapters/scripting/internal-events/
!#zh
recursive true API
https://www.cocos.com/docs/creator/scripting/internal-events.html
@param recursive Whether to resume node system events on the sub node tree.
@example
```js
node.resumeSystemEvents(true);
```
*/
resumeSystemEvents(recursive: boolean): void;
/**
!#en
Executes an action, and returns the action that is executed.<br/>
The node becomes the action's target. Refer to cc.Action's getTarget() <br/>
Calling runAction while the node is not active won't have any effect. <br/>
NoteYou shouldn't modify the action after runAction, that won't take any effect.<br/>
if you want to modify, when you define action plus.
!#zh
<br/>
runAction <br/>
runAction action
@param action action
@example
```js
var action = cc.scaleTo(0.2, 1, 0.6);
node.runAction(action);
node.runAction(action).repeatForever(); // fail
node.runAction(action.repeatForever()); // right
```
*/
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
```js
node.pauseAllActions();
```
*/
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
```js
node.resumeAllActions();
```
*/
resumeAllActions(): void;
/**
!#en Stops and removes all actions from the running action list .
!#zh
@example
```js
node.stopAllActions();
```
*/
stopAllActions(): void;
/**
!#en Stops and removes an action from the running action list.
!#zh
@param action An action object to be removed.
@example
```js
var action = cc.scaleTo(0.2, 1, 0.6);
node.stopAction(action);
```
*/
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
```js
node.stopActionByTag(1);
```
*/
stopActionByTag(tag: number): void;
/**
!#en Returns an action from the running action list by its tag.
!#zh
@param tag tag
@example
```js
var action = node.getActionByTag(1);
```
*/
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).<br/>
Composable actions are counted as 1 action. Example:<br/>
If you are running 1 Sequence of 7 actions, it will return 1. <br/>
If you are running 7 Sequences of 2 actions, it will return 7.</p>
!#zh
<br/>
<br/>
- 7 1 Sequence 1<br/>
- 2 7 Sequence 7<br/>
@example
```js
var count = node.getNumberOfRunningActions();
cc.log("Running Action Count: " + count);
```
*/
getNumberOfRunningActions(): number;
/**
!#en
Returns a copy of the position (x, y, z) of the node in its parent's coordinates.
You can pass a cc.Vec2 or cc.Vec3 as the argument to receive the return values.
!#zh
x, y, z
cc.Vec2 cc.Vec3
@param out The return value to receive position
@example
```js
cc.log("Node Position: " + node.getPosition());
```
*/
getPosition(out?: Vec2|Vec3): Vec2;
/**
!#en
Sets the position (x, y, z) of the node in its parent's coordinates.<br/>
Usually we use cc.v2(x, y) to compose cc.Vec2 object, in this case, position.z will become 0.<br/>
and passing two numbers (x, y) is more efficient than passing cc.Vec2 object, in this case, position.z will remain unchanged.
For 3D node we can use cc.v3(x, y, z) to compose cc.Vec3 object,<br/>
and passing three numbers (x, y, z) is more efficient than passing cc.Vec3 object.
!#zh
<br/>
<br/>
1. 2 x, y ( position.z )<br/>
2. cc.v2(x, y) cc.Vec2 ( position.z 0)
3. 3D 3 x, y, z<br/>
4. 3D cc.v3(x, y, z) cc.Vec3
@param x X coordinate for position or the position object
@param y Y coordinate for position
@param z Z coordinate for position
*/
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
```js
cc.log("Node Scale: " + node.getScale(cc.v3()));
```
*/
getScale(out: Vec2|Vec3): Vec2;
/**
!#en
Sets the scale of axis in local coordinates of the node.
You can operate 2 axis in 2D node, and 3 axis in 3D node.
When only (x, y) is passed, the value of scale.z will not be changed.
When a Vec2 is passed in, the value of scale.z will be set to 0.
!#zh
2D 3D
(x, y) scale.z
Vec2 scale.z 0
@param x scaleX or scale object
@param y y
@param z z
@example
```js
node.setScale(cc.v2(2, 2)); // Notice: scaleZ will be 0
node.setScale(cc.v3(2, 2, 2)); // for 3D node
node.setScale(2);
```
*/
setScale(x: number|Vec2|Vec3, y?: number, z?: number): void;
/**
!#en
Get rotation of node (in quaternion).
Need pass a cc.Quat as the argument to receive the return values.
!#zh
quaternion cc.Quat
@param out out
*/
getRotation(out: Quat): Quat;
/**
!#en Set rotation of node (in quaternion).
!#zh quaternion
@param quat Quaternion object represents the rotation or the x value of quaternion
@param y y value of quternion
@param z z value of quternion
@param w w value of quternion
*/
setRotation(quat: Quat|number, y?: number, z?: number, w?: number): void;
/**
!#en
Returns a copy the untransformed size of the node. <br/>
The contentSize remains the same no matter the node is scaled or rotated.<br/>
All nodes has a size. Layer and Scene has the same size of the screen by default. <br/>
!#zh
@example
```js
cc.log("Content Size: " + node.getContentSize());
```
*/
getContentSize(): Size;
/**
!#en
Sets the untransformed size of the node.<br/>
The contentSize remains the same no matter the node is scaled or rotated.<br/>
All nodes has a size. Layer and Scene has the same size of the screen.
!#zh
@param size The untransformed size of the node or The untransformed size's width of the node.
@param height The untransformed size's height of the node.
@example
```js
node.setContentSize(cc.size(100, 100));
node.setContentSize(100, 100);
```
*/
setContentSize(size: Size|number, height?: number): void;
/**
!#en
Returns a copy of the anchor point.<br/>
Anchor point is the point around which all transformations and positioning manipulations take place.<br/>
It's like a pin in the node where it is "attached" to its parent. <br/>
The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner. <br/>
But you can use values higher than (1,1) and lower than (0,0) too. <br/>
The default anchor point is (0.5,0.5), so it starts at the center of the node.
!#zh
<br/>
<br/>
(00) (11) <br/>
使1100<br/>
0.50.5<br/>
Creator
@example
```js
cc.log("Node AnchorPoint: " + node.getAnchorPoint());
```
*/
getAnchorPoint(): Vec2;
/**
!#en
Sets the anchor point in percent. <br/>
anchor point is the point around which all transformations and positioning manipulations take place. <br/>
It's like a pin in the node where it is "attached" to its parent. <br/>
The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.<br/>
But you can use values higher than (1,1) and lower than (0,0) too.<br/>
The default anchor point is (0.5,0.5), so it starts at the center of the node.
!#zh
<br/>
<br/>
(00) (11) <br/>
使1100<br/>
0.50.5<br/>
Creator
@param point The anchor point of node or The x axis anchor of node.
@param y The y axis anchor of node.
@example
```js
node.setAnchorPoint(cc.v2(1, 1));
node.setAnchorPoint(1, 1);
```
*/
setAnchorPoint(point: Vec2|number, y?: number): void;
/**
!#en Set rotation by lookAt target point, normally used by Camera Node
!#zh rotation Camera Node
@param pos pos
@param up default is (0,1,0)
*/
lookAt(pos: Vec3, up?: Vec3): void;
/**
!#en
Get the local transform matrix (4x4), based on parent node coordinates
!#zh
@param out The matrix object to be filled with data
@example
```js
let mat4 = cc.mat4();
node.getLocalMatrix(mat4);
```
*/
getLocalMatrix(out: Mat4): Mat4;
/**
!#en
Get the world transform matrix (4x4)
!#zh
@param out The matrix object to be filled with data
@example
```js
let mat4 = cc.mat4();
node.getWorldMatrix(mat4);
```
*/
getWorldMatrix(out: Mat4): Mat4;
/**
!#en
Converts a Point to node (local) space coordinates.
!#zh
()
@param worldPoint worldPoint
@param out out
@example
```js
var newVec2 = node.convertToNodeSpaceAR(cc.v2(100, 100));
var newVec3 = node.convertToNodeSpaceAR(cc.v3(100, 100, 100));
```
*/
convertToNodeSpaceAR<T extends cc.Vec2 | cc.Vec3>(worldPoint: T, out?: T): T;
/**
!#en
Converts a Point in node coordinates to world space coordinates.
!#zh
@param nodePoint nodePoint
@param out out
@example
```js
var newVec2 = node.convertToWorldSpaceAR(cc.v2(100, 100));
var newVec3 = node.convertToWorldSpaceAR(cc.v3(100, 100, 100));
```
*/
convertToWorldSpaceAR<T extends cc.Vec2 | cc.Vec3>(nodePoint: T, out?: T): T;
/**
!#en Converts a Point to node (local) space coordinates then add the anchor point position.
So the return position will be related to the left bottom corner of the node's bounding box.
This equals to the API behavior of cocos2d-x, you probably want to use convertToNodeSpaceAR instead
!#zh () <br/>
<br/>
API cocos2d-x 使 convertToNodeSpaceAR
@param worldPoint worldPoint
@example
```js
var newVec2 = node.convertToNodeSpace(cc.v2(100, 100));
```
*/
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
```js
var newVec2 = node.convertToWorldSpace(cc.v2(100, 100));
```
*/
convertToWorldSpace(nodePoint: Vec2): Vec2;
/**
!#en
Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.<br/>
The matrix is in Pixels.
!#zh
@param out The affine transform object to be filled with data
@example
```js
let affineTransform = cc.AffineTransform.create();
node.getNodeToParentTransform(affineTransform);
```
*/
getNodeToParentTransform(out?: AffineTransform): AffineTransform;
/**
!#en
Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.<br/>
The matrix is in Pixels.<br/>
This method is AR (Anchor Relative).
!#zh
<br/>
<br/>
@param out The affine transform object to be filled with data
@example
```js
let affineTransform = cc.AffineTransform.create();
node.getNodeToParentTransformAR(affineTransform);
```
*/
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
```js
let affineTransform = cc.AffineTransform.create();
node.getNodeToWorldTransform(affineTransform);
```
*/
getNodeToWorldTransform(out?: AffineTransform): AffineTransform;
/**
!#en
Returns the world affine transform matrix. The matrix is in Pixels.<br/>
This method is AR (Anchor Relative).
!#zh
仿<br/>
@param out The affine transform object to be filled with data
@example
```js
let affineTransform = cc.AffineTransform.create();
node.getNodeToWorldTransformAR(affineTransform);
```
*/
getNodeToWorldTransformAR(out?: AffineTransform): AffineTransform;
/**
!#en
Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.<br/>
The matrix is in Pixels. The returned transform is readonly and cannot be changed.
!#zh
<br/>
@param out The affine transform object to be filled with data
@example
```js
let affineTransform = cc.AffineTransform.create();
node.getParentToNodeTransform(affineTransform);
```
*/
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
```js
let affineTransform = cc.AffineTransform.create();
node.getWorldToNodeTransform(affineTransform);
```
*/
getWorldToNodeTransform(out?: AffineTransform): AffineTransform;
/**
!#en convenience methods which take a cc.Touch instead of cc.Vec2.
!#zh
@param touch The touch object
@example
```js
var newVec2 = node.convertTouchToNodeSpace(touch);
```
*/
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
```js
var newVec2 = node.convertTouchToNodeSpaceAR(touch);
```
*/
convertTouchToNodeSpaceAR(touch: Touch): Vec2;
/**
!#en
Returns a "local" axis aligned bounding box of the node. <br/>
The returned box is relative only to its parent.
!#zh
@example
```js
var boundingBox = node.getBoundingBox();
```
*/
getBoundingBox(): Rect;
/**
!#en
Returns a "world" axis aligned bounding box of the node.<br/>
The bounding box contains self and active children's world bounding box.
!#zh
AABB<br/>
@example
```js
var newRect = node.getBoundingBoxToWorld();
```
*/
getBoundingBoxToWorld(): Rect;
/**
!#en
Adds a child to the node with z order and name.
!#zh
Z
@param child A child node
@param zIndex Z order for drawing priority. Please refer to zIndex property
@param name A name to identify the node easily. Please refer to name property
@example
```js
node.addChild(newNode, 1, "node");
```
*/
addChild(child: Node, zIndex?: number, name?: string): void;
/**
!#en Stops all running actions and schedulers.
!#zh
@example
```js
node.cleanup();
```
*/
cleanup(): void;
/**
!#en Sorts the children array depends on children's zIndex and arrivalOrder,
normally you won't need to invoke this function.
!#zh zIndex arrivalOrder
*/
sortAllChildren(): void;
/**
!#en
Returns the displayed opacity of Node,
the difference between displayed opacity and opacity is that displayed opacity is calculated based on opacity and parent node's opacity when cascade opacity enabled.
!#zh
*/
getDisplayedOpacity(): number;
/**
!#en
Returns the displayed color of Node,
the difference between displayed color and color is that displayed color is calculated based on color and parent node's color when cascade color enabled.
!#zh
*/
getDisplayedColor(): Color;
/** !#en Cascade opacity is removed from v2.0
Indicate whether node's opacity value affect its child nodes, default value is true.
!#zh v2.0
true */
cascadeOpacity: boolean;
/**
!#en Cascade opacity is removed from v2.0
Returns whether node's opacity value affect its child nodes.
!#zh v2.0
*/
isCascadeOpacityEnabled(): boolean;
/**
!#en Cascade opacity is removed from v2.0
Enable or disable cascade opacity, if cascade enabled, child nodes' opacity will be the multiplication of parent opacity and its own opacity.
!#zh v2.0
@param cascadeOpacityEnabled cascadeOpacityEnabled
*/
setCascadeOpacityEnabled(cascadeOpacityEnabled: boolean): void;
/**
!#en Opacity modify RGB have been removed since v2.0
Set whether color should be changed with the opacity value,
useless in ccsg.Node, but this function is override in some class to have such behavior.
!#zh
RGB
@param opacityValue opacityValue
*/
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
*/
isOpacityModifyRGB(): boolean;
}
/** !#en
Class of private entities in Cocos Creator scenes.<br/>
The PrivateNode is hidden in editor, and completely transparent to users.<br/>
It's normally used as Node's private content created by components in parent node.<br/>
So in theory private nodes are not children, they are part of the parent node.<br/>
Private node have two important characteristics:<br/>
1. It has the minimum z index and cannot be modified, because they can't be displayed over real children.<br/>
2. The positioning of private nodes is also special, they will consider the left bottom corner of the parent node's bounding box as the origin of local coordinates.<br/>
In this way, they can be easily kept inside the bounding box.<br/>
Currently, it's used by RichText component and TileMap component.
!#zh
Cocos Creator <br/>
<br/>
<br/>
<br/>
1. Z <br/>
2. <br/>
RichText TileMap */
export class PrivateNode extends Node {
/**
@param name name
*/
constructor(name?: string);
}
/** !#en
cc.Scene is a subclass of cc.Node that is used only as an abstract concept.<br/>
cc.Scene and cc.Node are almost identical with the difference that users can not modify cc.Scene manually.
!#zh
cc.Scene cc.Node <br/>
cc.Scene cc.Node cc.Scene */
export class Scene extends Node {
/** !#en Indicates whether all (directly or indirectly) static referenced assets of this scene are releasable by default after scene unloading.
!#zh */
autoReleaseAssets: boolean;
}
/** !#en
Scheduler is responsible of triggering the scheduled callbacks.<br/>
You should not use NSTimer. Instead use this class.<br/>
<br/>
There are 2 different types of callbacks (selectors):<br/>
- update callback: the 'update' callback will be called every frame. You can customize the priority.<br/>
- custom callback: A custom callback will be called every frame, or with a custom interval of time<br/>
<br/>
The 'custom selectors' should be avoided when possible. It is faster,
and consumes less memory to use the 'update callback'. *
!#zh
Scheduler <br/>
使 cc.director.getScheduler() <br/>
<br/>
- update <br/>
- <br/>
使 update 使 update */
export class Scheduler {
/**
!#en This method should be called for any target which needs to schedule tasks, and this method should be called before any scheduler API usage.
This method will add a `_id` property if it doesn't exist.
!#zh Scheduler Scheduler API
`_id`
@param target target
*/
enableForTarget(target: any): void;
/**
!#en
Modifies the time of all scheduled callbacks.<br/>
You can use this property to create a 'slow motion' or 'fast forward' effect.<br/>
Default is 1.0. To create a 'slow motion' effect, use values below 1.0.<br/>
To create a 'fast forward' effect, use values higher than 1.0.<br/>
NoteIt will affect EVERY scheduled selector / action.
!#zh
<br/>
使 slow motion fast forward <br/>
1.0 slow motion ,使 1.0<br/>
使 fast forward 使 1.0<br/>
Scheduler
@param timeScale timeScale
*/
setTimeScale(timeScale: number): void;
/**
!#en Returns time scale of scheduler.
!#zh
*/
getTimeScale(): number;
/**
!#en 'update' the scheduler. (You should NEVER call this method, unless you know what you are doing.)
!#zh update ()
@param dt delta time
*/
update(dt: number): void;
/**
!#en
<p>
The scheduled method will be called every 'interval' seconds.<br/>
If paused is YES, then it won't be called until it is resumed.<br/>
If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.<br/>
If the callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.<br/>
repeat let the action be repeated repeat + 1 times, use cc.macro.REPEAT_FOREVER to let the action run continuously<br/>
delay is the amount of time the action will wait before it'll start<br/>
</p>
!#zh
<br/>
paused true resume <br/>
<br/>
interval 0
使 scheduleUpdateForTarget <br/>
使<br/>
repeat repeat + 1 使 cc.macro.REPEAT_FOREVER
<br/>
delay
@param callback callback
@param target target
@param interval interval
@param repeat repeat
@param delay delay
@param paused paused
@example
```js
//register a schedule to scheduler
cc.director.getScheduler().schedule(callback, this, interval, !this._isRunning);
```
*/
schedule(callback: Function, target: any, interval: number, repeat: number, delay: number, paused?: boolean): void;
schedule(callback: Function, target: any, interval: number, paused?: boolean): void;
/**
!#en
Schedules the update callback for a given target,
During every frame after schedule started, the "update" function of target will be invoked.
!#zh
使 update
update "update"
@param target target
@param priority priority
@param paused paused
*/
scheduleUpdate(target: any, priority: number, paused: boolean): void;
/**
!#en
Unschedules a callback for a callback and a given target.
If you want to unschedule the "update", use `unscheduleUpdate()`
!#zh
update 使 unscheduleUpdate()
@param callback The callback to be unscheduled
@param target The target bound to the callback.
*/
unschedule(callback: Function, target: any): void;
/**
!#en Unschedules the update callback for a given target.
!#zh update
@param target The target to be unscheduled.
*/
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.
*/
unscheduleAllForTarget(target: any): void;
/**
!#en
Unschedules all scheduled callbacks from all targets including the system callbacks.<br/>
You should NEVER call this method, unless you know what you are doing.
!#zh
<br/>
*/
unscheduleAll(): void;
/**
!#en
Unschedules all callbacks from all targets with a minimum priority.<br/>
You should only call this with `PRIORITY_NON_SYSTEM_MIN` or higher.
!#zh
<br/>
PRIORITY_NON_SYSTEM_MIN
@param minPriority The minimum priority of selector to be unscheduled. Which means, all selectors which
priority is higher than minPriority will be unscheduled.
*/
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.
*/
isScheduled(callback: Function, target: any): boolean;
/**
!#en
Pause all selectors from all targets.<br/>
You should NEVER call this method, unless you know what you are doing.
!#zh
<br/>
*/
pauseAllTargets(): void;
/**
!#en
Pause all selectors from all targets with a minimum priority. <br/>
You should only call this with kCCPriorityNonSystemMin or higher.
!#zh
<br/>
PRIORITY_NON_SYSTEM_MIN
@param minPriority minPriority
*/
pauseAllTargetsWithMinPriority(minPriority: number): void;
/**
!#en
Resume selectors on a set of targets.<br/>
This can be useful for undoing a call to pauseAllCallbacks.
!#zh
<br/>
pauseAllCallbacks
@param targetsToResume targetsToResume
*/
resumeTargets(targetsToResume: any[]): void;
/**
!#en
Pauses the target.<br/>
All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.<br/>
If the target is not present, nothing happens.
!#zh
<br/>
<br/>
@param target target
*/
pauseTarget(target: any): void;
/**
!#en
Resumes the target.<br/>
The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.<br/>
If the target is not present, nothing happens.
!#zh
<br/>
<br/>
@param target target
*/
resumeTarget(target: any): void;
/**
!#en Returns whether or not the target is paused.
!#zh
@param target target
*/
isTargetPaused(target: any): boolean;
/** !#en Priority level reserved for system services.
!#zh */
static PRIORITY_SYSTEM: number;
/** !#en Minimum priority level for user scheduling.
!#zh */
static PRIORITY_NON_SYSTEM: number;
}
/** !#en cc.VideoPlayer is a component for playing videos, you can use it for showing videos in your game. Because different platforms have different authorization, API and control methods for VideoPlayer component. And have not yet formed a unified standard, only Web, iOS, and Android platforms are currently supported.
!#zh Video VideoPlayer API WebiOS Android */
export class VideoPlayer extends Component {
/** !#en The resource type of videoplayer, REMOTE for remote url and LOCAL for local file path.
!#zh REMOTE URLLOCAL */
resourceType: VideoPlayer.ResourceType;
/** !#en The remote URL of video.
!#zh URL */
remoteURL: string;
/** !#en The local video full path.
!#zh URL */
clip: string;
/** !#en The current playback time of the now playing item in seconds, you could also change the start playback time.
!#zh */
currentTime: number;
/** !#en The volume of the video.
!#zh 0.0 ~ 1.0 */
volume: number;
/** !#en Mutes the VideoPlayer. Mute sets the volume=0, Un-Mute restore the original volume.
!#zh 0 */
mute: boolean;
/** !#en Whether keep the aspect ration of the original video.
!#zh */
keepAspectRatio: boolean;
/** !#en Whether play video in fullscreen mode.
!#zh */
isFullscreen: boolean;
/** !#en Always below the game view (only useful on Web. Note: The specific effects are not guaranteed to be consistent, depending on whether each browser supports or restricts).
!#zh Web */
stayOnBottom: boolean;
/** !#en the video player's callback, it will be triggered when certain event occurs, like: playing, paused, stopped and completed.
!#zh */
videoPlayerEvent: Component.EventHandler[];
/**
!#en If a video is paused, call this method could resume playing. If a video is stopped, call this method to play from scratch.
!#zh
*/
play(): void;
/**
!#en If a video is paused, call this method to resume playing.
!#zh
*/
resume(): void;
/**
!#en If a video is playing, call this method to pause playing.
!#zh
*/
pause(): void;
/**
!#en If a video is playing, call this method to stop playing immediately.
!#zh
*/
stop(): void;
/**
!#en Gets the duration of the video
!#zh
*/
getDuration(): number;
/**
!#en Determine whether video is playing or not.
!#zh
*/
isPlaying(): boolean;
/**
!#en if you don't need the VideoPlayer and it isn't in any running Scene, you should
call the destroy method on this component or the associated node explicitly.
Otherwise, the created DOM element won't be removed from web page.
!#zh
使 VideoPlayer destroy
DOM Web
@example
```js
videoplayer.node.parent = null; // or videoplayer.node.removeFromParent(false);
// when you don't need videoplayer anymore
videoplayer.node.destroy();
```
*/
destroy(): boolean;
}
/** Class for particle asset handling. */
export class ParticleAsset extends Asset {
}
/** Particle System base class. <br/>
Attributes of a Particle System:<br/>
- emmision rate of the particles<br/>
- Gravity Mode (Mode A): <br/>
- gravity <br/>
- direction <br/>
- speed +- variance <br/>
- tangential acceleration +- variance<br/>
- radial acceleration +- variance<br/>
- Radius Mode (Mode B): <br/>
- startRadius +- variance <br/>
- endRadius +- variance <br/>
- rotate +- variance <br/>
- Properties common to all modes: <br/>
- life +- life variance <br/>
- start spin +- variance <br/>
- end spin +- variance <br/>
- start size +- variance <br/>
- end size +- variance <br/>
- start color +- variance <br/>
- end color +- variance <br/>
- life +- variance <br/>
- blending function <br/>
- texture <br/>
<br/>
cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).<br/>
'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d, <br/>
cocos2d uses a another approach, but the results are almost identical.<br/>
cocos2d supports all the variables used by Particle Designer plus a bit more: <br/>
- spinning particles (supported when using ParticleSystem) <br/>
- tangential acceleration (Gravity mode) <br/>
- radial acceleration (Gravity mode) <br/>
- radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only) <br/>
It is possible to customize any of the above mentioned properties in runtime. Example: <br/> */
export class ParticleSystem extends RenderComponent implements BlendFunc {
/** !#en Play particle in edit mode.
!#zh */
preview: boolean;
/** !#en
If set custom to true, then use custom properties insteadof read particle file.
!#zh */
custom: boolean;
/** !#en The plist file.
!#zh plist */
file: ParticleAsset;
/** !#en SpriteFrame used for particles display
!#zh SpriteFrame */
spriteFrame: SpriteFrame;
/** !#en Texture of Particle System, readonly, please use spriteFrame to setup new texture
!#zh 使 spriteFrame */
texture: string;
/** !#en Current quantity of particles that are being simulated.
!#zh */
particleCount: number;
/** !#en Indicate whether the system simulation have stopped.
!#zh */
stopped: boolean;
/** !#en If set to true, the particle system will automatically start playing on onLoad.
!#zh true */
playOnLoad: boolean;
/** !#en Indicate whether the owner node will be auto-removed when it has no particles left.
!#zh */
autoRemoveOnFinish: boolean;
/** !#en Indicate whether the particle system is activated.
!#zh */
active: boolean;
/** !#en Maximum particles of the system.
!#zh */
totalParticles: number;
/** !#en How many seconds the emitter wil run. -1 means 'forever'.
!#zh -1 */
duration: number;
/** !#en Emission rate of the particles.
!#zh */
emissionRate: number;
/** !#en Life of each particle setter.
!#zh */
life: number;
/** !#en Variation of life.
!#zh */
lifeVar: number;
/** !#en Start color of each particle.
!#zh */
startColor: Color;
/** !#en Variation of the start color.
!#zh */
startColorVar: Color;
/** !#en Ending color of each particle.
!#zh */
endColor: Color;
/** !#en Variation of the end color.
!#zh */
endColorVar: Color;
/** !#en Angle of each particle setter.
!#zh */
angle: number;
/** !#en Variation of angle of each particle setter.
!#zh */
angleVar: number;
/** !#en Start size in pixels of each particle.
!#zh */
startSize: number;
/** !#en Variation of start size in pixels.
!#zh */
startSizeVar: number;
/** !#en End size in pixels of each particle.
!#zh */
endSize: number;
/** !#en Variation of end size in pixels.
!#zh */
endSizeVar: number;
/** !#en Start angle of each particle.
!#zh */
startSpin: number;
/** !#en Variation of start angle.
!#zh */
startSpinVar: number;
/** !#en End angle of each particle.
!#zh */
endSpin: number;
/** !#en Variation of end angle.
!#zh */
endSpinVar: number;
/** !#en Source position of the emitter.
!#zh */
sourcePos: Vec2;
/** !#en Variation of source position.
!#zh */
posVar: Vec2;
/** !#en Particles movement type.
!#zh */
positionType: ParticleSystem.PositionType;
/** !#en Particles emitter modes.
!#zh */
emitterMode: ParticleSystem.EmitterMode;
/** !#en Gravity of the emitter.
!#zh */
gravity: Vec2;
/** !#en Speed of the emitter.
!#zh */
speed: number;
/** !#en Variation of the speed.
!#zh */
speedVar: number;
/** !#en Tangential acceleration of each particle. Only available in 'Gravity' mode.
!#zh */
tangentialAccel: number;
/** !#en Variation of the tangential acceleration.
!#zh */
tangentialAccelVar: number;
/** !#en Acceleration of each particle. Only available in 'Gravity' mode.
!#zh */
radialAccel: number;
/** !#en Variation of the radial acceleration.
!#zh */
radialAccelVar: number;
/** !#en Indicate whether the rotation of each particle equals to its direction. Only available in 'Gravity' mode.
!#zh */
rotationIsDir: boolean;
/** !#en Starting radius of the particles. Only available in 'Radius' mode.
!#zh */
startRadius: number;
/** !#en Variation of the starting radius.
!#zh */
startRadiusVar: number;
/** !#en Ending radius of the particles. Only available in 'Radius' mode.
!#zh */
endRadius: number;
/** !#en Variation of the ending radius.
!#zh */
endRadiusVar: number;
/** !#en Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode.
!#zh */
rotatePerS: number;
/** !#en Variation of the degress to rotate a particle around the source pos per second.
!#zh */
rotatePerSVar: number;
/** !#en The Particle emitter lives forever.
!#zh */
static DURATION_INFINITY: number;
/** !#en The starting size of the particle is equal to the ending size.
!#zh */
static START_SIZE_EQUAL_TO_END_SIZE: number;
/** !#en The starting radius of the particle is equal to the ending radius.
!#zh */
static START_RADIUS_EQUAL_TO_END_RADIUS: number;
/**
!#en Stop emitting particles. Running particles will continue to run until they die.
!#zh
@example
```js
// stop particle system.
myParticleSystem.stopSystem();
```
*/
stopSystem(): void;
/**
!#en Kill all living particles.
!#zh
@example
```js
// play particle system.
myParticleSystem.resetSystem();
```
*/
resetSystem(): void;
/**
!#en Whether or not the system is full.
!#zh
*/
isFull(): boolean;
/**
!#en Sets a new texture with a rect. The rect is in texture position and size.
Please use spriteFrame property instead, this function is deprecated since v1.9
!#zh
spriteFrame v1.9
@param texture texture
@param rect rect
*/
setTextureWithRect(texture: Texture2D, rect: Rect): void;
/** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost.
!#zh */
srcBlendFactor: macro.BlendFactor;
/** !#en specify the destination Blend Factor.
!#zh */
dstBlendFactor: macro.BlendFactor;
}
/** cc.TMXLayerInfo contains the information about the layers like:
- Layer name
- Layer size
- Layer opacity at creation time (it can be modified at runtime)
- Whether the layer is visible (if it's not visible, then the CocosNode won't be created)
This information is obtained from the TMX file. */
export class TMXLayerInfo {
/** Properties of the layer info. */
properties: any;
}
/** cc.TMXImageLayerInfo contains the information about the image layers.
This information is obtained from the TMX file. */
export class TMXImageLayerInfo {
}
/** <p>cc.TMXObjectGroupInfo contains the information about the object group like:
- group name
- group size
- group opacity at creation time (it can be modified at runtime)
- Whether the group is visible
This information is obtained from the TMX file.</p> */
export class TMXObjectGroupInfo {
/** Properties of the ObjectGroup info. */
properties: any[];
}
/** <p>cc.TMXTilesetInfo contains the information about the tilesets like: <br />
- Tileset name<br />
- Tileset spacing<br />
- Tileset margin<br />
- size of the tiles<br />
- Image used for the tiles<br />
- Image size<br />
This information is obtained from the TMX file. </p> */
export class TMXTilesetInfo {
/** Tileset name */
name: string;
/** First grid */
firstGid: number;
/** Spacing */
spacing: number;
/** Margin */
margin: number;
/** Texture containing the tiles (should be sprite sheet / texture atlas) */
sourceImage: any;
/** Size in pixels of the image */
imageSize: Size;
}
/** <p>cc.TMXMapInfo contains the information about the map like: <br/>
- Map orientation (hexagonal, isometric or orthogonal)<br/>
- Tile size<br/>
- Map size</p>
<p>And it also contains: <br/>
- Layers (an array of TMXLayerInfo objects)<br/>
- Tilesets (an array of TMXTilesetInfo objects) <br/>
- ObjectGroups (an array of TMXObjectGroupInfo objects) </p>
<p>This information is obtained from the TMX file. </p> */
export class TMXMapInfo {
/** Properties of the map info. */
properties: any[];
/** Map orientation. */
orientation: number;
/** Parent element. */
parentElement: any;
/** Parent GID. */
parentGID: number;
/** Layer attributes. */
layerAttrs: any;
/** Is reading storing characters stream. */
storingCharacters: boolean;
/** Current string stored from characters stream. */
currentString: string;
/** Width of the map */
mapWidth: number;
/** Height of the map */
mapHeight: number;
/** Width of a tile */
tileWidth: number;
/** Height of a tile */
tileHeight: number;
static ATTRIB_NONE: number;
static ATTRIB_BASE64: number;
static ATTRIB_GZIP: number;
static ATTRIB_ZLIB: number;
}
/** !#en Render the TMX layer.
!#zh TMX layer */
export class TiledLayer extends Component {
/**
!#en enable or disable culling
!#zh
@param value value
*/
enableCulling(value: any): void;
/**
!#en Adds user's node into layer.
!#zh
@param node node
*/
addUserNode(node: Node): boolean;
/**
!#en Removes user's node.
!#zh
@param node node
*/
removeUserNode(node: Node): boolean;
/**
!#en Destroy user's node.
!#zh
@param node node
*/
destroyUserNode(node: Node): void;
/**
!#en Gets the layer name.
!#zh
@example
```js
let layerName = tiledLayer.getLayerName();
cc.log(layerName);
```
*/
getLayerName(): string;
/**
!#en Set the layer name.
!#zh
@param layerName layerName
@example
```js
tiledLayer.setLayerName("New Layer");
```
*/
SetLayerName(layerName: string): void;
/**
!#en Return the value for the specific property name.
!#zh
@param propertyName propertyName
@example
```js
let property = tiledLayer.getProperty("info");
cc.log(property);
```
*/
getProperty(propertyName: string): any;
/**
!#en Returns the position in pixels of a given tile coordinate.
!#zh tile
@param pos position or x
@param y y
@example
```js
let pos = tiledLayer.getPositionAt(cc.v2(0, 0));
cc.log("Pos: " + pos);
let pos = tiledLayer.getPositionAt(0, 0);
cc.log("Pos: " + pos);
```
*/
getPositionAt(pos: Vec2|number, y?: number): Vec2;
/**
!#en
Sets the tiles gid (gid = tile global id) at a given tiles rect.
!#zh
tile gid (gid = tile id)
@param gids an array contains gid
@param beginCol begin col number
@param beginRow begin row number
@param totalCols count of column
@example
```js
tiledLayer.setTilesGIDAt([1, 1, 1, 1], 10, 10, 2)
```
*/
setTilesGIDAt(gids: any[], beginCol: number, beginRow: number, totalCols: number): void;
/**
!#en
Sets the tile gid (gid = tile global id) at a given tile coordinate.<br />
The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor . Tileset Mgr +1.<br />
If a tile is already placed at that position, then it will be removed.
!#zh
tile gid (gid = tile id)
tile GID 使 tileGIDAt <br />
tile
@param gid gid
@param posOrX position or x
@param flagsOrY flags or y
@param flags flags
@example
```js
tiledLayer.setTileGIDAt(1001, 10, 10, 1)
```
*/
setTileGIDAt(gid: number, posOrX: Vec2|number, flagsOrY: number, flags?: number): void;
/**
!#en
Returns the tiles data.An array fill with GIDs. <br />
!#zh
tiles . GID. <br />
*/
getTiles(): number[];
/**
!#en
Returns the tile gid at a given tile coordinate. <br />
if it returns 0, it means that the tile is empty. <br />
!#zh
tile flags tile GID. <br />
0 tile <br />
@param pos or x
@param y y
@example
```js
let tileGid = tiledLayer.getTileGIDAt(0, 0);
```
*/
getTileGIDAt(pos: Vec2|number, y?: number): number;
/**
!#en Layer orientation, which is the same as the map orientation.
!#zh Layer ()
@example
```js
let orientation = tiledLayer.getLayerOrientation();
cc.log("Layer Orientation: " + orientation);
```
*/
getLayerOrientation(): number;
/**
!#en properties from the layer. They can be added using Tiled.
!#zh layer 使 Tiled
@example
```js
let properties = tiledLayer.getProperties();
cc.log("Properties: " + properties);
```
*/
getProperties(): any;
/**
!#en
Get the TiledTile with the tile coordinate.<br/>
If there is no tile in the specified coordinate and forceCreate parameter is true, <br/>
then will create a new TiledTile at the coordinate.
The renderer will render the tile with the rotation, scale, position and color property of the TiledTile.
!#zh
tile TiledTile <br/>
tile forceCreate TiledTile <br/>
tile 使 TiledTile <br/>
@param x x
@param y y
@param forceCreate forceCreate
@example
```js
let tile = tiledLayer.getTiledTileAt(100, 100, true);
cc.log(tile);
```
*/
getTiledTileAt(x: number, y: number, forceCreate: boolean): TiledTile;
/**
!#en
Change tile to TiledTile at the specified coordinate.
!#zh
tile TiledTile
@param x x
@param y y
@param tiledTile tiledTile
*/
setTiledTileAt(x: number, y: number, tiledTile: TiledTile): TiledTile;
/**
!#en Return texture.
!#zh
@param index The index of textures
*/
getTexture(index: any): Texture2D;
/**
!#en Return texture.
!#zh
*/
getTextures(): Texture2D;
/**
!#en Set the texture.
!#zh
@param texture texture
*/
setTexture(texture: Texture2D): void;
/**
!#en Set the texture.
!#zh
@param textures textures
*/
setTexture(textures: Texture2D): void;
/**
!#en Gets layer size.
!#zh
@example
```js
let size = tiledLayer.getLayerSize();
cc.log("layer size: " + size);
```
*/
getLayerSize(): Size;
/**
!#en Size of the map's tile (could be different from the tile's size).
!#zh tile ( tile )
@example
```js
let mapTileSize = tiledLayer.getMapTileSize();
cc.log("MapTile size: " + mapTileSize);
```
*/
getMapTileSize(): Size;
/**
!#en Gets Tile set first information for the layer.
!#zh layer 0 Tileset
@param index The index of tilesets
*/
getTileSet(index: any): TMXTilesetInfo;
/**
!#en Gets tile set all information for the layer.
!#zh layer Tileset
*/
getTileSet(): TMXTilesetInfo;
/**
!#en Sets tile set information for the layer.
!#zh layer tileset
@param tileset tileset
*/
setTileSet(tileset: TMXTilesetInfo): void;
/**
!#en Sets Tile set information for the layer.
!#zh layer Tileset
@param tilesets tilesets
*/
setTileSets(tilesets: TMXTilesetInfo): void;
}
/** !#en Renders a TMX Tile Map in the scene.
!#zh tmx Tile Map */
export class TiledMap extends Component {
/** !#en The TiledMap Asset.
!#zh TiledMap */
tmxAsset: TiledMapAsset;
/**
!#en Gets the map size.
!#zh
@example
```js
let mapSize = tiledMap.getMapSize();
cc.log("Map Size: " + mapSize);
```
*/
getMapSize(): Size;
/**
!#en Gets the tile size.
!#zh tile
@example
```js
let tileSize = tiledMap.getTileSize();
cc.log("Tile Size: " + tileSize);
```
*/
getTileSize(): Size;
/**
!#en map orientation.
!#zh
@example
```js
let mapOrientation = tiledMap.getMapOrientation();
cc.log("Map Orientation: " + mapOrientation);
```
*/
getMapOrientation(): number;
/**
!#en object groups.
!#zh
@example
```js
let objGroups = titledMap.getObjectGroups();
for (let i = 0; i < objGroups.length; ++i) {
cc.log("obj: " + objGroups[i]);
}
```
*/
getObjectGroups(): TiledObjectGroup[];
/**
!#en Return the TMXObjectGroup for the specific group.
!#zh TMXObjectGroup
@param groupName groupName
@example
```js
let group = titledMap.getObjectGroup("Players");
cc.log("ObjectGroup: " + group);
```
*/
getObjectGroup(groupName: string): TiledObjectGroup;
/**
!#en enable or disable culling
!#zh
@param value value
*/
enableCulling(value: any): void;
/**
!#en Gets the map properties.
!#zh
@example
```js
let properties = titledMap.getProperties();
for (let i = 0; i < properties.length; ++i) {
cc.log("Properties: " + properties[i]);
}
```
*/
getProperties(): any[];
/**
!#en Return All layers array.
!#zh layer
@example
```js
let layers = titledMap.getLayers();
for (let i = 0; i < layers.length; ++i) {
cc.log("Layers: " + layers[i]);
}
```
*/
getLayers(): TiledLayer[];
/**
!#en return the cc.TiledLayer for the specific layer.
!#zh layer
@param layerName layerName
@example
```js
let layer = titledMap.getLayer("Player");
cc.log(layer);
```
*/
getLayer(layerName: string): TiledLayer;
/**
!#en Return the value for the specific property name.
!#zh
@param propertyName propertyName
@example
```js
let property = titledMap.getProperty("info");
cc.log("Property: " + property);
```
*/
getProperty(propertyName: string): string;
/**
!#en Return properties dictionary for tile GID.
!#zh GID
@param GID GID
@example
```js
let properties = titledMap.getPropertiesForGID(GID);
cc.log("Properties: " + properties);
```
*/
getPropertiesForGID(GID: number): any;
}
/** Class for tiled map asset handling. */
export class TiledMapAsset extends Asset {
textures: Texture2D[];
textureNames: string[];
textureSizes: Size[];
imageLayerTextures: Texture2D[];
imageLayerTextureNames: string[];
}
/** !#en Renders the TMX object group.
!#zh tmx object group */
export class TiledObjectGroup extends Component {
/**
!#en Offset position of child objects.
!#zh
@example
```js
let offset = tMXObjectGroup.getPositionOffset();
```
*/
getPositionOffset(): Vec2;
/**
!#en List of properties stored in a dictionary.
!#zh
@example
```js
let offset = tMXObjectGroup.getProperties();
```
*/
getProperties(): any;
/**
!#en Gets the Group name.
!#zh
@example
```js
let groupName = tMXObjectGroup.getGroupName;
```
*/
getGroupName(): string;
/**
!#en
Return the object for the specific object name. <br />
It will return the 1st object found on the array for the given name.
!#zh
@param objectName objectName
@example
```js
let object = tMXObjectGroup.getObject("Group");
```
*/
getObject(objectName: string): any;
/**
!#en Gets the objects.
!#zh
@example
```js
let objects = tMXObjectGroup.getObjects();
```
*/
getObjects(): any[];
}
/** !#en TiledTile can control the specified map tile.
It will apply the node rotation, scale, translate to the map tile.
You can change the TiledTile's gid to change the map tile's style.
!#zh TiledTile
gid */
export class TiledTile extends Component {
/** !#en Specify the TiledTile horizontal coordinateuse map tile as the unit.
!#zh TiledTile */
x: number;
/** !#en Specify the TiledTile vertical coordinateuse map tile as the unit.
!#zh TiledTile */
y: number;
/** !#en Specify the TiledTile gid.
!#zh TiledTile gid */
gid: number;
}
/** !#en cc.WebView is a component for display web pages in the game. Because different platforms have different authorization, API and control methods for WebView component. And have not yet formed a unified standard, only Web, iOS, and Android platforms are currently supported.
!#zh WebView WebView API WebiOS Android */
export class WebView extends Component {
/** !#en A given URL to be loaded by the WebView, it should have a http or https prefix.
!#zh WebView http https */
url: string;
/** !#en The webview's event callback , it will be triggered when certain webview event occurs.
!#zh WebView */
webviewLoadedEvents: Component.EventHandler[];
/**
!#en
Set javascript interface scheme (see also setOnJSCallback). <br/>
Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.<br/>
Please refer to the official documentation for more details.
!#zh
JavaScript 'setOnJSCallback' 使<br/>
Android iOS Web <br/>
@param scheme scheme
*/
setJavascriptInterfaceScheme(scheme: string): void;
/**
!#en
This callback called when load URL that start with javascript
interface scheme (see also setJavascriptInterfaceScheme). <br/>
Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.<br/>
Please refer to the official documentation for more details.
!#zh
URL JavaScript <br/>
Android iOSWeb
@param callback callback
*/
setOnJSCallback(callback: Function): void;
/**
!#en
Evaluates JavaScript in the context of the currently displayed page. <br/>
Please refer to the official document for more details <br/>
Note: Cross domain issues need to be resolved by yourself <br/>
!#zh
WebView <br/>
@param str str
*/
evaluateJS(str: string): void;
/**
!#en if you don't need the WebView and it isn't in any running Scene, you should
call the destroy method on this component or the associated node explicitly.
Otherwise, the created DOM element won't be removed from web page.
!#zh
使 WebView destroy
DOM Web
@example
```js
webview.node.parent = null; // or webview.node.removeFromParent(false);
// when you don't need webview anymore
webview.node.destroy();
```
*/
destroy(): boolean;
}
/** !#en
cc.NodePool is the cache pool designed for node type.<br/>
It can helps you to improve your game performance for objects which need frequent release and recreate operations<br/>
It's recommended to create cc.NodePool instances by node type, the type corresponds to node type in game design, not the class,
for example, a prefab is a specific node type. <br/>
When you create a node pool, you can pass a Component which contains `unuse`, `reuse` functions to control the content of node.<br/>
Some common use case is :<br/>
1. Bullets in game (die very soon, massive creation and recreation, no side effect on other objects)<br/>
2. Blocks in candy crash (massive creation and recreation)<br/>
etc...
!#zh
cc.NodePool <br/>
<br/>
cocos2d-x cc.pool 使 cc.NodePool
NodePool 使 prefab <br/>
unuse, reuse <br/>
<br/>
1.<br/>
2.
.... */
export class NodePool {
/**
!#en
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
```js
properties: {
template: cc.Prefab
},
onLoad () {
// MyTemplateHandler is a component with 'unuse' and 'reuse' to handle events when node is reused or recycled.
this.myPool = new cc.NodePool('MyTemplateHandler');
}
```
*/
constructor(poolHandlerComp?: {prototype: Component}|string);
/** !#en The pool handler component, it could be the class name or the constructor.
!#zh */
poolHandlerComp: Function|string;
/**
!#en The current available size in the pool
!#zh
*/
size(): number;
/**
!#en Destroy all cached nodes in the pool
!#zh
*/
clear(): void;
/**
!#en Put a new Node into the pool.
It will automatically remove the node from its parent without cleanup.
It will also invoke unuse method of the poolHandlerComp if exist.
!#zh
cleanup
poolHandlerComp unuse
@param obj obj
@example
```js
let myNode = cc.instantiate(this.template);
this.myPool.put(myNode);
```
*/
put(obj: Node): void;
/**
!#en Get a obj from pool, if no available object in pool, null will be returned.
This function will invoke the reuse function of poolHandlerComp if exist.
!#zh
poolHandlerComp reuse
@param params !#en Params to pass to 'reuse' method in poolHandlerComp !#zh poolHandlerComp 'reuse'
@example
```js
let newNode = this.myPool.get();
```
*/
get(...params: any[]): Node;
}
/** !#en
Camera is usefull when making reel game or other games which need scroll screen.
Using camera will be more efficient than moving node to scroll screen.
Camera
!#zh
使 */
export class Camera extends Component {
/** !#en
The camera zoom ratio, only support 2D camera.
!#zh
, 2D camera */
zoomRatio: number;
/** !#en
Field of view. The width of the Cameras view angle, measured in degrees along the local Y axis.
!#zh
*/
fov: number;
/** !#en
The viewport size of the Camera when set to orthographic projection.
!#zh
*/
orthoSize: number;
/** !#en
The near clipping plane.
!#zh
*/
nearClip: number;
/** !#en
The far clipping plane.
!#zh
*/
farClip: number;
/** !#en
Is the camera orthographic (true) or perspective (false)?
!#zh
*/
ortho: boolean;
/** !#en
Four values (0 ~ 1) that indicate where on the screen this camera view will be drawn.
!#zh
0 ~ 1 */
rect: Rect;
/** !#en
This is used to render parts of the scene selectively.
!#zh
*/
cullingMask: number;
/** !#en
Determining what to clear when camera rendering.
!#zh
*/
clearFlags: Camera.ClearFlags;
/** !#en
The color with which the screen will be cleared.
!#zh
*/
backgroundColor: Color;
/** !#en
Camera's depth in the camera rendering order. Cameras with higher depth are rendered after cameras with lower depth.
!#zh
*/
depth: number;
/** !#en
Destination render texture.
Usually cameras render directly to screen, but for some effects it is useful to make a camera render into a texture.
!#zh
RenderTexture
使 RenderTexture RenderTexture */
targetTexture: RenderTexture;
/** !#en
Sets the camera's render stages.
!#zh
*/
renderStages: number;
/** !#en Whether auto align camera viewport to screen
!#zh */
alignWithScreen: boolean;
/** !#en
The primary camera in the scene. Returns the rear most rendered camera, which is the camera with the lowest depth.
!#zh
depth */
static main: Camera;
/** !#en
All enabled cameras.
!#zh
*/
static cameras: Camera[];
/**
!#en
Get the first camera which the node belong to.
!#zh
@param node node
*/
static findCamera(node: Node): Camera;
/**
!#en
Get the screen to world matrix, only support 2D camera which alignWithScreen is true.
!#zh
alignWithScreen true 2D
@param out the matrix to receive the result
*/
getScreenToWorldMatrix2D(out: Mat4): Mat4;
/**
!#en
Get the world to camera matrix, only support 2D camera which alignWithScreen is true.
!#zh
alignWithScreen true 2D
@param out the matrix to receive the result
*/
getWorldToScreenMatrix2D(out: Mat4): Mat4;
/**
!#en
Convert point from screen to world.
!#zh
@param screenPosition screenPosition
@param out out
*/
getScreenToWorldPoint(screenPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3;
/**
!#en
Convert point from world to screen.
!#zh
@param worldPosition worldPosition
@param out out
*/
getWorldToScreenPoint(worldPosition: Vec3|Vec2, out?: Vec3|Vec2): Vec3;
/**
!#en
Get a ray from screen position
!#zh
线
@param screenPos screenPos
*/
getRay(screenPos: Vec2): geomUtils.Ray;
/**
!#en
Check whether the node is in the camera.
!#zh
@param node the node which need to check
*/
containsNode(node: Node): boolean;
/**
!#en
Render the camera manually.
!#zh
@param rootNode rootNode
*/
render(rootNode?: Node): void;
/**
!#en
Returns the matrix that transform the node's (local) space coordinates into the camera's space coordinates.
!#zh
@param node the node which should transform
*/
getNodeToCameraTransform(node: Node): AffineTransform;
/**
!#en
Conver a camera coordinates point to world coordinates.
!#zh
@param point the point which should transform
@param out the point to receive the result
*/
getCameraToWorldPoint(point: Vec2, out?: Vec2): Vec2;
/**
!#en
Conver a world coordinates point to camera coordinates.
!#zh
@param point point
@param out the point to receive the result
*/
getWorldToCameraPoint(point: Vec2, out?: Vec2): Vec2;
/**
!#en
Get the camera to world matrix
!#zh
@param out the matrix to receive the result
*/
getCameraToWorldMatrix(out: Mat4): Mat4;
/**
!#en
Get the world to camera matrix
!#zh
@param out the matrix to receive the result
*/
getWorldToCameraMatrix(out: Mat4): Mat4;
}
/** !#en The Light Component
!#zh */
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 {
/** !#en
Normal loading pipeline
!#zh
线 */
pipeline: cc.AssetManager.Pipeline;
/** !#en
Fetching pipeline
!#zh
线 */
fetchPipeline: cc.AssetManager.Pipeline;
/** !#en
Url transformer
!#zh
Url */
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<AssetManager.Bundle>;
/** !#en
The collection of asset which is already loaded, you can remove cache with {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}}
!#zh
{{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} 来移除缓存 */
assets: AssetManager.Cache<cc.Asset>;
/** !#en
Manage relationship between asset and its dependencies
!#zh
*/
dependUtil: cc.AssetManager.DependUtil;
/** !#en
Whether or not cache the loaded asset
!#zh
*/
cacheAsset: boolean;
/** !#en
Whether or not load asset forcely, if it is true, asset will be loaded regardless of error
!#zh
, true */
force: boolean;
/** !#en
Some useful function
!#zh
*/
utils: cc.AssetManager.Helper;
/** !#en
Manage all downloading task
!#zh
*/
downloader: cc.AssetManager.Downloader;
/** !#en
Manage all parsing task
!#zh
*/
parser: cc.AssetManager.Parser;
/** !#en
Manage internal asset
!#zh
*/
builtins: cc.AssetManager.Builtins;
/** !#en
Manage all packed asset
!#zh
*/
packManager: cc.AssetManager.PackManager;
/** !#en
Cache manager is a module which controls all caches downloaded from server in non-web platform.
!#zh
WEB */
cacheManager: cc.AssetManager.CacheManager|null;
/** !#en
The preset of options
!#zh
*/
presets: Record<string, Record<string, any>>;
/** !#en
The builtin 'main' bundle
!#zh
main */
main: cc.AssetManager.Bundle;
/** !#en
The builtin 'resources' bundle
!#zh
resources */
resources: cc.AssetManager.Bundle;
/** !#en
The builtin 'internal' bundle
!#zh
internal */
internal: cc.AssetManager.Bundle;
/**
!#en
Initialize assetManager with options
!#zh
@param options options
*/
init(options: Record<string, any>): void;
/**
!#en
Get the bundle which has been loaded
!#zh
@param name The name of bundle
@example
```js
// ${project}/assets/test1
cc.assetManager.getBundle('test1');
cc.assetManager.getBundle('resources');
```
*/
getBundle (name: string): cc.AssetManager.Bundle;
/**
!#en
Remove this bundle. NOTE: The asset whthin this bundle will not be released automatically, you can call {{#crossLink "Bundle/releaseAll:method"}}{{/crossLink}} manually before remove it if you need
!#zh
, , {{#crossLink "Bundle/releaseAll:method"}}{{/crossLink}}
@param bundle The bundle to be removed
*/
removeBundle(bundle: cc.AssetManager.Bundle): void;
/**
!#en
General interface used to load assets with a progression callback and a complete callback. You can achieve almost all effect you want with combination of `requests` and `options`.
It is highly recommended that you use more simple API, such as `load`, `loadDir` etc. Every custom parameter in `options` will be distribute to each of `requests`.
if request already has same one, the parameter in request will be given priority. Besides, if request has dependencies, `options` will distribute to dependencies too.
Every custom parameter in `requests` will be tranfered to handler of `downloader` and `parser` as `options`.
You can register you own handler downloader or parser to collect these custom parameters for some effect.
Reserved Keyword: `uuid`, `url`, `path`, `dir`, `scene`, `type`, `priority`, `preset`, `audioLoadMode`, `ext`, `bundle`, `onFileProgress`, `maxConcurrency`, `maxRequestsPerFrame`
`maxRetryCount`, `version`, `responseType`, `withCredentials`, `mimeType`, `timeout`, `header`, `reload`, `cacheAsset`, `cacheEnabled`,
Please DO NOT use these words as custom options!
!#zh
`request` `options` 使API `load``loadDir`
`options` `requests` request `requests`
`options` request `options` `downloader`, `parser` ,
`downloader`, `parser`
: `uuid`, `url`, `path`, `dir`, `scene`, `type`, `priority`, `preset`, `audioLoadMode`, `ext`, `bundle`, `onFileProgress`, `maxConcurrency`, `maxRequestsPerFrame`
`maxRetryCount`, `version`, `responseType`, `withCredentials`, `mimeType`, `timeout`, `header`, `reload`, `cacheAsset`, `cacheEnabled`,
使!
@param requests The request you want to load
@param options Optional parameters
@param onProgress Callback invoked when progression change
@param onComplete Callback invoked when finish loading
@example
```js
cc.assetManager.loadAny({url: 'http://example.com/a.png'}, (err, img) => cc.log(img));
cc.assetManager.loadAny(['60sVXiTH1D/6Aft4MRt9VC'], (err, assets) => cc.log(assets));
cc.assetManager.loadAny([{ uuid: '0cbZa5Y71CTZAccaIFluuZ'}, {url: 'http://example.com/a.png'}], (err, assets) => cc.log(assets));
cc.assetManager.downloader.register('.asset', (url, options, onComplete) => {
url += '?userName=' + options.userName + "&password=" + options.password;
cc.assetManager.downloader.downloadFile(url, null, onComplete);
});
cc.assetManager.parser.register('.asset', (file, options, onComplete) => {
var json = JSON.parse(file);
var skin = json[options.skin];
var model = json[options.model];
onComplete(null, {skin, model});
});
cc.assetManager.loadAny({ url: 'http://example.com/my.asset', skin: 'xxx', model: 'xxx', userName: 'xxx', password: 'xxx' });
```
*/
loadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], options: Record<string, any>, onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, data: any) => void): void;
loadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, data: any) => void): void;
loadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], options: Record<string, any>, onComplete: (err: Error, data: any) => void): void;
loadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], onComplete: (err: Error, data: any) => void): void;
loadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], options: Record<string, any>): void;
loadAny(requests: string | string[] | Record<string, any> | Record<string, any>[]): void;
/**
!#en
General interface used to preload assets with a progression callback and a complete callback.It is highly recommended that you use more simple API, such as `preloadRes`, `preloadResDir` etc.
Everything about preload is just likes `cc.assetManager.loadAny`, the difference is `cc.assetManager.preloadAny` will only download asset but not parse asset. You need to invoke `cc.assetManager.loadAny(preloadTask)`
to finish loading asset
!#zh
使 API `preloadRes`, `preloadResDir` `preloadAny` `loadAny` `preloadAny` `cc.assetManager.loadAny(preloadTask)`
@param requests The request you want to preload
@param options Optional parameters
@param onProgress Callback invoked when progression change
@param onComplete Callback invoked when finish preloading
@example
```js
cc.assetManager.preloadAny('0cbZa5Y71CTZAccaIFluuZ', (err) => cc.assetManager.loadAny('0cbZa5Y71CTZAccaIFluuZ'));
```
*/
preloadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], options: Record<string, any>, onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void;
preloadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], onProgress: (finished: number, total: number, item: cc.AssetManager.RequestItem) => void, onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void;
preloadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], options: Record<string, any>, onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void;
preloadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], onComplete: (err: Error, items: cc.AssetManager.RequestItem[]) => void): void;
preloadAny(requests: string | string[] | Record<string, any> | Record<string, any>[], options: Record<string, any>): void;
preloadAny(requests: string | string[] | Record<string, any> | Record<string, any>[]): void;
/**
!#en
Load native file of asset, if you check the option 'Async Load Assets', you may need to load native file with this before you use the asset
!#zh
'延迟加载资源'使
@param asset The asset
@param options Some optional parameters
@param onComplete Callback invoked when finish loading
@example
```js
cc.assetManager.postLoadNative(texture, (err) => console.log(err));
```
*/
postLoadNative(asset: cc.Asset, options: Record<string, any>, onComplete: (err: Error) => void): void;
postLoadNative(asset: cc.Asset, onComplete: (err: Error) => void): void;
postLoadNative(asset: cc.Asset, options: Record<string, any>): void;
postLoadNative(asset: cc.Asset): void;
/**
!#en
Load remote asset with url, such as audio, image, text and so on.
!#zh
使 url
@param url The url of asset
@param options Some optional parameters
@param onComplete Callback invoked when finish loading
@example
```js
cc.assetManager.loadRemote('http://www.cloud.com/test1.jpg', (err, texture) => console.log(err));
cc.assetManager.loadRemote('http://www.cloud.com/test2.mp3', (err, audioClip) => console.log(err));
cc.assetManager.loadRemote('http://www.cloud.com/test3', { ext: '.png' }, (err, texture) => console.log(err));
```
*/
loadRemote<T extends cc.Asset>(url: string, options: Record<string, any>, onComplete: (err: Error, asset: T) => void): void;
loadRemote<T extends cc.Asset>(url: string, onComplete: (err: Error, asset: T) => void): void;
loadRemote<T extends cc.Asset>(url: string, options: Record<string, any>): void;
loadRemote<T extends cc.Asset>(url: string): void;
/**
!#en
Load script
!#zh
@param url Url of the script
@param options Some optional paramters
@param onComplete Callback when script loaded or failed
@example
```js
loadScript('http://localhost:8080/index.js', null, (err) => console.log(err));
```
*/
loadScript(url: string|string[], options: Record<string, any>, onComplete: (err: Error) => void): void;
loadScript(url: string|string[], onComplete: (err: Error) => void): void;
loadScript(url: string|string[], options: Record<string, any>): void;
loadScript(url: string|string[]): void;
/**
!#en
load bundle
!#zh
@param nameOrUrl The name or root path of bundle
@param options Some optional paramter, same like downloader.downloadFile
@param onComplete Callback when bundle loaded or failed
@example
```js
loadBundle('http://localhost:8080/test', null, (err, bundle) => console.log(err));
```
*/
loadBundle(nameOrUrl: string, options: Record<string, any>, onComplete: (err: Error, bundle: cc.AssetManager.Bundle) => void): void;
loadBundle(nameOrUrl: string, onComplete: (err: Error, bundle: cc.AssetManager.Bundle) => void): void;
loadBundle(nameOrUrl: string, options: Record<string, any>): void;
loadBundle(nameOrUrl: string): void;
/**
!#en
Release asset and it's dependencies.
This method will not only remove the cache of the asset in assetManager, but also clean up its content.
For example, if you release a texture, the texture asset and its gl texture data will be freed up.
Notice, this method may cause the texture to be unusable, if there are still other nodes use the same texture, they may turn to black and report gl errors.
!#zh
, assetManager
texture texture gl
GL
@param asset The asset to be released
@example
```js
// release a texture which is no longer need
cc.assetManager.releaseAsset(texture);
```
*/
releaseAsset(asset: cc.Asset): void;
/**
!#en
Release all assets. Refer to {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} for detailed informations.
!#zh
{{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}}
*/
releaseAll(): void;
}
/** `cc.loader` is deprecated, please backup your project and upgrade to {{#crossLink "AssetManager"}}{{/crossLink}} */
export class loader {
/** `cc.loader.onProgress` is deprecated, please transfer onProgress to API as a parameter */
static onProgress: any;
/**
`cc.loader.load` is deprecated, please use {{#crossLink "AssetManager/loadAny:method"}}{{/crossLink}} instead
@param resources Url list in an array
@param progressCallback Callback invoked when progression change
@param completeCallback Callback invoked when all resources loaded
*/
static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, completeCallback?: Function): void;
static load(resources: string|string[]|{uuid?: string, url?: string, type?: string}, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: Function|null): void;
/**
`cc.loader.getXMLHttpRequest` is deprecated, please use `XMLHttpRequest` directly
*/
static getXMLHttpRequest(): XMLHttpRequest;
/**
`cc.loader.getItem` is deprecated, please use `cc.assetManager.asset.get` instead
@param id The id of the item
*/
static getItem(id: any): any;
/**
`cc.loader.loadRes` is deprecated, please use {{#crossLink "Bundle/load:method"}}{{/crossLink}} instead
@param url Url of the target resource.
The url is relative to the "resources" folder, extensions must be omitted.
@param type Only asset of type will be loaded if this argument is supplied.
@param progressCallback Callback invoked when progression change.
@param completeCallback Callback invoked when the resource loaded.
*/
static loadRes(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void;
static loadRes(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any) => void): void;
static loadRes(url: string, type: typeof cc.Asset): void;
static loadRes(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void;
static loadRes(url: string, completeCallback: (error: Error, resource: any) => void): void;
static loadRes(url: string): void;
/**
`cc.loader.loadResArray` is deprecated, please use {{#crossLink "Bundle/load:method"}}{{/crossLink}} instead
@param urls Array of URLs of the target resource.
The url is relative to the "resources" folder, extensions must be omitted.
@param type Only asset of type will be loaded if this argument is supplied.
@param progressCallback Callback invoked when progression change.
@param completeCallback A callback which is called when all assets have been loaded, or an error occurs.
*/
static loadResArray(url: string[], type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void;
static loadResArray(url: string[], type: typeof cc.Asset, completeCallback: (error: Error, resource: any[]) => void): void;
static loadResArray(url: string[], type: typeof cc.Asset): void;
static loadResArray(url: string[], progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[]) => void)|null): void;
static loadResArray(url: string[], completeCallback: (error: Error, resource: any[]) => void): void;
static loadResArray(url: string[]): void;
static loadResArray(url: string[], type: typeof cc.Asset[]): void;
/**
`cc.loader.loadResDir` is deprecated, please use {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} instead
@param url Url of the target folder.
The url is relative to the "resources" folder, extensions must be omitted.
@param type Only asset of type will be loaded if this argument is supplied.
@param progressCallback Callback invoked when progression change.
@param completeCallback A callback which is called when all assets have been loaded, or an error occurs.
*/
static loadResDir(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void;
static loadResDir(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void;
static loadResDir(url: string, type: typeof cc.Asset): void;
static loadResDir(url: string, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void;
static loadResDir(url: string, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void;
static loadResDir(url: string): void;
/**
`cc.loader.getRes` is deprecated, please use {{#crossLink "Bundle/get:method"}}{{/crossLink}} instead
@param url url
@param type Only asset of type will be returned if this argument is supplied.
*/
static getRes(url: string, type?: Function): any;
/**
`cc.loader.getDependsRecursively` is deprecated, please use use {{#crossLink "DependUtil/getDepsRecursively:method"}}{{/crossLink}} instead
@param owner The owner asset or the resource url or the asset's uuid
*/
static getDependsRecursively(owner: Asset|string): any[];
/** `cc.loader.assetLoader` was removed, assetLoader and md5Pipe were merged into {{#crossLink "AssetManager/transformPipeline:property"}}{{/crossLink}} */
static assetLoader: any;
/** `cc.loader.md5Pipe` is deprecated, assetLoader and md5Pipe were merged into {{#crossLink "AssetManager/transformPipeline:property"}}{{/crossLink}} */
static md5Pipe: any;
/** `cc.loader.downloader` is deprecated, please use {{#crossLink "AssetManager/downloader:property"}}{{/crossLink}} instead */
static downloader: any;
/** `cc.loader.loader` is deprecated, please use {{#crossLink "AssetManager/parser:property"}}{{/crossLink}} instead */
static loader: any;
/**
`cc.loader.addDownloadHandlers` is deprecated, please use `cc.assetManager.downloader.register` instead
@param extMap Custom supported types with corresponded handler
*/
static addDownloadHandlers(extMap: any): void;
/**
`cc.loader.addLoadHandlers` is deprecated, please use `cc.assetManager.parser.register` instead
@param extMap Custom supported types with corresponded handler
*/
static addLoadHandlers(extMap: any): void;
/**
`cc.loader.release` is deprecated, please use {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} instead
@param asset asset
*/
static release(asset: Asset|string|any[]): void;
/**
`cc.loader.releaseAsset` is deprecated, please use {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} instead
@param asset asset
*/
static releaseAsset(asset: Asset): void;
/**
`cc.loader.releaseRes` is deprecated, please use {{#crossLink "AssetManager/releaseRes:method"}}{{/crossLink}} instead
@param url url
@param type Only asset of type will be released if this argument is supplied.
*/
static releaseRes(url: string, type?: Function): void;
/**
`cc.loader.releaseResDir` was removed, please use {{#crossLink "AssetManager/releaseRes:method"}}{{/crossLink}} instead
*/
static releaseResDir(): void;
/**
`cc.loader.releaseAll` is deprecated, please use {{#crossLink "AssetManager/releaseAll:method"}}{{/crossLink}} instead
*/
static releaseAll(): void;
/**
`cc.loader.removeItem` is deprecated, please use `cc.assetManager.assets.remove` instead
@param id The id of the item
*/
static removeItem(id: any): boolean;
/**
`cc.loader.setAutoRelease` is deprecated, if you want to prevent some asset from auto releasing, please use {{#crossLink "Asset/addRef:method"}}{{/crossLink}} instead
@param assetOrUrlOrUuid asset object or the raw asset's url or uuid
@param autoRelease indicates whether should release automatically
*/
static setAutoRelease(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void;
/**
`cc.loader.setAutoReleaseRecursively` is deprecated, if you want to prevent some asset from auto releasing, please use {{#crossLink "Asset/addRef:method"}}{{/crossLink}} instead
@param assetOrUrlOrUuid asset object or the raw asset's url or uuid
@param autoRelease indicates whether should release automatically
*/
static setAutoReleaseRecursively(assetOrUrlOrUuid: Asset|string, autoRelease: boolean): void;
/**
`cc.loader.isAutoRelease` is deprecated
@param assetOrUrl asset object or the raw asset's url
*/
static isAutoRelease(assetOrUrl: Asset|string): boolean;
}
/** `cc.url` is deprecated */
export class url {
/**
`cc.url.raw` is deprecated, please use `cc.resources.load` directly, or use `Asset.nativeUrl` instead.
@param url url
*/
static raw(url: string): string;
}
/** `cc.LoadingItems` was removed, please use {{#crossLink "Task"}}{{/crossLink}} instead */
export class LoadingItems {
}
/** !#en
Base class for handling assets used in Creator.<br/>
You may want to override:<br/>
- createNode<br/>
- getset functions of _nativeAsset<br/>
- cc.Object._serialize<br/>
- cc.Object._deserialize<br/>
!#zh
Creator <br/>
<br/>
- createNode <br/>
- _nativeAsset getset <br/>
- cc.Object._serialize<br/>
- cc.Object._deserialize<br/> */
export class Asset extends Object {
/** `cc.Asset.url` is deprecated, please use {{#crossLink "Asset/nativeUrl:property"}}{{/crossLink}} instead */
url: string;
/** !#en
Whether the asset is loaded or not.
!#zh
*/
loaded: boolean;
/** !#en
Returns the url of this asset's native object, if none it will returns an empty string.
!#zh
URL */
nativeUrl: string;
/** !#en
The number of reference
!#zh
*/
refCount: number;
/** !#en Indicates whether its dependent raw assets can support deferred load if the owner scene (or prefab) is marked as `asyncLoadAssets`.
!#zh Prefab `asyncLoadAssets` */
static preventDeferredLoadDependents: boolean;
/** !#en Indicates whether its native object should be preloaded from native url.
!#zh */
static preventPreloadNativeObject: boolean;
/**
!#en
Returns the asset's url.
The `Asset` object overrides the `toString()` method of the `Object` object.
For `Asset` objects, the `toString()` method returns a string representation of the object.
JavaScript calls the `toString()` method automatically when an asset is to be represented as a text value or when a texture is referred to in a string concatenation.
!#zh
URL
Asset Object `toString()`
Asset `toString()`
JavaScript `toString()`
*/
toString(): string;
/**
!#en
Create a new node using this asset in the scene.<br/>
If this type of asset dont have its corresponding node type, this method should be null.
!#zh
使<br/>
@param callback callback
*/
createNode(callback: (error: string, node: any) => void): void;
/**
!#en
Add references of asset
!#zh
*/
addRef(): cc.Asset;
/**
!#en
Reduce references of asset and it will be auto released when refCount equals 0.
!#zh
*/
decRef(): cc.Asset;
}
/** Predefined constants */
export class macro {
/** `cc.macro.DOWNLOAD_MAX_CONCURRENT` is deprecated now, please use {{#crossLink "Downloader/maxConcurrency:property"}}{{/crossLink}} instead */
static DOWNLOAD_MAX_CONCURRENT: number;
/** PI / 180 */
static RAD: number;
/** One degree */
static DEG: number;
static REPEAT_FOREVER: number;
static FLT_EPSILON: number;
/** Minimum z index value for node */
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;
/** Oriented vertically */
static ORIENTATION_PORTRAIT: number;
/** Oriented horizontally */
static ORIENTATION_LANDSCAPE: number;
/** Oriented automatically */
static ORIENTATION_AUTO: number;
/** <p>
If enabled, the texture coordinates will be calculated by using this formula: <br/>
- texCoord.left = (rect.x*2+1) / (texture.wide*2); <br/>
- texCoord.right = texCoord.left + (rect.width*2-2)/(texture.wide*2); <br/>
<br/>
The same for bottom and top. <br/>
<br/>
This formula prevents artifacts by using 99% of the texture. <br/>
The "correct" way to prevent artifacts is by expand the texture's border with the same color by 1 pixel<br/>
<br/>
Affected component: <br/>
- cc.TMXLayer <br/>
<br/>
Enabled by default. To disabled set it to 0. <br/>
To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h
</p> */
static FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX: number;
/** Position of the FPS (Default: 0,0 (bottom-left corner))<br/>
To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h */
static DIRECTOR_STATS_POSITION: Vec2;
/** <p>
If enabled, actions that alter the position property (eg: CCMoveBy, CCJumpBy, CCBezierBy, etc..) will be stacked. <br/>
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. <br/>
If disabled, only the last run action will take effect.
</p> */
static ENABLE_STACKABLE_ACTIONS: number;
/** !#en
The timeout to determine whether a touch is no longer active and should be removed.
The reason to add this timeout is due to an issue in X5 browser core,
when X5 is presented in wechat on Android, if a touch is glissed from the bottom up, and leave the page area,
no touch cancel event is triggered, and the touch will be considered active forever.
After multiple times of this action, our maximum touches number will be reached and all new touches will be ignored.
So this new mechanism can remove the touch that should be inactive if it's not updated during the last 5000 milliseconds.
Though it might remove a real touch if it's just not moving for the last 5 seconds which is not easy with the sensibility of mobile touch screen.
You can modify this value to have a better behavior if you find it's not enough.
!#zh
X5 bug
touch cancel touch end
5000 */
static TOUCH_TIMEOUT: number;
/** !#en
The maximum vertex count for a single batched draw call.
!#zh
*/
static BATCH_VERTEX_COUNT: number;
/** !#en
Whether or not enabled tiled map auto culling. If you set the TiledMap skew or rotation, then need to manually disable this, otherwise, the rendering will be wrong.
!#zh
skew, rotation */
static ENABLE_TILEDMAP_CULLING: boolean;
/** !#en
Boolean that indicates if the canvas contains an alpha channel, default sets to false for better performance.
Though if you want to make your canvas background transparent and show other dom elements at the background,
you can set it to true before `cc.game.run`.
Web only.
!#zh
Canvas alpha false
Canvas DOM `cc.game.run` true
Web */
static ENABLE_TRANSPARENT_CANVAS: boolean;
/** !#en
Boolean that indicates if the WebGL context is created with `antialias` option turned on, default value is false.
Set it to true could make your game graphics slightly smoother, like texture hard edges when rotated.
Whether to use this really depend on your game design and targeted platform,
device with retina display usually have good detail on graphics with or without this option,
you probably don't want antialias if your game style is pixel art based.
Also, it could have great performance impact with some browser / device using software MSAA.
You can set it to true before `cc.game.run`.
Web only.
!#zh
WebGL Context 齿 false
true 齿
retina
使齿
`cc.game.run`
Web */
static ENABLE_WEBGL_ANTIALIAS: boolean;
/** !#en
Whether or not enable auto culling.
This feature have been removed in v2.0 new renderer due to overall performance consumption.
We have no plan currently to re-enable auto culling.
If your game have more dynamic objects, we suggest to disable auto culling.
If your game have more static objects, we suggest to enable auto culling.
!#zh
v2.0
*/
static ENABLE_CULLING: boolean;
/** !#en
Whether to clear the original image cache after uploaded a texture to GPU. If cleared, [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) will not be supported.
Normally you don't need to enable this option on the web platform, because Image object doesn't consume too much memory.
But on WeChat Game platform, the current version cache decoded data in Image object, which has high memory usage.
So we enabled this option by default on WeChat, so that we can release Image cache immediately after uploaded to GPU.
!#zh
GPU [](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。
Web Web Image
Image
GL Image */
static CLEANUP_IMAGE_CACHE: boolean;
/** !#en
Whether or not show mesh wire frame.
!#zh
线 */
static SHOW_MESH_WIREFRAME: boolean;
/** !#en
Whether or not show mesh normal.
!#zh
线 */
static SHOW_MESH_NORMAL: boolean;
/** !#en
Whether to enable multi-touch.
!#zh
*/
static ENABLE_MULTI_TOUCH: boolean;
/** References:
https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap
https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap
!#en
Whether to use image bitmap first. If enabled, memory usage will increase.
!#zh
使 image bitmap */
static ALLOW_IMAGE_BITMAP: boolean;
/** !#en
Whether to use native TTF renderer which is faster but layout slightly different.
!#zh
使, . */
static ENABLE_NATIVE_TTF_RENDERER: boolean;
/** !#en
The image format supported by the engine defaults, and the supported formats may differ in different build platforms and device types.
Currently all platform and device support ['.webp', '.jpg', '.jpeg', '.bmp', '.png'], The iOS mobile platform also supports the PVR format
!#zh
['.webp', '.jpg', '.jpeg', '.bmp', '.png']. Ios PVR */
static SUPPORT_TEXTURE_FORMATS: string[];
}
/** !#en Class for audio data handling.
!#zh */
export class AudioClip extends Asset implements EventTarget {
/** !#en Get the audio clip duration
!#zh */
duration: number;
/**
!#en Checks whether the EventTarget object has any callback registered for a specific type of event.
!#zh
@param type The type of event.
*/
hasEventListener(type: string): boolean;
/**
!#en
Register an callback of a specific event type on the EventTarget.
This type of event should be triggered via `emit`.
!#zh
`emit`
@param type A string representing the event type to listen for.
@param callback The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null
@example
```js
eventTarget.on('fire', function () {
cc.log("fire in the hole");
}, node);
```
*/
on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
/**
!#en
Removes the listeners previously registered with the same type, callback, target and or useCapture,
if only type is passed as parameter, all listeners registered with that type will be removed.
!#zh
useCapture type type
@param type A string representing the event type being removed.
@param callback The callback to remove.
@param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
@example
```js
// register fire eventListener
var callback = eventTarget.on('fire', function () {
cc.log("fire in the hole");
}, target);
// remove fire event listener
eventTarget.off('fire', callback, target);
// remove all fire event listeners
eventTarget.off('fire');
```
*/
off(type: string, callback?: Function, target?: any): void;
/**
!#en Removes all callbacks previously registered with the same target (passed as parameter).
This is not for removing all listeners in the current event target,
and this is not for removing all listeners the target parameter have registered.
It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
!#zh EventTarget target
EventTarget target
target EventTarget
@param target The target to be searched for all related listeners
*/
targetOff(target: any): void;
/**
!#en
Register an callback of a specific event type on the EventTarget,
the callback will remove itself after the first time it is triggered.
!#zh
@param type A string representing the event type to listen for.
@param callback The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null
@example
```js
eventTarget.once('fire', function () {
cc.log("this is the callback and will be invoked only once");
}, node);
```
*/
once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void;
/**
!#en
Send an event with the event object.
!#zh
@param event event
*/
dispatchEvent(event: Event): void;
/**
!#en
Destroy all callbackInfos.
!#zh
*/
clear(): void;
}
/** !#en Class for BitmapFont handling.
!#zh */
export class BitmapFont extends Font {
}
/** undefined */
export class BufferAsset extends Asset {
}
/** !#en Class for Font handling.
!#zh */
export class Font extends Asset {
}
/** !#en
Class for JSON file. When the JSON file is loaded, this object is returned.
The parsed JSON object can be accessed through the `json` attribute in it.<br>
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 <br>
JSON `.txt` `TextAsset` `JsonAsset` */
export class JsonAsset extends Asset {
/** The loaded JSON object. */
json: any;
}
/** !#en Class for LabelAtlas handling.
!#zh */
export class LabelAtlas extends BitmapFont {
}
/** !#en Class for prefab handling.
!#zh */
export class Prefab extends Asset {
/** the main cc.Node in the prefab */
data: Node;
/** !#zh
prefab 使 prefab
!#en
Indicates the optimization policy for instantiating this prefab.
Set to a suitable value based on usage, can optimize the time it takes to instantiate this prefab. */
optimizationPolicy: Prefab.OptimizationPolicy;
/** !#en Indicates the raw assets of this prefab can be load after prefab loaded.
!#zh Prefab Prefab */
asyncLoadAssets: boolean;
readonly: boolean;
/**
Dynamically translation prefab data into minimized code.<br/>
This method will be called automatically before the first time the prefab being instantiated,
but you can re-call to refresh the create function once you modified the original prefab data in script.
*/
compileCreateFunction(): void;
}
/** Render textures are textures that can be rendered to. */
export class RenderTexture extends Texture2D {
/**
!#en
Init the render texture with size.
!#zh
render texture
@param width width
@param height height
@param depthStencilFormat depthStencilFormat
*/
initWithSize(width?: number, height?: number, depthStencilFormat?: number): void;
/**
!#en
Get pixels from render texture, the pixels data stores in a RGBA Uint8Array.
It will return a new (width * height * 4) length Uint8Array by default
You can specify a data to store the pixels to reuse the data,
you and can specify other params to specify the texture region to read.
!#zh
render texture RGBA Uint8Array
x x 4 Uint8Array
data
@param data data
@param x x
@param y y
@param w w
@param h h
*/
readPixels(data?: Uint8Array, x?: number, y?: number, w?: number, h?: number): Uint8Array;
}
/** !#en Class for scene handling.
!#zh */
export class SceneAsset extends Asset {
scene: Scene;
/** !#en Indicates the raw assets of this scene can be load after scene launched.
!#zh */
asyncLoadAssets: boolean;
}
/** !#en Class for script handling.
!#zh Script */
export class _Script extends Asset {
}
/** !#en Class for JavaScript handling.
!#zh JavaScript */
export class _JavaScript extends Asset {
}
/** !#en Class for TypeScript handling.
!#zh TypeScript */
export class TypeScript extends Asset {
}
/** !#en Class for sprite atlas handling.
!#zh */
export class SpriteAtlas extends Asset {
/**
Returns the texture of the sprite atlas
*/
getTexture(): Texture2D;
/**
Returns the sprite frame correspond to the given key in sprite atlas.
@param key key
*/
getSpriteFrame(key: string): SpriteFrame;
/**
Returns the sprite frames in sprite atlas.
*/
getSpriteFrames(): SpriteFrame[];
}
/** !#en
A cc.SpriteFrame has:<br/>
- texture: A cc.Texture2D that will be used by render components<br/>
- rectangle: A rectangle of the texture
!#zh
SpriteFrame <br/>
- 使 Texture2D <br/>
- */
export class SpriteFrame extends Asset implements EventTarget {
/** !#en Top border of the sprite
!#zh sprite */
insetTop: number;
/** !#en Bottom border of the sprite
!#zh sprite */
insetBottom: number;
/** !#en Left border of the sprite
!#zh sprite */
insetLeft: number;
/** !#en Right border of the sprite
!#zh sprite */
insetRight: number;
/**
!#en
Constructor of SpriteFrame class.
!#zh
SpriteFrame
@param filename filename
@param rect rect
@param rotated Whether the frame is rotated in the texture
@param offset The offset of the frame in the texture
@param originalSize The size of the frame in the texture
*/
constructor(filename?: string|Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size);
/**
!#en Returns whether the texture have been loaded
!#zh
*/
textureLoaded(): boolean;
/**
!#en Returns whether the sprite frame is rotated in the texture.
!#zh SpriteFrame
*/
isRotated(): boolean;
/**
!#en Set whether the sprite frame is rotated in the texture.
!#zh SpriteFrame
@param bRotated bRotated
*/
setRotated(bRotated: boolean): void;
/**
!#en Returns whether the sprite frame is flip x axis in the texture.
!#zh SpriteFrame x
*/
isFlipX(): boolean;
/**
!#en Returns whether the sprite frame is flip y axis in the texture.
!#zh SpriteFrame y
*/
isFlipY(): boolean;
/**
!#en Set whether the sprite frame is flip x axis in the texture.
!#zh SpriteFrame x
@param flipX flipX
*/
setFlipX(flipX: boolean): void;
/**
!#en Set whether the sprite frame is flip y axis in the texture.
!#zh SpriteFrame y
@param flipY flipY
*/
setFlipY(flipY: boolean): void;
/**
!#en Returns the rect of the sprite frame in the texture.
!#zh SpriteFrame
*/
getRect(): Rect;
/**
!#en Sets the rect of the sprite frame in the texture.
!#zh SpriteFrame
@param rect rect
*/
setRect(rect: Rect): void;
/**
!#en Returns the original size of the trimmed image.
!#zh
*/
getOriginalSize(): Size;
/**
!#en Sets the original size of the trimmed image.
!#zh
@param size size
*/
setOriginalSize(size: Size): void;
/**
!#en Returns the texture of the frame.
!#zh 使
*/
getTexture(): Texture2D;
/**
!#en Returns the offset of the frame in the texture.
!#zh
*/
getOffset(): Vec2;
/**
!#en Sets the offset of the frame in the texture.
!#zh
@param offsets offsets
*/
setOffset(offsets: Vec2): void;
/**
!#en Clone the sprite frame.
!#zh SpriteFrame
*/
clone(): SpriteFrame;
/**
!#en Set SpriteFrame with Texture, rect, rotated, offset and originalSize.<br/>
!#zh Texturerectrotatedoffset originalSize SpriteFrame
@param texture texture
@param rect rect
@param rotated rotated
@param offset offset
@param originalSize originalSize
*/
setTexture(texture: Texture2D, rect?: Rect, rotated?: boolean, offset?: Vec2, originalSize?: Size): boolean;
/**
!#en If a loading scene (or prefab) is marked as `asyncLoadAssets`, all the textures of the SpriteFrame which
associated by user's custom Components in the scene, will not preload automatically.
These textures will be load when Sprite component is going to render the SpriteFrames.
You can call this method if you want to load the texture early.
!#zh Prefab `asyncLoadAssets` SpriteFrame
Sprite SpriteFrame
@example
```js
if (spriteFrame.textureLoaded()) {
this._onSpriteFrameLoaded();
}
else {
spriteFrame.once('load', this._onSpriteFrameLoaded, this);
spriteFrame.ensureLoadTexture();
}
```
*/
ensureLoadTexture(): void;
/**
!#en
If you do not need to use the SpriteFrame temporarily, you can call this method so that its texture could be garbage collected. Then when you need to render the SpriteFrame, you should call `ensureLoadTexture` manually to reload texture.
!#zh
使 SpriteFrame GC SpriteFrame `ensureLoadTexture`
*/
clearTexture(): void;
/**
!#en Checks whether the EventTarget object has any callback registered for a specific type of event.
!#zh
@param type The type of event.
*/
hasEventListener(type: string): boolean;
/**
!#en
Register an callback of a specific event type on the EventTarget.
This type of event should be triggered via `emit`.
!#zh
`emit`
@param type A string representing the event type to listen for.
@param callback The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null
@example
```js
eventTarget.on('fire', function () {
cc.log("fire in the hole");
}, node);
```
*/
on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
/**
!#en
Removes the listeners previously registered with the same type, callback, target and or useCapture,
if only type is passed as parameter, all listeners registered with that type will be removed.
!#zh
useCapture type type
@param type A string representing the event type being removed.
@param callback The callback to remove.
@param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
@example
```js
// register fire eventListener
var callback = eventTarget.on('fire', function () {
cc.log("fire in the hole");
}, target);
// remove fire event listener
eventTarget.off('fire', callback, target);
// remove all fire event listeners
eventTarget.off('fire');
```
*/
off(type: string, callback?: Function, target?: any): void;
/**
!#en Removes all callbacks previously registered with the same target (passed as parameter).
This is not for removing all listeners in the current event target,
and this is not for removing all listeners the target parameter have registered.
It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
!#zh EventTarget target
EventTarget target
target EventTarget
@param target The target to be searched for all related listeners
*/
targetOff(target: any): void;
/**
!#en
Register an callback of a specific event type on the EventTarget,
the callback will remove itself after the first time it is triggered.
!#zh
@param type A string representing the event type to listen for.
@param callback The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null
@example
```js
eventTarget.once('fire', function () {
cc.log("this is the callback and will be invoked only once");
}, node);
```
*/
once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void;
/**
!#en
Send an event with the event object.
!#zh
@param event event
*/
dispatchEvent(event: Event): void;
/**
!#en
Destroy all callbackInfos.
!#zh
*/
clear(): void;
}
/** !#en Class for TTFFont handling.
!#zh TTF */
export class TTFFont extends Font {
}
/** !#en Class for text file.
!#zh */
export class TextAsset extends Asset {
/** The text contents of the resource. */
text: string;
}
/** This class allows to easily create OpenGL or Canvas 2D textures from images or raw data. */
export class Texture2D extends Asset implements EventTarget {
/** !#en Sets whether generate mipmaps for the texture
!#zh mipmaps */
genMipmaps: boolean;
/** !#en
Sets whether texture can be packed into texture atlas.
If need use texture uv in custom Effect, please sets packable to false.
!#zh
Effect 使 UV */
packable: boolean;
/** !#en
Whether the texture is loaded or not
!#zh
*/
loaded: boolean;
/** !#en
Texture width in pixel
!#zh
*/
width: number;
/** !#en
Texture height in pixel
!#zh
*/
height: number;
/**
!#en
Get renderer texture implementation object
extended from render.Texture2D
!#zh
*/
getImpl(): void;
/**
Update texture options, not available in Canvas render mode.
image, format, premultiplyAlpha can not be updated in native.
@param options options
*/
update(options: {image: DOMImageElement; genMipmaps: boolean; format: Texture2D.PixelFormat; minFilter: Texture2D.Filter; magFilter: Texture2D.Filter; wrapS: WrapMode; wrapT: WrapMode; premultiplyAlpha: boolean; }): void;
/**
!#en
Init with HTML element.
!#zh HTML Image Canvas
@param element element
@example
```js
var img = new Image();
img.src = dataURL;
texture.initWithElement(img);
```
*/
initWithElement(element: HTMLImageElement|HTMLCanvasElement): void;
/**
!#en
Intializes with texture data in ArrayBufferView.
!#zh 使 ArrayBufferView raw data
@param data data
@param pixelFormat pixelFormat
@param pixelsWidth pixelsWidth
@param pixelsHeight pixelsHeight
*/
initWithData(data: ArrayBufferView, pixelFormat: number, pixelsWidth: number, pixelsHeight: number): boolean;
/**
!#en
HTMLElement Object getter, available only on web.<br/>
Note: texture is packed into texture atlas by default<br/>
you should set texture.packable as false before getting Html element object.
!#zh HTML Image Canvas Web <br/>
<br/>
texture Html texture.packable false
*/
getHtmlElementObj(): HTMLImageElement;
/**
!#en
Destory this texture and immediately release its video memory. (Inherit from cc.Object.destroy)<br>
After destroy, this object is not usable anymore.
You can use cc.isValid(obj) to check whether the object is destroyed before accessing it.
!#zh
cc.Object.destroy<br/>
访使 cc.isValid(obj)
*/
destroy(): boolean;
/**
!#en
Pixel format of the texture.
!#zh
*/
getPixelFormat(): number;
/**
!#en
Whether or not the texture has their Alpha premultiplied.
!#zh GPU
*/
hasPremultipliedAlpha(): boolean;
/**
!#en
Handler of texture loaded event.
Since v2.0, you don't need to invoke this function, it will be invoked automatically after texture loaded.
!#zh v2.0
@param premultiplied premultiplied
*/
handleLoadedTexture(premultiplied?: boolean): void;
/**
!#en
Description of cc.Texture2D.
!#zh cc.Texture2D
*/
description(): string;
/**
!#en
Release texture, please use destroy instead.
!#zh 使 destroy
*/
releaseTexture(): void;
/**
!#en Sets the wrap s and wrap t options. <br/>
If the texture size is NPOT (non power of 2), then in can only use gl.CLAMP_TO_EDGE in gl.TEXTURE_WRAP_{S,T}.
!#zh
NPOTnon power of 2使 Texture2D.WrapMode.CLAMP_TO_EDGE
@param wrapS wrapS
@param wrapT wrapT
*/
setWrapMode(wrapS: Texture2D.WrapMode, wrapT: Texture2D.WrapMode): void;
/**
!#en Sets the minFilter and magFilter options
!#zh
@param minFilter minFilter
@param magFilter magFilter
*/
setFilters(minFilter: Texture2D.Filter, magFilter: Texture2D.Filter): void;
/**
!#en
Sets the flipY options
!#zh
@param flipY flipY
*/
setFlipY(flipY: boolean): void;
/**
!#en
Sets the premultiply alpha options
!#zh
@param premultiply premultiply
*/
setPremultiplyAlpha(premultiply: boolean): void;
/**
!#en Checks whether the EventTarget object has any callback registered for a specific type of event.
!#zh
@param type The type of event.
*/
hasEventListener(type: string): boolean;
/**
!#en
Register an callback of a specific event type on the EventTarget.
This type of event should be triggered via `emit`.
!#zh
`emit`
@param type A string representing the event type to listen for.
@param callback The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null
@example
```js
eventTarget.on('fire', function () {
cc.log("fire in the hole");
}, node);
```
*/
on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
/**
!#en
Removes the listeners previously registered with the same type, callback, target and or useCapture,
if only type is passed as parameter, all listeners registered with that type will be removed.
!#zh
useCapture type type
@param type A string representing the event type being removed.
@param callback The callback to remove.
@param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
@example
```js
// register fire eventListener
var callback = eventTarget.on('fire', function () {
cc.log("fire in the hole");
}, target);
// remove fire event listener
eventTarget.off('fire', callback, target);
// remove all fire event listeners
eventTarget.off('fire');
```
*/
off(type: string, callback?: Function, target?: any): void;
/**
!#en Removes all callbacks previously registered with the same target (passed as parameter).
This is not for removing all listeners in the current event target,
and this is not for removing all listeners the target parameter have registered.
It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
!#zh EventTarget target
EventTarget target
target EventTarget
@param target The target to be searched for all related listeners
*/
targetOff(target: any): void;
/**
!#en
Register an callback of a specific event type on the EventTarget,
the callback will remove itself after the first time it is triggered.
!#zh
@param type A string representing the event type to listen for.
@param callback The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null
@example
```js
eventTarget.once('fire', function () {
cc.log("this is the callback and will be invoked only once");
}, node);
```
*/
once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void;
/**
!#en
Send an event with the event object.
!#zh
@param event event
*/
dispatchEvent(event: Event): void;
/**
!#en
Destroy all callbackInfos.
!#zh
*/
clear(): void;
}
/** !#en Box Collider.
!#zh */
export class BoxCollider extends Collider implements Collider.Box {
/** !#en
Collider info in world coordinate.
!#zh
*/
world: ColliderInfo;
/** !#en Position offset
!#zh */
offset: Vec2;
/** !#en Box size
!#zh */
size: Size;
}
/** !#en Circle Collider.
!#zh */
export class CircleCollider extends Collider implements Collider.Circle {
/** !#en
Collider info in world coordinate.
!#zh
*/
world: ColliderInfo;
/** !#en Position offset
!#zh */
offset: Vec2;
/** !#en Circle radius
!#zh */
radius: number;
}
/** !#en Collider component base class.
!#zh */
export class Collider extends Component {
/** !#en Tag. If a node has several collider components, you can judge which type of collider is collided according to the tag.
!#zh 使 */
tag: number;
}
/** !#en
Collider Info.
!#zh
*/
export class ColliderInfo {
/** !#en
Collider aabb information of last frame
!#zh
aabb */
preAabb: Rect;
/** !#en
Collider aabb information of current frame
!#zh
aabb */
aabb: Rect;
/** !#en
Collider matrix
!#zh
*/
matrix: Mat4;
/** !#en
Collider radius (for CircleCollider)
!#zh
CircleCollider */
radius: number;
/** !#en
Collider position (for CircleCollider)
!#zh
CircleCollider */
position: Vec2;
/** !#en
Collider points (for BoxCollider and PolygonCollider)
!#zh
BoxCollider PolygonCollider */
points: Vec2[];
}
/** !#en
A simple collision manager class.
It will calculate whether the collider collides other colliders, if collides then call the callbacks.
!#zh
*/
export class CollisionManager implements EventTarget {
/** !#en
!#zh
*/
enabled: boolean;
/** !#en
!#zh
*/
enabledDrawBoundingBox: boolean;
/** !#en
!#zh
*/
enabledDebugDraw: boolean;
/**
!#en Checks whether the EventTarget object has any callback registered for a specific type of event.
!#zh
@param type The type of event.
*/
hasEventListener(type: string): boolean;
/**
!#en
Register an callback of a specific event type on the EventTarget.
This type of event should be triggered via `emit`.
!#zh
`emit`
@param type A string representing the event type to listen for.
@param callback The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null
@example
```js
eventTarget.on('fire', function () {
cc.log("fire in the hole");
}, node);
```
*/
on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
/**
!#en
Removes the listeners previously registered with the same type, callback, target and or useCapture,
if only type is passed as parameter, all listeners registered with that type will be removed.
!#zh
useCapture type type
@param type A string representing the event type being removed.
@param callback The callback to remove.
@param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
@example
```js
// register fire eventListener
var callback = eventTarget.on('fire', function () {
cc.log("fire in the hole");
}, target);
// remove fire event listener
eventTarget.off('fire', callback, target);
// remove all fire event listeners
eventTarget.off('fire');
```
*/
off(type: string, callback?: Function, target?: any): void;
/**
!#en Removes all callbacks previously registered with the same target (passed as parameter).
This is not for removing all listeners in the current event target,
and this is not for removing all listeners the target parameter have registered.
It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
!#zh EventTarget target
EventTarget target
target EventTarget
@param target The target to be searched for all related listeners
*/
targetOff(target: any): void;
/**
!#en
Register an callback of a specific event type on the EventTarget,
the callback will remove itself after the first time it is triggered.
!#zh
@param type A string representing the event type to listen for.
@param callback The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null
@example
```js
eventTarget.once('fire', function () {
cc.log("this is the callback and will be invoked only once");
}, node);
```
*/
once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void;
/**
!#en
Send an event with the event object.
!#zh
@param event event
*/
dispatchEvent(event: Event): void;
/**
!#en
Destroy all callbackInfos.
!#zh
*/
clear(): void;
}
/** !#en Intersection helper class
!#zh */
export class Intersection {
/**
!#en Test line and line
!#zh 线线
@param a1 The start point of the first line
@param a2 The end point of the first line
@param b1 The start point of the second line
@param b2 The end point of the second line
*/
static lineLine(a1: Vec2, a2: Vec2, b1: Vec2, b2: Vec2): boolean;
/**
!#en Test line and rect
!#zh 线
@param a1 The start point of the line
@param a2 The end point of the line
@param b The rect
*/
static lineRect(a1: Vec2, a2: Vec2, b: Rect): boolean;
/**
!#en Test line and polygon
!#zh 线
@param a1 The start point of the line
@param a2 The end point of the line
@param b The polygon, a set of points
*/
static linePolygon(a1: Vec2, a2: Vec2, b: Vec2[]): boolean;
/**
!#en Test rect and rect
!#zh
@param a The first rect
@param b The second rect
*/
static rectRect(a: Rect, b: Rect): boolean;
/**
!#en Test rect and polygon
!#zh
@param a The rect
@param b The polygon, a set of points
*/
static rectPolygon(a: Rect, b: Vec2[]): boolean;
/**
!#en Test polygon and polygon
!#zh
@param a The first polygon, a set of points
@param b The second polygon, a set of points
*/
static polygonPolygon(a: Vec2[], b: Vec2[]): boolean;
/**
!#en Test circle and circle
!#zh
@param a Object contains position and radius
@param b Object contains position and radius
*/
static circleCircle(a: {position: Vec2, radius: number}, b: {position: Vec2, radius: number}): boolean;
/**
!#en Test polygon and circle
!#zh
@param polygon The Polygon, a set of points
@param circle Object contains position and radius
*/
static polygonCircle(polygon: Vec2[], circle: {position: Vec2, radius: number}): boolean;
/**
!#en Test whether the point is in the polygon
!#zh
@param point The point
@param polygon The polygon, a set of points
*/
static pointInPolygon(point: Vec2, polygon: Vec2[]): boolean;
/**
!#en Calculate the distance of point to line.
!#zh 线线线线
@param point The point
@param start The start point of line
@param end The end point of line
@param isSegment whether this line is a segment
*/
static pointLineDistance(point: Vec2, start: Vec2, end: Vec2, isSegment: boolean): number;
}
/** !#en Polygon Collider.
!#zh */
export class PolygonCollider extends Collider implements Collider.Polygon {
/** !#en
Collider info in world coordinate.
!#zh
*/
world: ColliderInfo;
/** !#en Position offset
!#zh */
offset: Vec2;
/** !#en Polygon points
!#zh */
points: Vec2[];
}
/** !#en The touch event class
!#zh */
export class Touch {
/**
!#en Returns the current touch location in OpenGL coordinates.
!#zh
*/
getLocation(): Vec2;
/**
!#en Returns X axis location value.
!#zh X
*/
getLocationX(): number;
/**
!#en Returns Y axis location value.
!#zh Y
*/
getLocationY(): number;
/**
!#en Returns the previous touch location in OpenGL coordinates.
!#zh x y
*/
getPreviousLocation(): Vec2;
/**
!#en Returns the start touch location in OpenGL coordinates.
!#zh x y
*/
getStartLocation(): Vec2;
/**
!#en Returns the delta distance from the previous touche to the current one in screen coordinates.
!#zh x y
*/
getDelta(): Vec2;
/**
!#en Returns the current touch location in screen coordinates.
!#zh x y
*/
getLocationInView(): Vec2;
/**
!#en Returns the previous touch location in screen coordinates.
!#zh x y
*/
getPreviousLocationInView(): Vec2;
/**
!#en Returns the start touch location in screen coordinates.
!#zh x y
*/
getStartLocationInView(): Vec2;
/**
!#en Returns the id of cc.Touch.
!#zh ID
*/
getID(): number;
/**
!#en Sets information to touch.
!#zh
@param id id
@param x x
@param y y
*/
setTouchInfo(id: number, x: number, y: number): void;
}
/** !#en
EventTarget is an object to which an event is dispatched when something has occurred.
Entity are the most common event targets, but other objects can be event targets too.
Event targets are an important part of the Fireball event model.
The event target serves as the focal point for how events flow through the scene graph.
When an event such as a mouse click or a keypress occurs, Fireball dispatches an event object
into the event flow from the root of the hierarchy. The event object then makes its way through
the scene graph until it reaches the event target, at which point it begins its return trip through
the scene graph. This round-trip journey to the event target is conceptually divided into three phases:
- The capture phase comprises the journey from the root to the last node before the event target's node
- The target phase comprises only the event target node
- The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the tree
See also: http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
Event targets can implement the following methods:
- _getCapturingTargets
- _getBubblingTargets
!#zh
Node
<br/> */
export class EventTarget extends CallbacksInvoker {
/**
!#en Checks whether the EventTarget object has any callback registered for a specific type of event.
!#zh
@param type The type of event.
*/
hasEventListener(type: string): boolean;
/**
!#en
Register an callback of a specific event type on the EventTarget.
This type of event should be triggered via `emit`.
!#zh
`emit`
@param type A string representing the event type to listen for.
@param callback The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null
@example
```js
eventTarget.on('fire', function () {
cc.log("fire in the hole");
}, node);
```
*/
on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
/**
!#en
Removes the listeners previously registered with the same type, callback, target and or useCapture,
if only type is passed as parameter, all listeners registered with that type will be removed.
!#zh
useCapture type type
@param type A string representing the event type being removed.
@param callback The callback to remove.
@param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
@example
```js
// register fire eventListener
var callback = eventTarget.on('fire', function () {
cc.log("fire in the hole");
}, target);
// remove fire event listener
eventTarget.off('fire', callback, target);
// remove all fire event listeners
eventTarget.off('fire');
```
*/
off(type: string, callback?: Function, target?: any): void;
/**
!#en Removes all callbacks previously registered with the same target (passed as parameter).
This is not for removing all listeners in the current event target,
and this is not for removing all listeners the target parameter have registered.
It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
!#zh EventTarget target
EventTarget target
target EventTarget
@param target The target to be searched for all related listeners
*/
targetOff(target: any): void;
/**
!#en
Register an callback of a specific event type on the EventTarget,
the callback will remove itself after the first time it is triggered.
!#zh
@param type A string representing the event type to listen for.
@param callback The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null
@example
```js
eventTarget.once('fire', function () {
cc.log("this is the callback and will be invoked only once");
}, node);
```
*/
once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void;
/**
!#en
Send an event with the event object.
!#zh
@param event event
*/
dispatchEvent(event: Event): void;
/**
!#en
Destroy all callbackInfos.
!#zh
*/
clear(): void;
}
/** !#en Base class of all kinds of events.
!#zh */
export class Event {
/**
@param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit"
@param bubbles A boolean indicating whether the event bubbles up through the tree or not
*/
constructor(type: string, bubbles: boolean);
/** !#en The name of the event (case-sensitive), e.g. "click", "fire", or "submit".
!#zh */
type: string;
/** !#en Indicate whether the event bubbles up through the tree or not.
!#zh */
bubbles: boolean;
/** !#en A reference to the target to which the event was originally dispatched.
!#zh */
target: any;
/** !#en A reference to the currently registered target for the event.
!#zh */
currentTarget: any;
/** !#en
Indicates which phase of the event flow is currently being evaluated.
Returns an integer value represented by 4 constants:
- Event.NONE = 0
- Event.CAPTURING_PHASE = 1
- Event.AT_TARGET = 2
- Event.BUBBLING_PHASE = 3
The phases are explained in the [section 3.1, Event dispatch and DOM event flow]
(http://www.w3.org/TR/DOM-Level-3-Events/#event-flow), of the DOM Level 3 Events specification.
!#zh */
eventPhase: number;
/**
!#en Reset the event for being stored in the object pool.
!#zh
*/
unuse(): string;
/**
!#en Reuse the event for being used again by the object pool.
!#zh 使
*/
reuse(): string;
/**
!#en Stops propagation for current event.
!#zh
*/
stopPropagation(): void;
/**
!#en Stops propagation for current event immediately,
the event won't even be dispatched to the listeners attached in the current target.
!#zh
*/
stopPropagationImmediate(): void;
/**
!#en Checks whether the event has been stopped.
!#zh .
*/
isStopped(): boolean;
/**
!#en
<p>
Gets current target of the event <br/>
note: It only be available when the event listener is associated with node. <br/>
It returns 0 when the listener is associated with fixed priority.
</p>
!#zh
*/
getCurrentTarget(): Node;
/**
!#en Gets the event type.
!#zh
*/
getType(): string;
/** !#en Code for event without type.
!#zh */
static NO_TYPE: string;
/** !#en The type code of Touch event.
!#zh */
static TOUCH: string;
/** !#en The type code of Mouse event.
!#zh */
static MOUSE: string;
/** !#en The type code of Keyboard event.
!#zh */
static KEYBOARD: string;
/** !#en The type code of Acceleration event.
!#zh */
static ACCELERATION: string;
/** !#en Events not currently dispatched are in this phase
!#zh */
static NONE: number;
/** !#en
The capturing phase comprises the journey from the root to the last node before the event target's node
see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
!#zh */
static CAPTURING_PHASE: number;
/** !#en
The target phase comprises only the event target node
see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
!#zh */
static AT_TARGET: number;
/** !#en
The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the hierarchy
see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
!#zh */
static BUBBLING_PHASE: number;
}
/** !#en
The System event, it currently supports keyboard events and accelerometer events.<br>
You can get the SystemEvent instance with cc.systemEvent.<br>
!#zh
<br>
cc.systemEvent SystemEvent <br> */
export class SystemEvent extends EventTarget {
/**
!#en whether enable accelerometer event
!#zh
@param isEnable isEnable
*/
setAccelerometerEnabled(isEnable: boolean): void;
/**
!#en set accelerometer interval value
!#zh
@param interval interval
*/
setAccelerometerInterval(interval: number): void;
}
/** !#en The animation component is used to play back animations.
Animation provide several events to register
- play : Emit when begin playing animation
- stop : Emit when stop playing animation
- pause : Emit when pause animation
- resume : Emit when resume animation
- lastframe : If animation repeat count is larger than 1, emit when animation play to the last frame
- finished : Emit when finish playing animation
!#zh Animation
Animation
- play :
- stop :
- pause :
- resume :
- lastframe : 1
- finished : */
export class Animation extends Component implements EventTarget {
/** !#en Animation will play the default clip when start game.
!#zh play() */
defaultClip: AnimationClip;
/** !#en Current played clip.
!#zh */
currentClip: AnimationClip;
/** !#en Whether the animation should auto play the default clip when start game.
!#zh */
playOnLoad: boolean;
/**
!#en Get all the clips used in this animation.
!#zh
*/
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
```js
var animCtrl = this.node.getComponent(cc.Animation);
animCtrl.play("linear");
```
*/
play(name?: string, startTime?: number): AnimationState;
/**
!#en
Plays an additive animation, it will not stop other animations.
If there are other animations playing, then will play several animations at the same time.
!#zh
@param name The name of animation to play. If no name is supplied then the default animation will be played.
@param startTime play an animation from startTime
@example
```js
// linear_1 and linear_2 at the same time playing.
var animCtrl = this.node.getComponent(cc.Animation);
animCtrl.playAdditive("linear_1");
animCtrl.playAdditive("linear_2");
```
*/
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. <br/>
Stopping an animation also Rewinds it to the Start.
!#zh
@param name The animation to stop, if not supplied then stops all playing animations.
*/
stop(name?: string): void;
/**
!#en Pauses an animation named name. If no name is supplied then pauses all playing animations that were started with this Animation.
!#zh
@param name The animation to pauses, if not supplied then pauses all playing animations.
*/
pause(name?: string): void;
/**
!#en Resumes an animation named name. If no name is supplied then resumes all paused animations that were started with this Animation.
!#zh
@param name The animation to resumes, if not supplied then resumes all paused animations.
*/
resume(name?: string): void;
/**
!#en Make an animation named name go to the specified time. If no name is supplied then make all animations go to the specified time.
!#zh
@param time The time to go to
@param name Specified animation name, if not supplied then make all animations go to the time.
*/
setCurrentTime(time?: number, name?: string): void;
/**
!#en Returns the animation state named name. If no animation with the specified name, the function will return null.
!#zh null
@param name name
*/
getAnimationState(name: string): AnimationState;
/**
!#en Adds a clip to the animation with name newName. If a clip with that name already exists it will be replaced with the new clip.
!#zh
@param clip the clip to add
@param newName newName
*/
addClip(clip: AnimationClip, newName?: string): AnimationState;
/**
!#en
Remove clip from the animation list. This will remove the clip and any animation states based on it.
If there are animation states depand on the clip are playing or clip is defaultClip, it will not delete the clip.
But if force is true, then will always remove the clip and any animation states based on it. If clip is defaultClip, defaultClip will be reset to null
!#zh
<br/>
clip AnimationState clip defaultClip clip
force true clip defaultClipdefaultClip null
@param clip clip
@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;
/**
!#en
Samples animations at the current state.<br/>
This is useful when you explicitly want to set up some animation state, and sample it once.
!#zh
@param name name
*/
sample(name: string): void;
/**
!#en
Register animation event callback.
The event arguments will provide the AnimationState which emit the event.
When play an animation, will auto register the event callback to the AnimationState, and unregister the event callback from the AnimationState when animation stopped.
!#zh
AnimationState
AnimationState AnimationState
@param type A string representing the event type to listen for.
@param callback The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
@param state state
@param target The target (this object) to invoke the callback, can be null
@param useCapture When set to true, the capture argument prevents callback
from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
@example
```js
onPlay: function (type, state) {
// 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<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void;
on(type: string, callback: (type: string, state: cc.AnimationState) => void, target?: any, useCapture?: boolean): (type: string, state: cc.AnimationState) => void;
/**
!#en
Unregister animation event callback.
!#zh
@param type A string representing the event type being removed.
@param callback The callback to remove.
@param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
@param useCapture Specifies whether the callback being removed was registered as a capturing callback or not.
If not specified, useCapture defaults to false. If a callback was registered twice,
one with capture and one without, each must be removed separately. Removal of a capturing callback
does not affect a non-capturing version of the same listener, and vice versa.
@example
```js
// unregister event to all animation
animation.off('play', this.onPlay, this);
```
*/
off(type: string, callback?: Function, target?: any, useCapture?: boolean): void;
/**
!#en Checks whether the EventTarget object has any callback registered for a specific type of event.
!#zh
@param type The type of event.
*/
hasEventListener(type: string): boolean;
/**
!#en Removes all callbacks previously registered with the same target (passed as parameter).
This is not for removing all listeners in the current event target,
and this is not for removing all listeners the target parameter have registered.
It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
!#zh EventTarget target
EventTarget target
target EventTarget
@param target The target to be searched for all related listeners
*/
targetOff(target: any): void;
/**
!#en
Register an callback of a specific event type on the EventTarget,
the callback will remove itself after the first time it is triggered.
!#zh
@param type A string representing the event type to listen for.
@param callback The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null
@example
```js
eventTarget.once('fire', function () {
cc.log("this is the callback and will be invoked only once");
}, node);
```
*/
once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void;
/**
!#en
Send an event with the event object.
!#zh
@param event event
*/
dispatchEvent(event: Event): void;
/**
!#en
Destroy all callbackInfos.
!#zh
*/
clear(): void;
}
/** !#en Audio Source.
!#zh */
export class AudioSource extends Component {
/** !#en
Is the audio source playing (Read Only). <br/>
Note: isPlaying is not supported for Native platforms.
!#zh
<br/>
Native isPlaying */
isPlaying: boolean;
/** !#en The clip of the audio source to play.
!#zh */
clip: AudioClip;
/** !#en The volume of the audio source.
!#zh 0.0 ~ 1.0 */
volume: number;
/** !#en Is the audio source mute?
!#zh Mute 0 */
mute: boolean;
/** !#en Is the audio source looping?
!#zh */
loop: boolean;
/** !#en If set to true, the audio source will automatically start playing on onEnable.
!#zh true onEnable */
playOnLoad: boolean;
/** !#en If set to true and AudioClip is a deferred load resource, the component will preload AudioClip in the onLoad phase.
!#zh true AudioClip onLoad AudioClip */
preload: boolean;
/**
!#en Plays the clip.
!#zh
*/
play(): void;
/**
!#en Stops the clip.
!#zh
*/
stop(): void;
/**
!#en Pause the clip.
!#zh
*/
pause(): void;
/**
!#en Resume the clip.
!#zh
*/
resume(): void;
/**
!#en Rewind playing music.
!#zh
*/
rewind(): void;
/**
!#en Get current time
!#zh
*/
getCurrentTime(): number;
/**
!#en Set current time
!#zh
@param time time
*/
setCurrentTime(time: number): number;
/**
!#en Get audio duration
!#zh
*/
getDuration(): number;
}
/** !#en
This component will block all input events (mouse and touch) within the bounding box of the node, preventing the input from penetrating into the underlying node, typically for the background of the top UI.<br>
This component does not have any API interface and can be added directly to the scene to take effect.
!#zh
bounding box 穿 UI <br>
API */
export class BlockInputEvents extends Component {
}
/** !#en
Button component. Can be pressed or clicked. Button has 4 Transition types:
- Button.Transition.NONE // Button will do nothing
- Button.Transition.COLOR // Button will change target's color
- Button.Transition.SPRITE // Button will change target Sprite's sprite
- Button.Transition.SCALE // Button will change target node's scale
The button can bind events (but you must be on the button's node to bind events).<br/>
The following events can be triggered on all platforms.
- cc.Node.EventType.TOUCH_START // Press
- cc.Node.EventType.TOUCH_MOVE // After pressing and moving
- cc.Node.EventType.TOUCH_END // After pressing and releasing
- cc.Node.EventType.TOUCH_CANCEL // Press to cancel
The following events are only triggered on the PC platform:
- cc.Node.EventType.MOUSE_DOWN
- cc.Node.EventType.MOUSE_MOVE
- cc.Node.EventType.MOUSE_ENTER
- cc.Node.EventType.MOUSE_LEAVE
- cc.Node.EventType.MOUSE_UP
- cc.Node.EventType.MOUSE_WHEEL
User can get the current clicked node with 'event.target' from event object which is passed as parameter in the callback function of click event.
!#zh
Transition
- Button.Transition.NONE // 不做任何过渡
- Button.Transition.COLOR // 进行颜色之间过渡
- Button.Transition.SPRITE // 进行精灵之间过渡
- Button.Transition.SCALE // 进行缩放过渡
Node <br/>
- cc.Node.EventType.TOUCH_START // 按下时事件
- cc.Node.EventType.TOUCH_MOVE // 按住移动后事件
- cc.Node.EventType.TOUCH_END // 按下后松开后事件
- cc.Node.EventType.TOUCH_CANCEL // 按下取消事件
PC
- cc.Node.EventType.MOUSE_DOWN // 鼠标按下时事件
- cc.Node.EventType.MOUSE_MOVE // 鼠标按住移动后事件
- cc.Node.EventType.MOUSE_ENTER // 鼠标进入目标事件
- cc.Node.EventType.MOUSE_LEAVE // 鼠标离开目标事件
- cc.Node.EventType.MOUSE_UP // 鼠标松开事件
- cc.Node.EventType.MOUSE_WHEEL // 鼠标滚轮事件
____ event target */
export class Button extends Component implements GraySpriteState {
/** !#en
Whether the Button is disabled.
If true, the Button will trigger event and do transition.
!#zh
false */
interactable: boolean;
/** !#en When this flag is true, Button target sprite will turn gray when interactable is false.
!#zh true button interactable false 使 shader button target sprite */
enableAutoGrayEffect: boolean;
/** !#en Transition type
!#zh */
transition: Button.Transition;
/** !#en Normal state color.
!#zh */
normalColor: Color;
/** !#en Pressed state color
!#zh */
pressedColor: Color;
/** !#en Hover state color
!#zh */
hoverColor: Color;
/** !#en Disabled state color
!#zh */
disabledColor: Color;
/** !#en Color and Scale transition duration
!#zh */
duration: number;
/** !#en When user press the button, the button will zoom to a scale.
The final scale of the button equals (button original scale * zoomScale)
!#zh Button scale * zoomScale */
zoomScale: number;
/** !#en Normal state sprite
!#zh Sprite */
normalSprite: SpriteFrame;
/** !#en Pressed state sprite
!#zh Sprite */
pressedSprite: SpriteFrame;
/** !#en Hover state sprite
!#zh Sprite */
hoverSprite: SpriteFrame;
/** !#en Disabled state sprite
!#zh Sprite */
disabledSprite: SpriteFrame;
/** !#en
Transition target.
When Button state changed:
If Transition type is Button.Transition.NONE, Button will do nothing
If Transition type is Button.Transition.COLOR, Button will change target's color
If Transition type is Button.Transition.SPRITE, Button will change target Sprite's sprite
!#zh
- Transition type Button.Transition.NONE
- Transition type Button.Transition.COLOR
- Transition type Button.Transition.Sprite Sprite Sprite */
target: Node;
/** !#en If Button is clicked, it will trigger event's handler
!#zh */
clickEvents: Component.EventHandler[];
/** !#en The normal material.
!#zh */
normalMaterial: Material;
/** !#en The gray material.
!#zh */
grayMaterial: Material;
}
/** !#zh UI 便<br>
anchorPoint (0.5, 0.5) */
export class Canvas extends Component {
/** !#en Current active canvas, the scene should only have one active canvas at the same time.
!#zh */
static instance: Canvas;
/** !#en The desigin resolution for current scene.
!#zh */
designResolution: Size;
/** !#en TODO
!#zh: */
fitHeight: boolean;
/** !#en TODO
!#zh: */
fitWidth: boolean;
}
/** !#en
Base class for everything attached to Node(Entity).<br/>
<br/>
NOTE: Not allowed to use construction parameters for Component's subclasses,
because Component is created by the engine.
!#zh
<br/>
<br/>
使 */
export class Component extends Object {
/** !#en The node this component is attached to. A component is always attached to a node.
!#zh */
node: Node;
/** !#en The uuid for editor.
!#zh uuid */
uuid: string;
/** !#en indicates whether this component is enabled or not.
!#zh */
enabled: boolean;
/** !#en indicates whether this component is enabled and its node is also active in the hierarchy.
!#zh */
enabledInHierarchy: boolean;
/** !#en Returns a value which used to indicate the onLoad get called or not.
!#zh onLoad 0 0 */
_isOnLoadCalled: number;
/**
!#en Update is called every frame, if the Component is enabled.<br/>
This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere.
!#zh update<br/>
@param dt the delta time in seconds it took to complete the last frame
*/
protected update(dt: number): void;
/**
!#en LateUpdate is called every frame, if the Component is enabled.<br/>
This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere.
!#zh LateUpdate<br/>
@param dt the delta time in seconds it took to complete the last frame
*/
protected lateUpdate(dt: number): void;
/**
!#en
When attaching to an active node or its node first activated.
onLoad is always called before any start functions, this allows you to order initialization of scripts.<br/>
This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere.
!#zh
onLoad start <br/>
*/
protected onLoad(): void;
/**
!#en
Called before all scripts' update if the Component is enabled the first time.
Usually used to initialize some logic which need to be called after all components' `onload` methods called.<br/>
This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere.
!#zh
update onLoad <br/>
*/
protected start(): void;
/**
!#en Called when this component becomes enabled and its node is active.<br/>
This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere.
!#zh <br/>
*/
protected onEnable(): void;
/**
!#en Called when this component becomes disabled or its node becomes inactive.<br/>
This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere.
!#zh <br/>
*/
protected onDisable(): void;
/**
!#en Called when this component will be destroyed.<br/>
This is a lifecycle method. It may not be implemented in the super class. You can only call its super class method inside it. It should not be called manually elsewhere.
!#zh <br/>
*/
protected onDestroy(): void;
protected onFocusInEditor(): void;
protected onLostFocusInEditor(): void;
/**
!#en Called to initialize the component or nodes properties when adding the component the first time or when the Reset command is used. This function is only called in editor.
!#zh Reset
*/
protected resetInEditor(): void;
/**
!#en Adds a component class to the node. You can also add component to node by passing in the name of the script.
!#zh
@param typeOrClassName the constructor or the class name of the component to add
@example
```js
var sprite = node.addComponent(cc.Sprite);
var test = node.addComponent("Test");
```
*/
addComponent<T extends Component>(type: {new(): T}): T;
addComponent(className: string): any;
/**
!#en
Returns the component of supplied type if the node has one attached, null if it doesn't.<br/>
You can also get component in the node by passing in the name of the script.
!#zh
<br/>
@param typeOrClassName typeOrClassName
@example
```js
// get sprite component.
var sprite = node.getComponent(cc.Sprite);
// get custom test calss.
var test = node.getComponent("Test");
```
*/
getComponent<T extends Component>(type: {prototype: T}): T;
getComponent(className: string): any;
/**
!#en Returns all components of supplied Type in the node.
!#zh
@param typeOrClassName typeOrClassName
@example
```js
var sprites = node.getComponents(cc.Sprite);
var tests = node.getComponents("Test");
```
*/
getComponents<T extends Component>(type: {prototype: T}): T[];
getComponents(className: string): any[];
/**
!#en Returns the component of supplied type in any of its children using depth first search.
!#zh
@param typeOrClassName typeOrClassName
@example
```js
var sprite = node.getComponentInChildren(cc.Sprite);
var Test = node.getComponentInChildren("Test");
```
*/
getComponentInChildren<T extends Component>(type: {prototype: T}): T;
getComponentInChildren(className: string): any;
/**
!#en Returns the components of supplied type in self or any of its children using depth first search.
!#zh
@param typeOrClassName typeOrClassName
@example
```js
var sprites = node.getComponentsInChildren(cc.Sprite);
var tests = node.getComponentsInChildren("Test");
```
*/
getComponentsInChildren<T extends Component>(type: {prototype: T}): T[];
getComponentsInChildren(className: string): any[];
/**
!#en
If the component's bounding box is different from the node's, you can implement this method to supply
a custom axis aligned bounding box (AABB), so the editor's scene view can perform hit test properly.
!#zh
AABB
便
@param out_rect the Rect to receive the bounding box
*/
_getLocalBounds(out_rect: Rect): void;
/**
!#en
onRestore is called after the user clicks the Reset item in the Inspector's context menu or performs
an undo operation on this component.<br/>
<br/>
If the component contains the "internal state", short for "temporary member variables which not included<br/>
in its CCClass properties", then you may need to implement this function.<br/>
<br/>
The editor will call the getset accessors of your component to record/restore the component's state<br/>
for undo/redo operation. However, in extreme cases, it may not works well. Then you should implement<br/>
this function to manually synchronize your component's "internal states" with its public properties.<br/>
Once you implement this function, all the getset accessors of your component will not be called when<br/>
the user performs an undo/redo operation. Which means that only the properties with default value<br/>
will be recorded or restored by editor.<br/>
<br/>
Similarly, the editor may failed to reset your component correctly in extreme cases. Then if you need<br/>
to support the reset menu, you should manually synchronize your component's "internal states" with its<br/>
properties in this function. Once you implement this function, all the getset accessors of your component<br/>
will not be called during reset operation. Which means that only the properties with default value<br/>
will be reset by editor.
This function is only called in editor mode.
!#zh
onRestore Reset <br/>
<br/>
CCClass <br/>
<br/>
/ get set <br/>
get set <br/>
<br/>
get set
<br/>
*/
onRestore(): void;
/**
!#en
Schedules a custom selector.<br/>
If the selector is already scheduled, then the interval parameter will be updated without scheduling it again.
!#zh
<br/>
@param callback The callback function
@param interval Tick interval in seconds. 0 means tick every frame.
@param repeat The selector will be executed (repeat + 1) times, you can use cc.macro.REPEAT_FOREVER for tick infinitely.
@param delay The amount of time that the first tick will wait before execution. Unit: s
@example
```js
var timeCallback = function (dt) {
cc.log("time: " + dt);
}
this.schedule(timeCallback, 1);
```
*/
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
```js
var timeCallback = function (dt) {
cc.log("time: " + dt);
}
this.scheduleOnce(timeCallback, 2);
```
*/
scheduleOnce(callback: Function, delay?: number): void;
/**
!#en Unschedules a custom callback function.
!#zh
@param callback_fn A function wrapped as a selector
@example
```js
this.unschedule(_callback);
```
*/
unschedule(callback_fn: Function): void;
/**
!#en
unschedule all scheduled callback functions: custom callback functions, and the 'update' callback function.<br/>
Actions are not affected by this method.
!#zh `update`
@example
```js
this.unscheduleAllCallbacks();
```
*/
unscheduleAllCallbacks(): void;
}
/** !#en The Label Component.
!#zh */
export class Label extends RenderComponent {
/** !#en Content string of label.
!#zh */
string: string;
/** !#en Horizontal Alignment of label.
!#zh */
horizontalAlign: Label.HorizontalAlign;
/** !#en Vertical Alignment of label.
!#zh */
verticalAlign: Label.VerticalAlign;
/** !#en The actual rendering font size in shrink mode
!#zh SHRINK */
actualFontSize: number;
/** !#en Font size of label.
!#zh */
fontSize: number;
/** !#en Font family of label, only take effect when useSystemFont property is true.
!#zh , useSystemFont true */
fontFamily: string;
/** !#en Line Height of label.
!#zh */
lineHeight: number;
/** !#en Overflow of label.
!#zh */
overflow: Label.Overflow;
/** !#en Whether auto wrap label when string width is large than label width.
!#zh */
enableWrapText: boolean;
/** !#en The font of label.
!#zh */
font: Font;
/** !#en Whether use system font name or not.
!#zh 使 */
useSystemFont: boolean;
/** !#en The spacing of the x axis between characters, only take Effect when using bitmap fonts.
!#zh x 使 */
spacingX: number;
/** !#en The cache mode of label. This mode only supports system fonts.
!#zh , */
cacheMode: Label.CacheMode;
/** !#en Whether enable bold.
!#zh */
enableBold: boolean;
/** !#en Whether enable italic.
!#zh */
enableItalic: boolean;
/** !#en Whether enable underline.
!#zh 线 */
enableUnderline: boolean;
/** !#en The height of underline.
!#zh 线 */
underlineHeight: number;
/**
!#zh 使CHARLabel
!#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;
}
/** !#en Outline effect used to change the display, only for system fonts or TTF fonts
!#zh ,, */
export class LabelOutline extends Component {
/** !#en outline color
!#zh */
color: Color;
/** !#en Change the outline width
!#zh */
width: number;
}
/** !#en Shadow effect for Label component, only for system fonts or TTF fonts
!#zh Label ttf */
export class LabelShadow extends Component {
/** !#en The shadow color
!#zh */
color: Color;
/** !#en Offset between font and shadow
!#zh */
offset: Vec2;
/** !#en A non-negative float specifying the level of shadow blur
!#zh */
blur: number;
}
/** !#en
The Layout is a container component, use it to arrange child elements easily.<br>
Note<br>
1.Scaling and rotation of child nodes are not considered.<br>
2.After setting the Layout, the results need to be updated until the next frame,
unless you manually call {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}
!#zh
Layout <br>
<br>
1.<br>
2. Layout {{#crossLink "Layout/updateLayout:method"}}{{/crossLink}}。 */
export class Layout extends Component {
/** !#en The layout type.
!#zh */
type: Layout.Type;
/** !#en
The are three resize modes for Layout.
None, resize Container and resize children.
!#zh */
resizeMode: Layout.ResizeMode;
/** !#en The cell size for grid layout.
!#zh GRID */
cellSize: Size;
/** !#en
The start axis for grid layout. If you choose horizontal, then children will layout horizontally at first,
and then break line on demand. Choose vertical if you want to layout vertically at first .
!#zh GRID */
startAxis: Layout.AxisDirection;
/** !#en The left padding of layout, it only effect the layout in one direction.
!#zh */
paddingLeft: number;
/** !#en The right padding of layout, it only effect the layout in one direction.
!#zh */
paddingRight: number;
/** !#en The top padding of layout, it only effect the layout in one direction.
!#zh */
paddingTop: number;
/** !#en The bottom padding of layout, it only effect the layout in one direction.
!#zh */
paddingBottom: number;
/** !#en The distance in x-axis between each element in layout.
!#zh */
spacingX: number;
/** !#en The distance in y-axis between each element in layout.
!#zh */
spacingY: number;
/** !#en
Only take effect in Vertical layout mode.
This option changes the start element's positioning.
!#zh */
verticalDirection: Layout.VerticalDirection;
/** !#en
Only take effect in Horizontal layout mode.
This option changes the start element's positioning.
!#zh */
horizontalDirection: Layout.HorizontalDirection;
/** !#en Adjust the layout if the children scaled.
!#zh */
affectedByScale: boolean;
/**
!#en Perform the layout update
!#zh
@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;
}
/** !#en The Mask Component
!#zh */
export class Mask extends RenderComponent {
/** !#en The mask type.
!#zh */
type: Mask.Type;
/** !#en The mask image
!#zh */
spriteFrame: SpriteFrame;
/** !#en
The alpha threshold.(Not supported Canvas Mode) <br/>
The content is drawn only where the stencil have pixel with alpha greater than the alphaThreshold. <br/>
Should be a float between 0 and 1. <br/>
This default to 0.1.
When it's set to 1, the stencil will discard all pixels, nothing will be shown.
!#zh
Alpha Canvas <br/>
alpha alphaThreshold <br/>
0 ~ 1 0.1
1 */
alphaThreshold: number;
/** !#en Reverse mask (Not supported Canvas Mode)
!#zh Canvas */
inverted: boolean;
/** TODO: remove segments, not supported by graphics
!#en The segements for ellipse mask.
!#zh 线 */
segements: number;
}
/** !#en
cc.MotionStreak manages a Ribbon based on it's motion in absolute space. <br/>
You construct it with a fadeTime, minimum segment size, texture path, texture <br/>
length and color. The fadeTime controls how long it takes each vertex in <br/>
the streak to fade out, the minimum segment size it how many pixels the <br/>
streak will move before adding a new ribbon segment, and the texture <br/>
length is the how many pixels the texture is stretched across. The texture <br/>
is vertically aligned along the streak segment.
!#zh */
export class MotionStreak extends Component implements BlendFunc {
/** !#en
!#zh */
preview: boolean;
/** !#en The fade time to fade.
!#zh */
fadeTime: number;
/** !#en The minimum segment size.
!#zh */
minSeg: number;
/** !#en The stroke's width.
!#zh */
stroke: number;
/** !#en The texture of the MotionStreak.
!#zh */
texture: Texture2D;
/** !#en The color of the MotionStreak.
!#zh */
color: Color;
/** !#en The fast Mode.
!#zh */
fastMode: boolean;
/**
!#en Remove all living segments of the ribbon.
!#zh
@example
```js
// Remove all living segments of the ribbon.
myMotionStreak.reset();
```
*/
reset(): void;
/** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost.
!#zh */
srcBlendFactor: macro.BlendFactor;
/** !#en specify the destination Blend Factor.
!#zh */
dstBlendFactor: macro.BlendFactor;
}
/** !#en The PageView control
!#zh */
export class PageView extends ScrollView {
/** !#en Specify the size type of each page in PageView.
!#zh */
sizeMode: PageView.SizeMode;
/** !#en The page view direction
!#zh */
direction: PageView.Direction;
/** !#en
The scroll threshold value, when drag exceeds this value,
release the next page will automatically scroll, less than the restore
!#zh */
scrollThreshold: number;
/** !#en
Auto page turning velocity threshold. When users swipe the PageView quickly,
it will calculate a velocity based on the scroll distance and time,
if the calculated velocity is larger than the threshold, then it will trigger page turning.
!#zh
*/
autoPageTurningThreshold: number;
/** !#en Change the PageTurning event timing of PageView.
!#zh PageView PageTurning */
pageTurningEventTiming: number;
/** !#en The Page View Indicator
!#zh */
indicator: PageViewIndicator;
/** !#en The time required to turn over a page. unit: second
!#zh */
pageTurningSpeed: number;
/** !#en PageView events callback
!#zh */
pageEvents: Component.EventHandler[];
/**
!#en Returns current page index
!#zh
*/
getCurrentPageIndex(): number;
/**
!#en Set current page index
!#zh
@param index index
*/
setCurrentPageIndex(index: number): void;
/**
!#en Returns all pages of pageview
!#zh
*/
getPages(): Node[];
/**
!#en At the end of the current page view to insert a new view
!#zh
@param page page
*/
addPage(page: Node): void;
/**
!#en Inserts a page in the specified location
!#zh
@param page page
@param index index
*/
insertPage(page: Node, index: number): void;
/**
!#en Removes a page from PageView.
!#zh
@param page page
*/
removePage(page: Node): void;
/**
!#en Removes a page at index of PageView.
!#zh
@param index index
*/
removePageAtIndex(index: number): void;
/**
!#en Removes all pages from PageView
!#zh
*/
removeAllPages(): void;
/**
!#en Scroll PageView to index.
!#zh
@param idx index of page.
@param timeInSecond scrolling time
*/
scrollToPage(idx: number, timeInSecond: number): void;
}
/** !#en The Page View Indicator Component
!#zh */
export class PageViewIndicator extends Component {
/** !#en The spriteFrame for each element.
!#zh */
spriteFrame: SpriteFrame;
/** !#en The location direction of PageViewIndicator.
!#zh */
direction: PageViewIndicator.Direction;
/** !#en The cellSize for each element.
!#zh */
cellSize: Size;
/** !#en The distance between each element.
!#zh */
spacing: number;
/**
!#en Set Page View
!#zh
@param target target
*/
setPageView(target: PageView): void;
}
/** !#en
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 {
/** !#en The targeted Sprite which will be changed progressively.
!#zh Sprite */
barSprite: Sprite;
/** !#en The progress mode, there are two modes supported now: horizontal and vertical.
!#zh */
mode: ProgressBar.Mode;
/** !#en The total width or height of the bar sprite.
!#zh */
totalLength: number;
/** !#en The current progress of the bar sprite. The valid value is between 0-1.
!#zh 0-1 */
progress: number;
/** !#en Whether reverse the progress direction of the bar sprite.
!#zh */
reverse: boolean;
}
/** !#en
Base class for components which supports rendering features.
!#zh
*/
export class RenderComponent extends Component {
/** !#en The materials used by this render component.
!#zh 使 */
sharedMaterials: Material[];
/**
!#en Get the material by index.
!#zh
@param index index
*/
getMaterial(index: number): MaterialVariant;
/**
!#en Gets all the materials.
!#zh
*/
getMaterials(): MaterialVariant[];
/**
!#en Set the material by index.
!#zh
@param index index
@param material material
*/
setMaterial(index: number, material: Material): Material;
}
/** !#en The RichText Component.
!#zh */
export class RichText extends Component {
/** !#en Content string of RichText.
!#zh */
string: string;
/** !#en Horizontal Alignment of each line in RichText.
!#zh */
horizontalAlign: macro.TextAlignment;
/** !#en Font size of RichText.
!#zh */
fontSize: number;
/** !#en Custom System font of RichText
!#zh */
fontFamily: string;
/** !#en Custom TTF font of RichText
!#zh */
font: TTFFont;
/** !#en Whether use system font name or not.
!#zh 使 */
useSystemFont: boolean;
/** !#en The cache mode of label. This mode only supports system fonts.
!#zh , */
cacheMode: Label.CacheMode;
/** !#en The maximize width of the RichText
!#zh */
maxWidth: number;
/** !#en Line Height of RichText.
!#zh */
lineHeight: number;
/** !#en The image atlas for the img tag. For each src value in the img tag, there should be a valid spriteFrame in the image atlas.
!#zh img src imageAtlas spriteFrame img tag */
imageAtlas: SpriteAtlas;
/** !#en
Once checked, the RichText will block all input events (mouse and touch) within
the bounding box of the node, preventing the input from penetrating into the underlying node.
!#zh
RichText 穿 */
handleTouchEvent: boolean;
}
/** !#en
This component is used to adjust the layout of current node to respect the safe area of a notched mobile device such as the iPhone X.
It is typically used for the top node of the UI interaction area. For specific usage, refer to the official [example-cases/02_ui/16_safeArea/SafeArea.fire](https://github.com/cocos-creator/example-cases).
The concept of safe area is to give you a fixed inner rectangle in which you can safely display content that will be drawn on screen.
You are strongly discouraged from providing controls outside of this area. But your screen background could embellish edges.
This component internally uses the API `cc.sys.getSafeAreaRect();` to obtain the safe area of the current iOS or Android device,
and implements the adaptation by using the Widget component and set anchor.
!#zh
iPhone X UI [example-cases/02_ui/16_safeArea/SafeArea.fire](https://github.com/cocos-creator/example-cases)。
API `cc.sys.getSafeAreaRect();` iOS Android Widget */
export class SafeArea extends Component {
/**
!#en Adapt to safe area
!#zh
@example
```js
let safeArea = this.node.addComponent(cc.SafeArea);
safeArea.updateArea();
```
*/
updateArea(): void;
}
/** !#en
The Scrollbar control allows the user to scroll an image or other view that is too large to see completely
!#zh */
export class Scrollbar extends Component {
/** !#en The "handle" part of the scrollbar.
!#zh Sprite */
handle: Sprite;
/** !#en The direction of scrollbar.
!#zh ScrollBar */
direction: Scrollbar.Direction;
/** !#en Whether enable auto hide or not.
!#zh ScrollBar */
enableAutoHide: boolean;
/** !#en
The time to hide scrollbar when scroll finished.
Note: This value is only useful when enableAutoHide is true.
!#zh
enableAutoHide true */
autoHideTime: number;
}
/** !#en
Layout container for a view hierarchy that can be scrolled by the user,
allowing it to be larger than the physical display.
!#zh
*/
export class ScrollView extends Component {
/** !#en This is a reference to the UI element to be scrolled.
!#zh */
content: Node;
/** !#en Enable horizontal scroll.
!#zh */
horizontal: boolean;
/** !#en Enable vertical scroll.
!#zh */
vertical: boolean;
/** !#en When inertia is set, the content will continue to move when touch ended.
!#zh */
inertia: boolean;
/** !#en
It determines how quickly the content stop moving. A value of 1 will stop the movement immediately.
A value of 0 will never stop the movement until it reaches to the boundary of scrollview.
!#zh
01 */
brake: number;
/** !#en When elastic is set, the content will be bounce back when move out of boundary.
!#zh */
elastic: boolean;
/** !#en The elapse time of bouncing back. A value of 0 will bounce back immediately.
!#zh 0 */
bounceDuration: number;
/** !#en The horizontal scrollbar reference.
!#zh ScrollBar */
horizontalScrollBar: Scrollbar;
/** !#en The vertical scrollbar reference.
!#zh ScrollBar */
verticalScrollBar: Scrollbar;
/** !#en Scrollview events callback
!#zh */
scrollEvents: Component.EventHandler[];
/** !#en If cancelInnerEvents is set to true, the scroll behavior will cancel touch events on inner content nodes
It's set to true by default.
!#zh true true
touchstart touchmove touchend */
cancelInnerEvents: boolean;
/**
!#en Scroll the content to the bottom boundary of ScrollView.
!#zh
@param timeInSecond Scroll time in second, if you don't pass timeInSecond,
the content will jump to the bottom boundary immediately.
@param attenuated Whether the scroll acceleration attenuated, default is true.
@example
```js
// Scroll to the bottom of the view.
scrollView.scrollToBottom(0.1);
```
*/
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
```js
// Scroll to the top of the view.
scrollView.scrollToTop(0.1);
```
*/
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
```js
// Scroll to the left of the view.
scrollView.scrollToLeft(0.1);
```
*/
scrollToLeft(timeInSecond?: number, attenuated?: boolean): void;
/**
!#en Scroll the content to the right boundary of ScrollView.
!#zh
@param timeInSecond Scroll time in second, if you don't pass timeInSecond,
the content will jump to the right boundary immediately.
@param attenuated Whether the scroll acceleration attenuated, default is true.
@example
```js
// Scroll to the right of the view.
scrollView.scrollToRight(0.1);
```
*/
scrollToRight(timeInSecond?: number, attenuated?: boolean): void;
/**
!#en Scroll the content to the top left boundary of ScrollView.
!#zh
@param timeInSecond Scroll time in second, if you don't pass timeInSecond,
the content will jump to the top left boundary immediately.
@param attenuated Whether the scroll acceleration attenuated, default is true.
@example
```js
// Scroll to the upper left corner of the view.
scrollView.scrollToTopLeft(0.1);
```
*/
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
```js
// Scroll to the top right corner of the view.
scrollView.scrollToTopRight(0.1);
```
*/
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
```js
// Scroll to the lower left corner of the view.
scrollView.scrollToBottomLeft(0.1);
```
*/
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
```js
// Scroll to the lower right corner of the view.
scrollView.scrollToBottomRight(0.1);
```
*/
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.
!#zh ScrollView , timeInSecond
@param offset A Vec2, the value of which each axis between 0 and maxScrollOffset
@param timeInSecond Scroll time in second, if you don't pass timeInSecond,
the content will jump to the specific offset of ScrollView immediately.
@param attenuated Whether the scroll acceleration attenuated, default is true.
@example
```js
// 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;
/**
!#en Get the positive offset value corresponds to the content's top left boundary.
!#zh
*/
getScrollOffset(): Vec2;
/**
!#en Get the maximize available scroll offset
!#zh
*/
getMaxScrollOffset(): Vec2;
/**
!#en Scroll the content to the horizontal percent position of ScrollView.
!#zh ScrollView
@param percent A value between 0 and 1.
@param timeInSecond Scroll time in second, if you don't pass timeInSecond,
the content will jump to the horizontal percent position of ScrollView immediately.
@param attenuated Whether the scroll acceleration attenuated, default is true.
@example
```js
// Scroll to middle position.
scrollView.scrollToBottomRight(0.5, 0.1);
```
*/
scrollToPercentHorizontal(percent: number, timeInSecond?: number, attenuated?: boolean): void;
/**
!#en Scroll the content to the percent position of ScrollView in any direction.
!#zh
@param anchor A point which will be clamp between cc.v2(0,0) and cc.v2(1,1).
@param timeInSecond Scroll time in second, if you don't pass timeInSecond,
the content will jump to the percent position of ScrollView immediately.
@param attenuated Whether the scroll acceleration attenuated, default is true.
@example
```js
// Vertical scroll to the bottom of the view.
scrollView.scrollTo(cc.v2(0, 1), 0.1);
// Horizontal scroll to view right.
scrollView.scrollTo(cc.v2(1, 0), 0.1);
```
*/
scrollTo(anchor: Vec2, timeInSecond?: number, attenuated?: boolean): void;
/**
!#en Scroll the content to the vertical percent position of ScrollView.
!#zh ScrollView
@param percent A value between 0 and 1.
@param timeInSecond Scroll time in second, if you don't pass timeInSecond,
the content will jump to the vertical percent position of ScrollView immediately.
@param attenuated Whether the scroll acceleration attenuated, default is true.
// Scroll to middle position.
scrollView.scrollToPercentVertical(0.5, 0.1);
*/
scrollToPercentVertical(percent: number, timeInSecond?: number, attenuated?: boolean): void;
/**
!#en Stop auto scroll immediately
!#zh , API Scrollview
*/
stopAutoScroll(): void;
/**
!#en Modify the content position.
!#zh
@param position The position in content's parent space.
*/
setContentPosition(position: Vec2): void;
/**
!#en Query the content's position in its parent space.
!#zh
*/
getContentPosition(): Vec2;
/**
!#en Query whether the user is currently dragging the ScrollView to scroll it
!#zh
*/
isScrolling(): boolean;
/**
!#en Query whether the ScrollView is currently scrolling because of a bounceback or inertia slowdown.
!#zh
*/
isAutoScrolling(): boolean;
}
/** !#en The Slider Control
!#zh */
export class Slider extends Component {
/** !#en The "handle" part of the slider
!#zh */
handle: Button;
/** !#en The slider direction
!#zh */
direction: Slider.Direction;
/** !#en The current progress of the slider. The valid value is between 0-1
!#zh 0-1 */
progress: number;
/** !#en The slider slide events' callback array
!#zh */
slideEvents: Component.EventHandler[];
}
/** !#en Renders a sprite in the scene.
!#zh */
export class Sprite extends RenderComponent implements BlendFunc {
/** !#en The sprite frame of the sprite.
!#zh */
spriteFrame: SpriteFrame;
/** !#en The sprite render type.
!#zh */
type: Sprite.Type;
/** !#en
The fill type, This will only have any effect if the "type" is set to cc.Sprite.Type.FILLED.
!#zh
cc.Sprite.Type.FILLED */
fillType: Sprite.FillType;
/** !#en
The fill Center, This will only have any effect if the "type" is set to cc.Sprite.Type.FILLED.
!#zh
cc.Sprite.Type.FILLED */
fillCenter: Vec2;
/** !#en
The fill Start, This will only have any effect if the "type" is set to cc.Sprite.Type.FILLED.
!#zh
cc.Sprite.Type.FILLED */
fillStart: number;
/** !#en
The fill Range, This will only have any effect if the "type" is set to cc.Sprite.Type.FILLED.
!#zh
cc.Sprite.Type.FILLED */
fillRange: number;
/** !#en specify the frame is trimmed or not.
!#zh 使 */
trim: boolean;
/** !#en specify the size tracing mode.
!#zh */
sizeMode: Sprite.SizeMode;
/**
Change the state of sprite.
@param state NORMAL or GRAY State.
*/
setState(state: Sprite.State): void;
/**
Gets the current 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;
/** !#en specify the destination Blend Factor.
!#zh */
dstBlendFactor: macro.BlendFactor;
}
/** !#en The toggle component is a CheckBox, when it used together with a ToggleGroup, it
could be treated as a RadioButton.
!#zh Toggle CheckBox ToggleGroup 使 RadioButton */
export class Toggle extends Button implements GraySpriteState {
/** !#en When this value is true, the check mark component will be enabled, otherwise
the check mark component will be disabled.
!#zh true check mark enabled disabled */
isChecked: boolean;
/** !#en The toggle group which the toggle belongs to, when it is null, the toggle is a CheckBox.
Otherwise, the toggle is a RadioButton.
!#zh Toggle ToggleGroup null Toggle CheckBox
Toggle RadioButton */
toggleGroup: ToggleGroup;
/** !#en The image used for the checkmark.
!#zh Toggle */
checkMark: Sprite;
/** !#en If Toggle is clicked, it will trigger event's handler
!#zh Toggle */
checkEvents: Component.EventHandler[];
/**
!#en Make the toggle button checked.
!#zh 使 toggle
*/
check(): void;
/**
!#en Make the toggle button unchecked.
!#zh 使 toggle
*/
uncheck(): void;
/** !#en The normal material.
!#zh */
normalMaterial: Material;
/** !#en The gray material.
!#zh */
grayMaterial: Material;
}
/** !#en ToggleContainer is not a visiable UI component but a way to modify the behavior of a set of Toggles. <br/>
Toggles that belong to the same group could only have one of them to be switched on at a time.<br/>
Note: All the first layer child node containing the toggle component will auto be added to the container
!#zh ToggleContainer UI Toggle <br/>
Toggle ToggleContainer Toggle <br/>
Toggle */
export class ToggleContainer extends Component {
/** !#en If this setting is true, a toggle could be switched off and on when pressed.
If it is false, it will make sure there is always only one toggle could be switched on
and the already switched on toggle can't be switched off.
!#zh true toggle */
allowSwitchOff: boolean;
/** !#en If Toggle is clicked, it will trigger event's handler
!#zh Toggle */
checkEvents: Component.EventHandler[];
/** !#en Read only property, return the toggle items array reference managed by ToggleContainer.
!#zh ToggleContainer toggle */
toggleItems: Toggle[];
}
/** !#en ToggleGroup is not a visiable UI component but a way to modify the behavior of a set of Toggles.
Toggles that belong to the same group could only have one of them to be switched on at a time.
!#zh ToggleGroup UI Toggle Toggle ToggleGroup
Toggle */
export class ToggleGroup extends Component {
/** !#en If this setting is true, a toggle could be switched off and on when pressed.
If it is false, it will make sure there is always only one toggle could be switched on
and the already switched on toggle can't be switched off.
!#zh true toggle */
allowSwitchOff: boolean;
/** !#en Read only property, return the toggle items array reference managed by toggleGroup.
!#zh toggleGroup toggle */
toggleItems: any[];
}
/** !#en
Handling touch events in a ViewGroup takes special care,
because it's common for a ViewGroup to have children that are targets for different touch events than the ViewGroup itself.
To make sure that each view correctly receives the touch events intended for it,
ViewGroup should register capture phase event and handle the event propagation properly.
Please refer to Scrollview for more information.
!#zh
ViewGroup ViewGroup ViewGroup
ViewGroup capture ViewGroup
ScrollView */
export class ViewGroup extends Component {
}
/** !#en
Stores and manipulate the anchoring based on its parent.
Widget are used for GUI but can also be used for other things.
Widget will adjust current node's position and size automatically, but the results after adjustment can not be obtained until the next frame unless you call {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}} manually.
!#zh
Widget Widget UI
Widget {{#crossLink "Widget/updateAlignment:method"}}{{/crossLink}}。 */
export class Widget extends Component {
/** !#en Specifies an alignment target that can only be one of the parent nodes of the current node.
The default value is null, and when null, indicates the current parent.
!#zh */
target: Node;
/** !#en Whether to align the top.
!#zh */
isAlignTop: boolean;
/** !#en
Vertically aligns the midpoint, This will open the other vertical alignment options cancel.
!#zh
*/
isAlignVerticalCenter: boolean;
/** !#en Whether to align the bottom.
!#zh */
isAlignBottom: boolean;
/** !#en Whether to align the left.
!#zh */
isAlignLeft: boolean;
/** !#en
Horizontal aligns the midpoint. This will open the other horizontal alignment options canceled.
!#zh
*/
isAlignHorizontalCenter: boolean;
/** !#en Whether to align the right.
!#zh */
isAlignRight: boolean;
/** !#en
Whether the stretched horizontally, when enable the left and right alignment will be stretched horizontally,
the width setting is invalid (read only).
!#zh
*/
isStretchWidth: boolean;
/** !#en
Whether the stretched vertically, when enable the left and right alignment will be stretched vertically,
then height setting is invalid (read only)
!#zh
*/
isStretchHeight: boolean;
/** !#en
The margins between the top of this node and the top of parent node,
the value can be negative, Only available in 'isAlignTop' open.
!#zh
isAlignTop */
top: number;
/** !#en
The margins between the bottom of this node and the bottom of parent node,
the value can be negative, Only available in 'isAlignBottom' open.
!#zh
isAlignBottom */
bottom: number;
/** !#en
The margins between the left of this node and the left of parent node,
the value can be negative, Only available in 'isAlignLeft' open.
!#zh
isAlignLeft */
left: number;
/** !#en
The margins between the right of this node and the right of parent node,
the value can be negative, Only available in 'isAlignRight' open.
!#zh
isAlignRight */
right: number;
/** !#en
Horizontal aligns the midpoint offset value,
the value can be negative, Only available in 'isAlignHorizontalCenter' open.
!#zh isAlignHorizontalCenter */
horizontalCenter: number;
/** !#en
Vertical aligns the midpoint offset value,
the value can be negative, Only available in 'isAlignVerticalCenter' open.
!#zh isAlignVerticalCenter */
verticalCenter: number;
/** !#en If true, horizontalCenter is pixel margin, otherwise is percentage (0 - 1) margin.
!#zh true"horizontalCenter" 0 1 */
isAbsoluteHorizontalCenter: boolean;
/** !#en If true, verticalCenter is pixel margin, otherwise is percentage (0 - 1) margin.
!#zh true"verticalCenter" 0 1 */
isAbsoluteVerticalCenter: boolean;
/** !#en
If true, top is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height.
!#zh
true"top" 0 1 */
isAbsoluteTop: boolean;
/** !#en
If true, bottom is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height.
!#zh
true"bottom" 0 1 */
isAbsoluteBottom: boolean;
/** !#en
If true, left is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's width.
!#zh
true"left" 0 1 */
isAbsoluteLeft: boolean;
/** !#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;
/** !#en Specifies the alignment mode of the Widget, which determines when the widget should refresh.
!#zh Widget Widget */
alignMode: Widget.AlignMode;
/**
!#en
Immediately perform the widget alignment. You need to manually call this method only if
you need to get the latest results after the alignment before the end of current frame.
!#zh
widget
widget
@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;
/** !#en
When turned on, it will only be aligned once at the end of the onEnable frame,
then immediately disables the current component.
This will allow the script or animation to continue controlling the current node.
Note: It will still be aligned at the frame when onEnable is called.
!#zh
onEnable
便
onEnable */
isAlignOnce: boolean;
}
/** !#en SubContextView is a view component which controls open data context viewport in minigame platform.<br/>
The component's node size decide the viewport of the sub context content in main context,
the entire sub context texture will be scaled to the node's bounding box area.<br/>
This component provides multiple important features:<br/>
1. Sub context could use its own resolution size and policy.<br/>
2. Sub context could be minized to smallest size it needed.<br/>
3. Resolution of sub context content could be increased.<br/>
4. User touch input is transformed to the correct viewport.<br/>
5. Texture update is handled by this component. User don't need to worry.<br/>
One important thing to be noted, whenever the node's bounding box change,
!#zh SubContextView <br/>
<br/>
<br/>
1. 使<br/>
2. <br/>
3. 便<br/>
4. <br/>
5. <br/> */
export class SubContextView extends Component {
/**
!#en Reset open data context size and viewport
!#zh
*/
reset(): void;
/**
!#en Update the sub context viewport manually, it should be called whenever the node's bounding box changes.
!#zh viewport
*/
updateSubContextViewport(): void;
}
/** !#en WXSubContextView is deprecated since v2.4.1, please use SubContextView instead.
!#zh v2.4.1 WXSubContextView 使 SubContextView */
export class WXSubContextView extends Component {
}
/** !#en SwanSubContextView is deprecated since v2.4.1, please use SubContextView instead.
!#zh v2.4.1 SwanSubContextView 使 SubContextView */
export class SwanSubContextView extends Component {
}
/** !#en Mesh Asset.
!#zh */
export class Mesh extends Asset implements EventTarget {
/** !#en Get ir set the sub meshes.
!#zh */
subMeshes: InputAssembler[];
/**
!#en
Init vertex buffer according to the vertex format.
!#zh
@param vertexFormat vertex format
@param vertexCount how much vertex should be create in this buffer.
@param dynamic whether or not to use dynamic buffer.
@param index index
*/
init(vertexFormat: gfx.VertexFormat, vertexCount: number, dynamic?: boolean, index?: boolean): void;
/**
!#en
Set the vertex values.
!#zh
@param name the attribute name, e.g. gfx.ATTR_POSITION
@param values the vertex values
*/
setVertices(name: string, values: Vec2[]|Vec3[]|Color[]|number[]|Uint8Array|Float32Array): void;
/**
!#en
Set the sub mesh indices.
!#zh
@param indices the sub mesh indices.
@param index sub mesh index.
@param dynamic whether or not to use dynamic buffer.
*/
setIndices(indices: number[]|Uint16Array|Uint8Array, index?: number, dynamic?: boolean): void;
/**
!#en
Set the sub mesh primitive type.
!#zh
线
@param type type
@param index index
*/
setPrimitiveType(type: number, index: number): void;
/**
!#en
Clear the buffer data.
!#zh
*/
clear(): void;
/**
!#en Set mesh bounding box
!#zh
@param min min
@param max max
*/
setBoundingBox(min: Vec3, max: Vec3): void;
/**
!#en Read the specified attributes of the subgrid into the target buffer.
!#zh
@param primitiveIndex The subgrid index.
@param attributeName attribute name.
@param buffer The target buffer.
@param stride The byte interval between adjacent attributes in the target buffer.
@param offset The offset of the first attribute in the target buffer.
*/
copyAttribute(primitiveIndex: number, attributeName: string, buffer: ArrayBuffer, stride: number, offset: number): boolean;
/**
!#en Read the index data of the subgrid into the target array.
!#zh
@param primitiveIndex The subgrid index.
@param outputArray The target array.
*/
copyIndices(primitiveIndex: number, outputArray: DataView): boolean;
/**
!#en Checks whether the EventTarget object has any callback registered for a specific type of event.
!#zh
@param type The type of event.
*/
hasEventListener(type: string): boolean;
/**
!#en
Register an callback of a specific event type on the EventTarget.
This type of event should be triggered via `emit`.
!#zh
`emit`
@param type A string representing the event type to listen for.
@param callback The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null
@example
```js
eventTarget.on('fire', function () {
cc.log("fire in the hole");
}, node);
```
*/
on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
/**
!#en
Removes the listeners previously registered with the same type, callback, target and or useCapture,
if only type is passed as parameter, all listeners registered with that type will be removed.
!#zh
useCapture type type
@param type A string representing the event type being removed.
@param callback The callback to remove.
@param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
@example
```js
// register fire eventListener
var callback = eventTarget.on('fire', function () {
cc.log("fire in the hole");
}, target);
// remove fire event listener
eventTarget.off('fire', callback, target);
// remove all fire event listeners
eventTarget.off('fire');
```
*/
off(type: string, callback?: Function, target?: any): void;
/**
!#en Removes all callbacks previously registered with the same target (passed as parameter).
This is not for removing all listeners in the current event target,
and this is not for removing all listeners the target parameter have registered.
It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
!#zh EventTarget target
EventTarget target
target EventTarget
@param target The target to be searched for all related listeners
*/
targetOff(target: any): void;
/**
!#en
Register an callback of a specific event type on the EventTarget,
the callback will remove itself after the first time it is triggered.
!#zh
@param type A string representing the event type to listen for.
@param callback The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null
@example
```js
eventTarget.once('fire', function () {
cc.log("this is the callback and will be invoked only once");
}, node);
```
*/
once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void;
/**
!#en
Send an event with the event object.
!#zh
@param event event
*/
dispatchEvent(event: Event): void;
}
/** !#en
Mesh Renderer Component
!#zh
*/
export class MeshRenderer extends RenderComponent {
/** !#en
The mesh which the renderer uses.
!#zh
使 */
mesh: Mesh;
/** !#en
Whether the mesh should receive shadows.
!#zh
*/
receiveShadows: boolean;
/** !#en
Shadow Casting Mode
!#zh
*/
shadowCastingMode: MeshRenderer.ShadowCastingMode;
/** !#en
Enable auto merge mesh, only support when mesh's VertexFormat, PrimitiveType, materials are all the same
!#zh
mesh PrimitiveType, 使 */
enableAutoBatch: boolean;
}
/** The class BufferRange denotes a range of the buffer. */
export class BufferRange {
/** The offset of the range. */
offset: number;
/** The length of the range. */
length: number;
}
/** undefined */
export class VertexFormat {
/** The data range of this bundle.
This range of data is essentially mapped to a GPU vertex buffer. */
data: BufferRange;
/** The attribute formats. */
formats: VertexFormat;
/** The vertex bundle that the primitive use. */
vertexBundleIndices: number[];
/** The data range of the primitive.
This range of data is essentially mapped to a GPU indices buffer. */
data: BufferRange;
/** The type of this primitive's indices. */
indexUnit: number;
/** The primitive's topology. */
topology: number;
}
/** undefined */
export class Graphics extends RenderComponent {
/** !#en
Current line width.
!#zh
线 */
lineWidth: number;
/** !#en
lineJoin determines how two connecting segments (of lines, arcs or curves) with non-zero lengths in a shape are joined together.
!#zh
lineJoin 20线线 */
lineJoin: Graphics.LineJoin;
/** !#en
lineCap determines how the end points of every line are drawn.
!#zh
lineCap 线 */
lineCap: Graphics.LineCap;
/** !#en
stroke color
!#zh
线 */
strokeColor: Color;
/** !#en
fill color
!#zh
*/
fillColor: Color;
/** !#en
Sets the miter limit ratio
!#zh
*/
miterLimit: number;
/**
!#en Move path start point to (x,y).
!#zh (x, y)
@param x The x axis of the coordinate for the end point.
@param y The y axis of the coordinate for the end point.
*/
moveTo(x?: number, y?: number): void;
/**
!#en Adds a straight line to the path
!#zh 线
@param x The x axis of the coordinate for the end point.
@param y The y axis of the coordinate for the end point.
*/
lineTo(x?: number, y?: number): void;
/**
!#en Adds a cubic Bézier curve to the path
!#zh 线
@param c1x The x axis of the coordinate for the first control point.
@param c1y The y axis of the coordinate for first control point.
@param c2x The x axis of the coordinate for the second control point.
@param c2y The y axis of the coordinate for the second control point.
@param x The x axis of the coordinate for the end point.
@param y The y axis of the coordinate for the end point.
*/
bezierCurveTo(c1x?: number, c1y?: number, c2x?: number, c2y?: number, x?: number, y?: number): void;
/**
!#en Adds a quadratic Bézier curve to the path
!#zh 线
@param cx The x axis of the coordinate for the control point.
@param cy The y axis of the coordinate for the control point.
@param x The x axis of the coordinate for the end point.
@param y The y axis of the coordinate for the end point.
*/
quadraticCurveTo(cx?: number, cy?: number, x?: number, y?: number): void;
/**
!#en Adds an arc to the path which is centered at (cx, cy) position with radius r starting at startAngle and ending at endAngle going in the given direction by counterclockwise (defaulting to false).
!#zh (cx, cy) r counterclockwise false startAngle endAngle
@param cx The x axis of the coordinate for the center point.
@param cy The y axis of the coordinate for the center point.
@param r The arc's radius.
@param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians.
@param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians.
@param counterclockwise An optional Boolean which, if true, causes the arc to be drawn counter-clockwise between the two angles. By default it is drawn clockwise.
*/
arc(cx?: number, cy?: number, r?: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): void;
/**
!#en Adds an ellipse to the path.
!#zh
@param cx The x axis of the coordinate for the center point.
@param cy The y axis of the coordinate for the center point.
@param rx The ellipse's x-axis radius.
@param ry The ellipse's y-axis radius.
*/
ellipse(cx?: number, cy?: number, rx?: number, ry?: number): void;
/**
!#en Adds an circle to the path.
!#zh
@param cx The x axis of the coordinate for the center point.
@param cy The y axis of the coordinate for the center point.
@param r The circle's radius.
*/
circle(cx?: number, cy?: number, r?: number): void;
/**
!#en Adds an rectangle to the path.
!#zh
@param x The x axis of the coordinate for the rectangle starting point.
@param y The y axis of the coordinate for the rectangle starting point.
@param w The rectangle's width.
@param h The rectangle's height.
*/
rect(x?: number, y?: number, w?: number, h?: number): void;
/**
!#en Adds an round corner rectangle to the path.
!#zh
@param x The x axis of the coordinate for the rectangle starting point.
@param y The y axis of the coordinate for the rectangle starting point.
@param w The rectangles width.
@param h The rectangle's height.
@param r The radius of the rectangle.
*/
roundRect(x?: number, y?: number, w?: number, h?: number, r?: number): void;
/**
!#en Draws a filled rectangle.
!#zh
@param x The x axis of the coordinate for the rectangle starting point.
@param y The y axis of the coordinate for the rectangle starting point.
@param w The rectangle's width.
@param h The rectangle's height.
*/
fillRect(x?: number, y?: number, w?: number, h?: number): void;
/**
!#en Erasing any previously drawn content.
!#zh
@param clean Whether to clean the graphics inner cache.
*/
clear(clean?: boolean): void;
/**
!#en Causes the point of the pen to move back to the start of the current path. It tries to add a straight line from the current point to the start.
!#zh 线
*/
close(): void;
/**
!#en Strokes the current or given path with the current stroke style.
!#zh 线
*/
stroke(): void;
/**
!#en Fills the current or given path with the current fill style.
!#zh 线
*/
fill(): void;
}
/** !#en The module provides utilities for working with file and directory paths
!#zh */
export class path {
/**
!#en Join strings to be a path.
!#zh Path
@example
```js
------------------------------
cc.path.join("a", "b.png"); //-->"a/b.png"
cc.path.join("a", "b", "c.png"); //-->"a/b/c.png"
cc.path.join("a", "b"); //-->"a/b"
cc.path.join("a", "b", "/"); //-->"a/b/"
cc.path.join("a", "b/", "/"); //-->"a/b/"
```
*/
static join(): string;
/**
!#en Get the ext name of a path including '.', like '.png'.
!#zh Path '.' '.png'
@param pathStr pathStr
@example
```js
---------------------------
cc.path.extname("a/b.png"); //-->".png"
cc.path.extname("a/b.png?a=1&b=2"); //-->".png"
cc.path.extname("a/b"); //-->null
cc.path.extname("a/b?a=1&b=2"); //-->null
```
*/
static extname(pathStr: string): any;
/**
!#en Get the main name of a file name
!#zh
@param fileName fileName
*/
static mainFileName(fileName: string): string;
/**
!#en Get the file name of a file path.
!#zh
@param pathStr pathStr
@param extname extname
@example
```js
---------------------------------
cc.path.basename("a/b.png"); //-->"b.png"
cc.path.basename("a/b.png?a=1&b=2"); //-->"b.png"
cc.path.basename("a/b.png", ".png"); //-->"b"
cc.path.basename("a/b.png?a=1&b=2", ".png"); //-->"b"
cc.path.basename("a/b.png", ".txt"); //-->"b.png"
```
*/
static basename(pathStr: string, extname?: string): any;
/**
!#en Get dirname of a file path.
!#zh
@param pathStr pathStr
@example
```js
---------------------------------
* unix
cc.path.driname("a/b/c.png"); //-->"a/b"
cc.path.driname("a/b/c.png?a=1&b=2"); //-->"a/b"
cc.path.dirname("a/b/"); //-->"a/b"
cc.path.dirname("c.png"); //-->""
* windows
cc.path.driname("a\\b\\c.png"); //-->"a\b"
cc.path.driname("a\\b\\c.png?a=1&b=2"); //-->"a\b"
```
*/
static dirname(pathStr: string): any;
/**
!#en Change extname of a file path.
!#zh
@param pathStr pathStr
@param extname extname
@example
```js
---------------------------------
cc.path.changeExtname("a/b.png", ".plist"); //-->"a/b.plist"
cc.path.changeExtname("a/b.png?a=1&b=2", ".plist"); //-->"a/b.plist?a=1&b=2"
```
*/
static changeExtname(pathStr: string, extname?: string): string;
}
/** !#en
AffineTransform class represent an affine transform matrix. It's composed basically by translation, rotation, scale transformations.<br/>
!#zh
AffineTransform 仿<br/> */
export class AffineTransform {
/**
!#en Create a AffineTransform object with all contents in the matrix.
!#zh AffineTransform
@param a a
@param b b
@param c c
@param d d
@param tx tx
@param ty ty
*/
static create(a: number, b: number, c: number, d: number, tx: number, ty: number): AffineTransform;
/**
!#en
Create a identity transformation matrix: <br/>
[ 1, 0, 0, <br/>
0, 1, 0 ]
!#zh
<br/>
[ 1, 0, 0, <br/>
0, 1, 0 ]
*/
static identity(): AffineTransform;
/**
!#en Clone a AffineTransform object from the specified transform.
!#zh AffineTransform
@param t t
*/
static clone(t: AffineTransform): AffineTransform;
/**
!#en
Concatenate a transform matrix to another
The results are reflected in the out affine transform
out = t1 * t2
This function is memory free, you should create the output affine transform by yourself and manage its memory.
!#zh
out AffineTransform
out = t1 * t2
@param out Out object to store the concat result
@param t1 The first transform object.
@param t2 The transform object to concatenate.
*/
static concat(out: AffineTransform, t1: AffineTransform, t2: AffineTransform): AffineTransform;
/**
!#en Get the invert transform of an AffineTransform object.
This function is memory free, you should create the output affine transform by yourself and manage its memory.
!#zh AffineTransform
@param out out
@param t t
*/
static invert(out: AffineTransform, t: AffineTransform): AffineTransform;
/**
!#en Get an AffineTransform object from a given matrix 4x4.
This function is memory free, you should create the output affine transform by yourself and manage its memory.
!#zh 4x4 Matrix AffineTransform AffineTransform
@param out out
@param mat mat
*/
static invert(out: AffineTransform, mat: Mat4): AffineTransform;
/**
!#en Apply the affine transformation on a point.
This function is memory free, you should create the output Vec2 by yourself and manage its memory.
!#zh Vec2
@param out The output point to store the result
@param point Point to apply transform or x.
@param transOrY transform matrix or y.
@param t transform matrix.
*/
static transformVec2(out: Vec2, point: Vec2|number, transOrY: AffineTransform|number, t?: AffineTransform): Vec2;
/**
!#en Apply the affine transformation on a size.
This function is memory free, you should create the output Size by yourself and manage its memory.
!#zh 仿 Size Size
@param out The output point to store the result
@param size size
@param t t
*/
static transformSize(out: Size, size: Size, t: AffineTransform): Size;
/**
!#en Apply the affine transformation on a rect.
This function is memory free, you should create the output Rect by yourself and manage its memory.
!#zh 仿 Rect Rect
@param out out
@param rect rect
@param anAffineTransform anAffineTransform
*/
static transformRect(out: Rect, rect: Rect, anAffineTransform: AffineTransform): Rect;
/**
!#en Apply the affine transformation on a rect, and truns to an Oriented Bounding Box.
This function is memory free, you should create the output vectors by yourself and manage their memory.
!#zh 仿 Rect , Vector
@param out_bl out_bl
@param out_tl out_tl
@param out_tr out_tr
@param out_br out_br
@param rect rect
@param anAffineTransform anAffineTransform
*/
static transformObb(out_bl: Vec2, out_tl: Vec2, out_tr: Vec2, out_br: Vec2, rect: Rect, anAffineTransform: AffineTransform): void;
}
/** A base node for CCNode, it will:
- maintain scene hierarchy and active logic
- notifications if some properties changed
- define some interfaces shares between CCNode
- define machanisms for Enity Component Systems
- define prefab and serialize functions */
export class _BaseNode extends Object implements EventTarget {
/** !#en Name of node.
!#zh */
name: string;
/** !#en The uuid for editor, will be stripped before building project.
!#zh uuid id */
uuid: string;
/** !#en All children nodes.
!#zh */
children: Node[];
/** !#en All children nodes.
!#zh */
childrenCount: number;
/** !#en
The local active state of this node.<br/>
Note that a Node may be inactive because a parent is not active, even if this returns true.<br/>
Use {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}} if you want to check if the Node is actually treated as active in the scene.
!#zh
<br/>
使<br/>
使 {{#crossLink "Node/activeInHierarchy:property"}}{{/crossLink}}。 */
active: boolean;
/** !#en Indicates whether this node is active in the scene.
!#zh */
activeInHierarchy: boolean;
/**
@param name name
*/
constructor(name?: string);
/** !#en The parent of the node.
!#zh */
parent: Node;
/**
!#en Get parent of the node.
!#zh
@example
```js
var parent = this.node.getParent();
```
*/
getParent(): Node;
/**
!#en Set parent of the node.
!#zh
@param value value
@example
```js
node.setParent(newNode);
```
*/
setParent(value: Node): void;
/**
!#en
Properties configuration function <br/>
All properties in attrs will be set to the node, <br/>
when the setter of the node is available, <br/>
the property will be set via setter function.<br/>
!#zh attrs
@param attrs Properties to be set to node
@example
```js
var attrs = { key: 0, num: 100 };
node.attr(attrs);
```
*/
attr(attrs: any): void;
/**
!#en Returns a child from the container given its uuid.
!#zh uuid
@param uuid The uuid to find the child node.
@example
```js
var child = node.getChildByUuid(uuid);
```
*/
getChildByUuid(uuid: string): Node;
/**
!#en Returns a child from the container given its name.
!#zh
@param name A name to find the child node.
@example
```js
var child = node.getChildByName("Test Node");
```
*/
getChildByName(name: string): Node;
/**
!#en
Inserts a child to the node at a specified index.
!#zh
@param child the child node to be inserted
@param siblingIndex the sibling index to place the child in
@example
```js
node.insertChild(child, 2);
```
*/
insertChild(child: Node, siblingIndex: number): void;
/**
!#en Get the sibling index.
!#zh
@example
```js
var index = node.getSiblingIndex();
```
*/
getSiblingIndex(): number;
/**
!#en Set the sibling index of this node.
!#zh
@param index index
@example
```js
node.setSiblingIndex(1);
```
*/
setSiblingIndex(index: number): void;
/**
!#en Walk though the sub children tree of the current node.
Each node, including the current node, in the sub tree will be visited two times, before all children and after all children.
This function call is not recursive, it's based on stack.
Please don't walk any other node inside the walk process.
!#zh
prefunc 访postfunc 访
walk walk
@param prefunc The callback to process node when reach the node for the first time
@param postfunc The callback to process node when re-visit the node after walked all children in its sub tree
@example
```js
node.walk(function (target) {
console.log('Walked through node ' + target.name + ' for the first time');
}, function (target) {
console.log('Walked through node ' + target.name + ' after walked all children in its sub tree');
});
```
*/
walk(prefunc: (target: _BaseNode) => void, postfunc: (target: _BaseNode) => void): void;
/**
!#en
Remove itself from its parent node. If cleanup is `true`, then also remove all events and actions. <br/>
If the cleanup parameter is not passed, it will force a cleanup, so it is recommended that you always pass in the `false` parameter when calling this API.<br/>
If the node orphan, then nothing happens.
!#zh
cleanup `true`action <br/>
API `false` <br/>
@param cleanup true if all actions and callbacks on this node should be removed, false otherwise.
@example
```js
node.removeFromParent();
node.removeFromParent(false);
```
*/
removeFromParent(cleanup?: boolean): void;
/**
!#en
Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter. </p>
If the cleanup parameter is not passed, it will force a cleanup. <br/>
"remove" logic MUST only be on this method <br/>
If a class wants to extend the 'removeChild' behavior it only needs <br/>
to override this method.
!#zh
cleanup <br/>
cleanup true <br/>
@param child The child node which will be removed.
@param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise.
@example
```js
node.removeChild(newNode);
node.removeChild(newNode, false);
```
*/
removeChild(child: Node, cleanup?: boolean): void;
/**
!#en
Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter. <br/>
If the cleanup parameter is not passed, it will force a cleanup.
!#zh
cleanup <br/>
cleanup true
@param cleanup true if all running actions on all children nodes should be cleanup, false otherwise.
@example
```js
node.removeAllChildren();
node.removeAllChildren(false);
```
*/
removeAllChildren(cleanup?: boolean): void;
/**
!#en Is this node a child of the given node?
!#zh
@param parent parent
@example
```js
node.isChildOf(newNode);
```
*/
isChildOf(parent: Node): boolean;
/**
!#en
Returns the component of supplied type if the node has one attached, null if it doesn't.<br/>
You can also get component in the node by passing in the name of the script.
!#zh
<br/>
@param typeOrClassName typeOrClassName
@example
```js
// get sprite component
var sprite = node.getComponent(cc.Sprite);
// get custom test class
var test = node.getComponent("Test");
```
*/
getComponent<T extends Component>(type: {prototype: T}): T;
getComponent(className: string): any;
/**
!#en Returns all components of supplied type in the node.
!#zh
@param typeOrClassName typeOrClassName
@example
```js
var sprites = node.getComponents(cc.Sprite);
var tests = node.getComponents("Test");
```
*/
getComponents<T extends Component>(type: {prototype: T}): T[];
getComponents(className: string): any[];
/**
!#en Returns the component of supplied type in any of its children using depth first search.
!#zh
@param typeOrClassName typeOrClassName
@example
```js
var sprite = node.getComponentInChildren(cc.Sprite);
var Test = node.getComponentInChildren("Test");
```
*/
getComponentInChildren<T extends Component>(type: {prototype: T}): T;
getComponentInChildren(className: string): any;
/**
!#en Returns all components of supplied type in self or any of its children.
!#zh
@param typeOrClassName typeOrClassName
@example
```js
var sprites = node.getComponentsInChildren(cc.Sprite);
var tests = node.getComponentsInChildren("Test");
```
*/
getComponentsInChildren<T extends Component>(type: {prototype: T}): T[];
getComponentsInChildren(className: string): any[];
/**
!#en Adds a component class to the node. You can also add component to node by passing in the name of the script.
!#zh
@param typeOrClassName The constructor or the class name of the component to add
@example
```js
var sprite = node.addComponent(cc.Sprite);
var test = node.addComponent("Test");
```
*/
addComponent<T extends Component>(type: {new(): T}): T;
addComponent(className: string): any;
/**
!#en
Removes a component identified by the given name or removes the component object given.
You can also use component.destroy() if you already have the reference.
!#zh
component.destroy()
@param component The need remove component.
@example
```js
node.removeComponent(cc.Sprite);
var Test = require("Test");
node.removeComponent(Test);
```
*/
removeComponent(component: string|Function|Component): void;
/**
!#en
Destroy all children from the node, and release all their own references to other objects.<br/>
Actual destruct operation will delayed until before rendering.
!#zh
<br/>
@example
```js
node.destroyAllChildren();
```
*/
destroyAllChildren(): void;
/**
!#en Checks whether the EventTarget object has any callback registered for a specific type of event.
!#zh
@param type The type of event.
*/
hasEventListener(type: string): boolean;
/**
!#en
Register an callback of a specific event type on the EventTarget.
This type of event should be triggered via `emit`.
!#zh
`emit`
@param type A string representing the event type to listen for.
@param callback The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null
@example
```js
eventTarget.on('fire', function () {
cc.log("fire in the hole");
}, node);
```
*/
on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
/**
!#en
Removes the listeners previously registered with the same type, callback, target and or useCapture,
if only type is passed as parameter, all listeners registered with that type will be removed.
!#zh
useCapture type type
@param type A string representing the event type being removed.
@param callback The callback to remove.
@param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
@example
```js
// register fire eventListener
var callback = eventTarget.on('fire', function () {
cc.log("fire in the hole");
}, target);
// remove fire event listener
eventTarget.off('fire', callback, target);
// remove all fire event listeners
eventTarget.off('fire');
```
*/
off(type: string, callback?: Function, target?: any): void;
/**
!#en Removes all callbacks previously registered with the same target (passed as parameter).
This is not for removing all listeners in the current event target,
and this is not for removing all listeners the target parameter have registered.
It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
!#zh EventTarget target
EventTarget target
target EventTarget
@param target The target to be searched for all related listeners
*/
targetOff(target: any): void;
/**
!#en
Register an callback of a specific event type on the EventTarget,
the callback will remove itself after the first time it is triggered.
!#zh
@param type A string representing the event type to listen for.
@param callback The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null
@example
```js
eventTarget.once('fire', function () {
cc.log("this is the callback and will be invoked only once");
}, node);
```
*/
once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void;
/**
!#en
Send an event with the event object.
!#zh
@param event event
*/
dispatchEvent(event: Event): void;
/**
!#en
Destroy all callbackInfos.
!#zh
*/
clear(): void;
}
/** !#en
Helper class for setting material blend function.
!#zh
*/
export class BlendFunc {
/** !#en specify the source Blend Factor, this will generate a custom material object, please pay attention to the memory cost.
!#zh */
srcBlendFactor: macro.BlendFactor;
/** !#en specify the destination Blend Factor.
!#zh */
dstBlendFactor: macro.BlendFactor;
}
/** An internal helper class for switching render component's material between normal sprite material and gray sprite material. */
export class GraySpriteState {
/** !#en The normal material.
!#zh */
normalMaterial: Material;
/** !#en The gray material.
!#zh */
grayMaterial: Material;
}
/** misc utilities */
export class misc {
/**
!#en Clamp a value between from and to.
!#zh
<br/>
max_inclusive max_inclusive<br/>
min_inclusive min_inclusive<br/>
@param value value
@param min_inclusive min_inclusive
@param max_inclusive max_inclusive
@example
```js
var v1 = cc.misc.clampf(20, 0, 20); // 20;
var v2 = cc.misc.clampf(-1, 0, 20); // 0;
var v3 = cc.misc.clampf(10, 0, 20); // 10;
```
*/
static clampf(value: number, min_inclusive: number, max_inclusive: number): number;
/**
!#en Clamp a value between 0 and 1.
!#zh 0 ~ 1
@param value value
@example
```js
var v1 = cc.misc.clamp01(20); // 1;
var v2 = cc.misc.clamp01(-1); // 0;
var v3 = cc.misc.clamp01(0.5); // 0.5;
```
*/
static clamp01(value: number): number;
/**
Linear interpolation between 2 numbers, the ratio sets how much it is biased to each end
@param a number A
@param b number B
@param r ratio between 0 and 1
@example
```js
----
lerp
cc.misc.lerp(2,10,0.5)//returns 6
cc.misc.lerp(2,10,0.2)//returns 3.6
```
*/
static lerp(a: number, b: number, r: number): number;
/**
converts degrees to radians
@param angle angle
*/
static degreesToRadians(angle: number): number;
/**
converts radians to degrees
@param angle angle
*/
static radiansToDegrees(angle: number): number;
}
/** !#en The renderer object which provide access to render system APIs,
detailed APIs will be available progressively.
!#zh */
export class renderer {
/** !#en The render engine is available only after cc.game.EVENT_ENGINE_INITED event.<br/>
Normally it will be inited as the webgl render engine, but in wechat open context domain,
it will be inited as the canvas render engine. Canvas render engine is no longer available for other use case since v2.0.
!#zh cc.game.EVENT_ENGINE_INITED <br/>
WebGL Canvas 2.0 Canvas */
static renderEngine: any;
/** !#en The total draw call count in last rendered frame.
!#zh */
static drawCalls: number;
}
/** !#en the device accelerometer reports values for each axis in units of g-force.
!#zh */
export class constructor {
/**
whether enable accelerometer event
@param isEnable isEnable
*/
setAccelerometerEnabled(isEnable: boolean): void;
/**
set accelerometer interval value
@param interval interval
*/
setAccelerometerInterval(interval: number): void;
}
/** undefined */
export enum VerticalTextAlignment {
TOP = 0,
CENTER = 0,
BOTTOM = 0,
}
/** The base class of most of all the objects in Fireball. */
export class Object {
/** !#en The name of the object.
!#zh */
name: string;
/** !#en
Indicates whether the object is not yet destroyed. (It will not be available after being destroyed)<br>
When an object's `destroy` is called, it is actually destroyed after the end of this frame.
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
destroy <br>
`destroy` `isValid` false `isValid` true `destroy`使 `cc.isValid(obj, true)` */
isValid: boolean;
/**
!#en
Destroy this Object, and release all its own references to other objects.<br/>
Actual object destruction will delayed until before rendering.
From the next frame, this object is not usable anymore.
You can use `cc.isValid(obj)` to check whether the object is destroyed before accessing it.
!#zh
<br/>
访使 `cc.isValid(obj)`
@example
```js
obj.destroy();
```
*/
destroy(): boolean;
}
/** Bit mask that controls object states. */
export enum Flags {
DontSave = 0,
EditorOnly = 0,
HideInHierarchy = 0,
}
/** System variables */
export class sys {
/** English language code */
static LANGUAGE_ENGLISH: string;
/** Chinese language code */
static LANGUAGE_CHINESE: string;
/** French language code */
static LANGUAGE_FRENCH: string;
/** Italian language code */
static LANGUAGE_ITALIAN: string;
/** German language code */
static LANGUAGE_GERMAN: string;
/** Spanish language code */
static LANGUAGE_SPANISH: string;
/** Spanish language code */
static LANGUAGE_DUTCH: string;
/** Russian language code */
static LANGUAGE_RUSSIAN: string;
/** Korean language code */
static LANGUAGE_KOREAN: string;
/** Japanese language code */
static LANGUAGE_JAPANESE: string;
/** Hungarian language code */
static LANGUAGE_HUNGARIAN: string;
/** Portuguese language code */
static LANGUAGE_PORTUGUESE: string;
/** Arabic language code */
static LANGUAGE_ARABIC: string;
/** Norwegian language code */
static LANGUAGE_NORWEGIAN: string;
/** Polish language code */
static LANGUAGE_POLISH: string;
/** Turkish language code */
static LANGUAGE_TURKISH: string;
/** Ukrainian language code */
static LANGUAGE_UKRAINIAN: string;
/** Romanian language code */
static LANGUAGE_ROMANIAN: string;
/** Bulgarian language code */
static LANGUAGE_BULGARIAN: string;
/** Unknown language code */
static LANGUAGE_UNKNOWN: string;
static OS_IOS: string;
static OS_ANDROID: string;
static OS_WINDOWS: string;
static OS_MARMALADE: string;
static OS_LINUX: string;
static OS_BADA: string;
static OS_BLACKBERRY: string;
static OS_OSX: string;
static OS_WP8: string;
static OS_WINRT: string;
static OS_UNKNOWN: string;
static UNKNOWN: number;
static WIN32: number;
static LINUX: number;
static MACOS: number;
static ANDROID: number;
static IPHONE: number;
static IPAD: number;
static BLACKBERRY: number;
static NACL: number;
static EMSCRIPTEN: number;
static TIZEN: number;
static WINRT: number;
static WP8: number;
static MOBILE_BROWSER: number;
static DESKTOP_BROWSER: number;
/** Indicates whether executes in editor's window process (Electron's renderer context) */
static EDITOR_PAGE: number;
/** Indicates whether executes in editor's main process (Electron's browser context) */
static EDITOR_CORE: number;
static WECHAT_GAME: number;
static QQ_PLAY: number;
static FB_PLAYABLE_ADS: number;
static BAIDU_GAME: number;
static VIVO_GAME: number;
static OPPO_GAME: number;
static HUAWEI_GAME: number;
static XIAOMI_GAME: number;
static JKW_GAME: number;
static ALIPAY_GAME: number;
static WECHAT_GAME_SUB: number;
static BAIDU_GAME_SUB: number;
static QTT_GAME: number;
static BYTEDANCE_GAME: number;
static BYTEDANCE_GAME_SUB: number;
static LINKSURE: number;
/** BROWSER_TYPE_WECHAT */
static BROWSER_TYPE_WECHAT: string;
static BROWSER_TYPE_ANDROID: string;
static BROWSER_TYPE_IE: string;
static BROWSER_TYPE_EDGE: string;
static BROWSER_TYPE_QQ: string;
static BROWSER_TYPE_MOBILE_QQ: string;
static BROWSER_TYPE_UC: string;
/** uc third party integration. */
static BROWSER_TYPE_UCBS: string;
static BROWSER_TYPE_360: string;
static BROWSER_TYPE_BAIDU_APP: string;
static BROWSER_TYPE_BAIDU: string;
static BROWSER_TYPE_MAXTHON: string;
static BROWSER_TYPE_OPERA: string;
static BROWSER_TYPE_OUPENG: string;
static BROWSER_TYPE_MIUI: string;
static BROWSER_TYPE_FIREFOX: string;
static BROWSER_TYPE_SAFARI: string;
static BROWSER_TYPE_CHROME: string;
static BROWSER_TYPE_LIEBAO: string;
static BROWSER_TYPE_QZONE: string;
static BROWSER_TYPE_SOUGOU: string;
static BROWSER_TYPE_HUAWEI: string;
static BROWSER_TYPE_UNKNOWN: string;
/** Is native ? This is set to be true in jsb auto. */
static isNative: boolean;
/** Is web browser ? */
static isBrowser: boolean;
/**
Is webgl extension support?
@param name name
*/
static glExtension(name: any): boolean;
/**
Get max joint matrix size for skinned mesh renderer.
*/
static getMaxJointMatrixSize(): void;
/**
!#en
Returns the safe area of the screen (in design resolution). If the screen is not notched, the visibleRect will be returned by default.
Currently supports Android, iOS and WeChat Mini Game platform.
!#zh
visibleRectiOS
*/
static getSafeAreaRect(): Rect;
/** Indicate whether system is mobile system */
static isMobile: boolean;
/** Indicate the running platform */
static platform: number;
/** Get current language iso 639-1 code.
Examples of valid language codes include "zh-tw", "en", "en-us", "fr", "fr-fr", "es-es", etc.
The actual value totally depends on results provided by destination platform. */
static languageCode: string;
/** Indicate the current language of the running system */
static language: string;
/** Indicate the running os name */
static os: string;
/** Indicate the running os version */
static osVersion: string;
/** Indicate the running os main version */
static osMainVersion: number;
/** Indicate the running browser type */
static browserType: string|void;
/** Indicate the running browser version */
static browserVersion: string|void;
/** Indicate the real pixel resolution of the whole game window */
static windowPixelResolution: Size;
/** cc.sys.localStorage is a local storage component. */
static localStorage: any;
/** The capabilities of the current platform */
static capabilities: any;
/**
!#en
Get the network type of current device, return cc.sys.NetworkType.LAN if failure.
!#zh
, cc.sys.NetworkType.LAN
*/
static getNetworkType(): sys.NetworkType;
/**
!#en
Get the battery level of current device, return 1.0 if failure.
!#zh
1
*/
static getBatteryLevel(): number;
/**
Forces the garbage collection, only available in JSB
*/
static garbageCollect(): void;
/**
Restart the JS VM, only available in JSB
*/
static restartVM(): void;
/**
Check whether an object is valid,
In web engine, it will return true if the object exist
In native engine, it will return true if the JS object and the correspond native object are both valid
@param obj obj
*/
static isObjectValid(obj: any): boolean;
/**
Dump system informations
*/
static dump(): void;
/**
Open a url in browser
@param url url
*/
static openURL(url: string): void;
/**
Get the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.
*/
static now(): number;
}
/** The fullscreen API provides an easy way for web content to be presented using the user's entire screen.
It's invalid on safari, QQbrowser and android browser */
export class screen {
/**
initialize
*/
init(): void;
/**
return true if it's full now.
*/
fullScreen(): boolean;
/**
change the screen to full mode.
@param element element
@param onFullScreenChange onFullScreenChange
@param onFullScreenError onFullScreenError
*/
requestFullScreen(element: Element, onFullScreenChange: Function, onFullScreenError: Function): void;
/**
exit the full mode.
*/
exitFullScreen(): boolean;
/**
Automatically request full screen with a touch/click event
@param element element
@param onFullScreenChange onFullScreenChange
*/
autoFullScreen(element: Element, onFullScreenChange: Function): void;
}
/** cc.view is the singleton object which represents the game window.<br/>
It's main task include: <br/>
- Apply the design resolution policy<br/>
- Provide interaction with the window, like resize event on web, retina display support, etc...<br/>
- Manage the game view port which can be different with the window<br/>
- Manage the content scale and translation<br/>
<br/>
Since the cc.view is a singleton, you don't need to call any constructor or create functions,<br/>
the standard way to use it is by calling:<br/>
- cc.view.methodName(); <br/> */
export class View extends EventTarget {
/**
!#en
Sets view's target-densitydpi for android mobile browser. it can be set to: <br/>
1. cc.macro.DENSITYDPI_DEVICE, value is "device-dpi" <br/>
2. cc.macro.DENSITYDPI_HIGH, value is "high-dpi" (default value) <br/>
3. cc.macro.DENSITYDPI_MEDIUM, value is "medium-dpi" (browser's default value) <br/>
4. cc.macro.DENSITYDPI_LOW, value is "low-dpi" <br/>
5. Custom value, e.g: "480" <br/>
!#zh
@param densityDPI densityDPI
*/
setTargetDensityDPI(densityDPI: string): void;
/**
!#en
Returns the current target-densitydpi value of cc.view.
!#zh
*/
getTargetDensityDPI(): string;
/**
!#en
Sets whether resize canvas automatically when browser's size changed.<br/>
Useful only on web.
!#zh canvas
Web
@param enabled Whether enable automatic resize with browser's resize event
*/
resizeWithBrowserSize(enabled: boolean): void;
/**
!#en
Sets the callback function for cc.view's resize action,<br/>
this callback will be invoked before applying resolution policy, <br/>
so you can do any additional modifications within the callback.<br/>
Useful only on web.
!#zh cc.view
Web
@param callback The callback function
*/
setResizeCallback(callback: Function|void): void;
/**
!#en
Sets the orientation of the game, it can be landscape, portrait or auto.
When set it to landscape or portrait, and screen w/h ratio doesn't fit,
cc.view will automatically rotate the game canvas using CSS.
Note that this function doesn't have any effect in native,
in native, you need to set the application orientation in native project settings
!#zh
cc.view CSS canvas
native native
@param orientation Possible values: cc.macro.ORIENTATION_LANDSCAPE | cc.macro.ORIENTATION_PORTRAIT | cc.macro.ORIENTATION_AUTO
*/
setOrientation(orientation: number): void;
/**
!#en
Sets whether the engine modify the "viewport" meta in your web page.<br/>
It's enabled by default, we strongly suggest you not to disable it.<br/>
And even when it's enabled, you can still set your own "viewport" meta, it won't be overridden<br/>
Only useful on web
!#zh viewport meta
使 viewport meta
Web
@param enabled Enable automatic modification to "viewport" meta
*/
adjustViewportMeta(enabled: boolean): void;
/**
!#en
Retina support is enabled by default for Apple device but disabled for other devices,<br/>
it takes effect only when you called setDesignResolutionPolicy<br/>
Only useful on web
!#zh Apple Retina
setDesignResolutionPolicy
Web
@param enabled Enable or disable retina display
*/
enableRetina(enabled: boolean): void;
/**
!#en
Check whether retina display is enabled.<br/>
Only useful on web
!#zh Retina
Web
*/
isRetinaEnabled(): boolean;
/**
!#en Whether to Enable on anti-alias
!#zh 齿
@param enabled Enable or not anti-alias
*/
enableAntiAlias(enabled: boolean): void;
/**
!#en Returns whether the current enable on anti-alias
!#zh 齿
*/
isAntiAliasEnabled(): boolean;
/**
!#en
If enabled, the application will try automatically to enter full screen mode on mobile devices<br/>
You can pass true as parameter to enable it and disable it by passing false.<br/>
Only useful on web
!#zh
true false
@param enabled Enable or disable auto full screen on mobile devices
*/
enableAutoFullScreen(enabled: boolean): void;
/**
!#en
Check whether auto full screen is enabled.<br/>
Only useful on web
!#zh
Web
*/
isAutoFullScreenEnabled(): boolean;
/**
!#en
Returns the canvas size of the view.<br/>
On native platforms, it returns the screen size since the view is a fullscreen view.<br/>
On web, it returns the size of the canvas element.
!#zh canvas
native
Web canvas
*/
getCanvasSize(): Size;
/**
!#en
Returns the frame size of the view.<br/>
On native platforms, it returns the screen size since the view is a fullscreen view.<br/>
On web, it returns the size of the canvas's outer DOM element.
!#zh
native
web canvas DOM
*/
getFrameSize(): Size;
/**
!#en
On native, it sets the frame size of view.<br/>
On web, it sets the size of the canvas's outer DOM element.
!#zh native
web canvas DOM
@param width width
@param height height
*/
setFrameSize(width: number, height: number): void;
/**
!#en
Returns the visible area size of the view port.
!#zh
*/
getVisibleSize(): Size;
/**
!#en
Returns the visible area size of the view port.
!#zh
*/
getVisibleSizeInPixel(): Size;
/**
!#en
Returns the visible origin of the view port.
!#zh
*/
getVisibleOrigin(): Vec2;
/**
!#en
Returns the visible origin of the view port.
!#zh
*/
getVisibleOriginInPixel(): Vec2;
/**
!#en
Returns the current resolution policy
!#zh
*/
getResolutionPolicy(): ResolutionPolicy;
/**
!#en
Sets the current resolution policy
!#zh
@param resolutionPolicy resolutionPolicy
*/
setResolutionPolicy(resolutionPolicy: ResolutionPolicy|number): void;
/**
!#en
Sets the resolution policy with designed view size in points.<br/>
The resolution policy include: <br/>
[1] ResolutionExactFit Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched.<br/>
[2] ResolutionNoBorder Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut.<br/>
[3] ResolutionShowAll Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown.<br/>
[4] ResolutionFixedHeight Scale the content's height to screen's height and proportionally scale its width<br/>
[5] ResolutionFixedWidth Scale the content's width to screen's width and proportionally scale its height<br/>
[cc.ResolutionPolicy] [Web only feature] Custom resolution policy, constructed by cc.ResolutionPolicy<br/>
!#zh
@param width Design resolution width.
@param height Design resolution height.
@param resolutionPolicy The resolution policy desired
*/
setDesignResolutionSize(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void;
/**
!#en
Returns the designed size for the view.
Default resolution size is the same as 'getFrameSize'.
!#zh
`getFrameSize`
*/
getDesignResolutionSize(): Size;
/**
!#en
Sets the container to desired pixel resolution and fit the game content to it.
This function is very useful for adaptation in mobile browsers.
In some HD android devices, the resolution is very high, but its browser performance may not be very good.
In this case, enabling retina display is very costy and not suggested, and if retina is disabled, the image may be blurry.
But this API can be helpful to set a desired pixel resolution which is in between.
This API will do the following:
1. Set viewport's width to the desired width in pixel
2. Set body width to the exact pixel resolution
3. The resolution policy will be reset with designed view size in points.
!#zh container
@param width Design resolution width.
@param height Design resolution height.
@param resolutionPolicy The resolution policy desired
*/
setRealPixelResolution(width: number, height: number, resolutionPolicy: ResolutionPolicy|number): void;
/**
!#en
Sets view port rectangle with points.
!#zh
@param x x
@param y y
@param w width
@param h height
*/
setViewportInPoints(x: number, y: number, w: number, h: number): void;
/**
!#en
Sets Scissor rectangle with points.
!#zh scissor
@param x x
@param y y
@param w w
@param h h
*/
setScissorInPoints(x: number, y: number, w: number, h: number): void;
/**
!#en
Returns whether GL_SCISSOR_TEST is enable
!#zh scissor
*/
isScissorEnabled(): boolean;
/**
!#en
Returns the current scissor rectangle
!#zh scissor
*/
getScissorRect(): Rect;
/**
!#en
Returns the view port rectangle.
!#zh
*/
getViewportRect(): Rect;
/**
!#en
Returns scale factor of the horizontal direction (X axis).
!#zh
*/
getScaleX(): number;
/**
!#en
Returns scale factor of the vertical direction (Y axis).
!#zh
*/
getScaleY(): number;
/**
!#en
Returns device pixel ratio for retina display.
!#zh
*/
getDevicePixelRatio(): number;
/**
!#en
Returns the real location in view for a translation based on a related position
!#zh
@param tx The X axis translation
@param ty The Y axis translation
@param relatedPos The related position object including "left", "top", "width", "height" informations
*/
convertToLocationInView(tx: number, ty: number, relatedPos: any): Vec2;
}
/** <p>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</p> */
export class ContainerStrategy {
/**
!#en
Manipulation before appling the strategy
!#zh
@param view The target view
*/
preApply(view: View): void;
/**
!#en
Function to apply this strategy
!#zh
@param view view
@param designedResolution designedResolution
*/
apply(view: View, designedResolution: Size): void;
/**
!#en
Manipulation after applying the strategy
!#zh
@param view The target view
*/
postApply(view: View): void;
}
/** <p>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</p> */
export class ContentStrategy {
/**
!#en
Manipulation before applying the strategy
!#zh
@param view The target view
*/
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
*/
apply(view: View, designedResolution: Size): any;
/**
!#en
Manipulation after applying the strategy
!#zh
@param view The target view
*/
postApply(view: View): void;
}
/** undefined */
export class EqualToFrame extends ContainerStrategy {
}
/** undefined */
export class ProportionalToFrame extends ContainerStrategy {
}
/** undefined */
export class EqualToWindow extends EqualToFrame {
}
/** undefined */
export class ProportionalToWindow extends ProportionalToFrame {
}
/** undefined */
export class OriginalContainer extends ContainerStrategy {
}
/** <p>cc.ResolutionPolicy class is the root strategy class of scale strategy,
its main task is to maintain the compatibility with Cocos2d-x</p> */
export class ResolutionPolicy {
/**
@param containerStg The container strategy
@param contentStg The content strategy
*/
constructor(containerStg: ContainerStrategy, contentStg: ContentStrategy);
/**
!#en Manipulation before applying the resolution policy
!#zh
@param view The target view
*/
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
*/
apply(view: View, designedResolution: Size): any;
/**
!#en Manipulation after appyling the strategy
!#zh
@param view The target view
*/
postApply(view: View): void;
/**
!#en
Setup the container's scale strategy
!#zh
@param containerStg containerStg
*/
setContainerStrategy(containerStg: ContainerStrategy): void;
/**
!#en
Setup the content's scale strategy
!#zh
@param contentStg contentStg
*/
setContentStrategy(contentStg: ContentStrategy): void;
/** The entire application is visible in the specified area without trying to preserve the original aspect ratio.<br/>
Distortion can occur, and the application may appear stretched or compressed. */
static EXACT_FIT: number;
/** The entire application fills the specified area, without distortion but possibly with some cropping,<br/>
while maintaining the original aspect ratio of the application. */
static NO_BORDER: number;
/** The entire application is visible in the specified area without distortion while maintaining the original<br/>
aspect ratio of the application. Borders can appear on two sides of the application. */
static SHOW_ALL: number;
/** The application takes the height of the design resolution size and modifies the width of the internal<br/>
canvas so that it fits the aspect ratio of the device<br/>
no distortion will occur however you must make sure your application works on different<br/>
aspect ratios */
static FIXED_HEIGHT: number;
/** The application takes the width of the design resolution size and modifies the height of the internal<br/>
canvas so that it fits the aspect ratio of the device<br/>
no distortion will occur however you must make sure your application works on different<br/>
aspect ratios */
static FIXED_WIDTH: number;
/** Unknow policy */
static UNKNOWN: number;
}
/** cc.visibleRect is a singleton object which defines the actual visible rect of the current view,
it should represent the same rect as cc.view.getViewportRect() */
export class visibleRect {
/**
initialize
@param visibleRect visibleRect
*/
static init(visibleRect: Rect): void;
/** Top left coordinate of the screen related to the game scene. */
static topLeft: Vec2;
/** Top right coordinate of the screen related to the game scene. */
static topRight: Vec2;
/** Top center coordinate of the screen related to the game scene. */
static top: Vec2;
/** Bottom left coordinate of the screen related to the game scene. */
static bottomLeft: Vec2;
/** Bottom right coordinate of the screen related to the game scene. */
static bottomRight: Vec2;
/** Bottom center coordinate of the screen related to the game scene. */
static bottom: Vec2;
/** Center coordinate of the screen related to the game scene. */
static center: Vec2;
/** Left center coordinate of the screen related to the game scene. */
static left: Vec2;
/** Right center coordinate of the screen related to the game scene. */
static right: Vec2;
/** Width of the screen. */
static width: number;
/** Height of the screen. */
static height: number;
}
/** !#en The callbacks invoker to handle and invoke callbacks by key.
!#zh CallbacksInvoker Key */
export class CallbacksInvoker {
/**
!#zh
!#en
Check if the specified key has any registered callback. If a callback is also specified,
it will only return true if the callback is registered.
@param key key
@param callback callback
@param target target
*/
hasEventListener(key: string, callback?: Function, target?: any): boolean;
/**
!#zh
!#en
Removes all callbacks registered in a certain event type or all callbacks registered with a certain target
@param keyOrTarget The event key to be removed or the target to be removed
*/
removeAll(keyOrTarget: string|any): void;
/**
!#zh
@param key key
@param callback callback
@param target target
*/
off(key: string, callback: Function, target?: any): void;
/**
!#en
Trigger an event directly with the event name and necessary arguments.
!#zh
@param key event type
@param arg1 First argument
@param arg2 Second argument
@param arg3 Third argument
@param arg4 Fourth argument
@param arg5 Fifth argument
@example
```js
eventTarget.emit('fire', event);
eventTarget.emit('fire', message, emitter);
```
*/
emit(key: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any): void;
}
/** !#en Contains information collected during deserialization
!#zh */
export class Details {
/** the obj list whose field needs to load asset by uuid */
uuidObjList: any[];
/** the corresponding field name which referenced to the asset */
uuidPropList: (String|Number)[];
/** list of the depends assets' uuid */
uuidList: string[];
/**
@param data data
*/
init(data: any): void;
reset(): void;
/**
@param obj obj
@param propName propName
@param uuid uuid
*/
push(obj: any, propName: string, uuid: string): void;
/** list of the depends assets' uuid */
uuidList: string[];
/** the obj list whose field needs to load asset by uuid */
uuidObjList: any[];
/** the corresponding field name which referenced to the asset */
uuidPropList: string[];
reset(): void;
/**
@param obj obj
@param propName propName
@param uuid uuid
*/
push(obj: any, propName: string, uuid: string): void;
}
/** undefined */
export class WorldManifold {
/** !#en
world contact point (point of intersection)
!#zh
*/
points: Vec2[];
/** !#en
world vector pointing from A to B
!#zh
A B */
normal: Vec2;
}
/** !#en
A manifold point is a contact point belonging to a contact manifold.
It holds details related to the geometry and dynamics of the contact points.
Note: the impulses are used for internal caching and may not
provide reliable contact forces, especially for high speed collisions.
!#zh
ManifoldPoint
*/
export class ManifoldPoint {
/** !#en
The local point usage depends on the manifold type:
-e_circles: the local center of circleB
-e_faceA: the local center of circleB or the clip point of polygonB
-e_faceB: the clip point of polygonA
!#zh
manifold
- e_circles: circleB
- e_faceA: circleB polygonB
- e_faceB: polygonB */
localPoint: Vec2;
/** !#en
Normal impulse.
!#zh
线 */
normalImpulse: number;
/** !#en
Tangent impulse.
!#zh
线 */
tangentImpulse: number;
}
/** undefined */
export class Manifold {
/** !#en
Manifold type : 0: e_circles, 1: e_faceA, 2: e_faceB
!#zh
Manifold : 0: e_circles, 1: e_faceA, 2: e_faceB */
type: number;
/** !#en
The local point usage depends on the manifold type:
-e_circles: the local center of circleA
-e_faceA: the center of faceA
-e_faceB: the center of faceB
!#zh
manifold
-e_circles: circleA
-e_faceA: faceA
-e_faceB: faceB */
localPoint: Vec2;
/** !#en
-e_circles: not used
-e_faceA: the normal on polygonA
-e_faceB: the normal on polygonB
!#zh
-e_circles: 使
-e_faceA: polygonA
-e_faceB: polygonB */
localNormal: Vec2;
/** !#en
the points of contact.
!#zh
*/
points: ManifoldPoint[];
}
/** !#en
Contact impulses for reporting.
!#zh
*/
export class PhysicsImpulse {
/** !#en
Normal impulses.
!#zh
线 */
normalImpulses: any;
/** !#en
Tangent impulses
!#zh
线 */
tangentImpulses: any;
}
/** !#en
PhysicsContact will be generated during begin and end collision as a parameter of the collision callback.
Note that contacts will be reused for speed up cpu time, so do not cache anything in the contact.
!#zh
使 */
export class PhysicsContact {
/**
!#en
Get the world manifold.
!#zh
*/
getWorldManifold(): WorldManifold;
/**
!#en
Get the manifold.
!#zh
*/
getManifold(): Manifold;
/**
!#en
Get the impulses.
Note: PhysicsImpulse can only used in onPostSolve callback.
!#zh
onPostSolve
*/
getImpulse(): PhysicsImpulse;
/** !#en
One of the collider that collided
!#zh
*/
colliderA: Collider;
/** !#en
One of the collider that collided
!#zh
*/
colliderB: Collider;
/** !#en
If set disabled to true, the contact will be ignored until contact end.
If you just want to disabled contact for current time step or sub-step, please use disabledOnce.
!#zh
disabled true
使 disabledOnce */
disabled: boolean;
/** !#en
Disabled contact for current time step or sub-step.
!#zh
*/
disabledOnce: boolean;
/**
!#en
Is this contact touching?
!#zh
*/
isTouching(): boolean;
/**
!#en
Set the desired tangent speed for a conveyor belt behavior.
!#zh
线
@param tangentSpeed tangentSpeed
*/
setTangentSpeed(tangentSpeed: number): void;
/**
!#en
Get the desired tangent speed.
!#zh
线
*/
getTangentSpeed(): number;
/**
!#en
Override the default friction mixture. You can call this in onPreSolve callback.
!#zh
onPreSolve
@param friction friction
*/
setFriction(friction: number): void;
/**
!#en
Get the friction.
!#zh
*/
getFriction(): number;
/**
!#en
Reset the friction mixture to the default value.
!#zh
*/
resetFriction(): void;
/**
!#en
Override the default restitution mixture. You can call this in onPreSolve callback.
!#zh
onPreSolve
@param restitution restitution
*/
setRestitution(restitution: number): void;
/**
!#en
Get the restitution.
!#zh
*/
getRestitution(): number;
/**
!#en
Reset the restitution mixture to the default value.
!#zh
*/
resetRestitution(): void;
}
/** !#en
Physics manager uses box2d as the inner physics system, and hide most box2d implement details(creating rigidbody, synchronize rigidbody info to node).
You can visit some common box2d function through physics manager(hit testing, raycast, debug info).
Physics manager distributes the collision information to each collision callback when collision is produced.
Note: You need first enable the collision listener in the rigidbody.
!#zh
box2d box2d
访 box2d 线
<br>
{{#crossLink "PhysicsManager.DrawBits"}}{{/crossLink}} */
export class PhysicsManager implements EventTarget {
/** !#en
The ratio transform between physics unit and pixel unit, generally is 32.
!#zh
32 */
static PTM_RATIO: number;
/** !#en
The velocity iterations for the velocity constraint solver.
!#zh
*/
static VELOCITY_ITERATIONS: number;
/** !#en
The position Iterations for the position constraint solver.
!#zh
*/
static POSITION_ITERATIONS: number;
/** !#en
Specify the fixed time step.
Need enabledAccumulator to make it work.
!#zh
enabledAccumulator */
static FIXED_TIME_STEP: number;
/** !#en
Specify the max accumulator time.
Need enabledAccumulator to make it work.
!#zh
enabledAccumulator */
static MAX_ACCUMULATOR: number;
/** !#en
If enabled accumulator, then will call step function with the fixed time step FIXED_TIME_STEP.
And if the update dt is bigger than the time step, then will call step function several times.
If disabled accumulator, then will call step function with a time step calculated with the frame rate.
!#zh
FIXED_TIME_STEP update FIXED_TIME_STEP
frame rate */
enabledAccumulator: boolean;
/**
!#en
Test which collider contains the given world point
!#zh
@param point the world point
*/
testPoint(point: Vec2): PhysicsCollider;
/**
!#en
Test which colliders intersect the given world rect
!#zh
@param rect the world rect
*/
testAABB(rect: Rect): PhysicsCollider[];
/**
!#en
Raycast the world for all colliders in the path of the ray.
The raycast ignores colliders that contain the starting point.
!#zh
线线
@param p1 start point of the raycast
@param p2 end point of the raycast
@param type optional, default is RayCastType.Closest
*/
rayCast(p1: Vec2, p2: Vec2, type: RayCastType): PhysicsRayCastResult[];
/** !#en
Enabled the physics manager?
!#zh
*/
enabled: boolean;
/** !#en
Debug draw flags.
!#zh
*/
debugDrawFlags: number;
/** !#en
The physics world gravity.
!#zh
*/
gravity: Vec2;
/**
!#en Checks whether the EventTarget object has any callback registered for a specific type of event.
!#zh
@param type The type of event.
*/
hasEventListener(type: string): boolean;
/**
!#en
Register an callback of a specific event type on the EventTarget.
This type of event should be triggered via `emit`.
!#zh
`emit`
@param type A string representing the event type to listen for.
@param callback The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null
@example
```js
eventTarget.on('fire', function () {
cc.log("fire in the hole");
}, node);
```
*/
on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
/**
!#en
Removes the listeners previously registered with the same type, callback, target and or useCapture,
if only type is passed as parameter, all listeners registered with that type will be removed.
!#zh
useCapture type type
@param type A string representing the event type being removed.
@param callback The callback to remove.
@param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
@example
```js
// register fire eventListener
var callback = eventTarget.on('fire', function () {
cc.log("fire in the hole");
}, target);
// remove fire event listener
eventTarget.off('fire', callback, target);
// remove all fire event listeners
eventTarget.off('fire');
```
*/
off(type: string, callback?: Function, target?: any): void;
/**
!#en Removes all callbacks previously registered with the same target (passed as parameter).
This is not for removing all listeners in the current event target,
and this is not for removing all listeners the target parameter have registered.
It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
!#zh EventTarget target
EventTarget target
target EventTarget
@param target The target to be searched for all related listeners
*/
targetOff(target: any): void;
/**
!#en
Register an callback of a specific event type on the EventTarget,
the callback will remove itself after the first time it is triggered.
!#zh
@param type A string representing the event type to listen for.
@param callback The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null
@example
```js
eventTarget.once('fire', function () {
cc.log("this is the callback and will be invoked only once");
}, node);
```
*/
once(type: string, callback: (arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) => void, target?: any): void;
/**
!#en
Send an event with the event object.
!#zh
@param event event
*/
dispatchEvent(event: Event): void;
/**
!#en
Destroy all callbackInfos.
!#zh
*/
clear(): void;
}
/** undefined */
export class PhysicsRayCastResult {
/** !#en
The PhysicsCollider which intersects with the raycast
!#zh
线 */
collider: PhysicsCollider;
/** !#en
The intersection point
!#zh
线 */
point: Vec2;
/** !#en
The normal vector at the point of intersection
!#zh
线 */
normal: Vec2;
/** !#en
The fraction of the raycast path at the point of intersection
!#zh
线线 */
fraction: number;
}
/** !#en Enum for RigidBodyType.
!#zh */
export enum RigidBodyType {
Static = 0,
Kinematic = 0,
Dynamic = 0,
Animated = 0,
}
/** !#en Enum for RayCastType.
!#zh 线 */
export enum RayCastType {
Closest = 0,
Any = 0,
AllClosest = 0,
All = 0,
}
/** undefined */
export class RigidBody extends Component {
/** !#en
Should enabled contact listener?
When a collision is trigger, the collision callback will only be called when enabled contact listener.
!#zh
collider */
enabledContactListener: boolean;
/**
!#en
Collision callback.
Called when two collider begin to touch.
!#zh
@param contact contact information
@param selfCollider the collider belong to this rigidbody
@param otherCollider the collider belong to another rigidbody
*/
onBeginContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
/**
!#en
Collision callback.
Called when two collider cease to touch.
!#zh
@param contact contact information
@param selfCollider the collider belong to this rigidbody
@param otherCollider the collider belong to another rigidbody
*/
onEndContact(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
/**
!#en
Collision callback.
This is called when a contact is updated.
This allows you to inspect a contact before it goes to the solver(e.g. disable contact).
Note: this is called only for awake bodies.
Note: this is called even when the number of contact points is zero.
Note: this is not called for sensors.
!#zh
(sensor)
@param contact contact information
@param selfCollider the collider belong to this rigidbody
@param otherCollider the collider belong to another rigidbody
*/
onPreSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
/**
!#en
Collision callback.
This is called after a contact is updated.
You can get the impulses from the contact in this callback.
!#zh
@param contact contact information
@param selfCollider the collider belong to this rigidbody
@param otherCollider the collider belong to another rigidbody
*/
onPostSolve(contact: PhysicsContact, selfCollider: PhysicsCollider, otherCollider: PhysicsCollider): void;
/** !#en
Is this a fast moving body that should be prevented from tunneling through
other moving bodies?
Note :
- All bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies.
- You should use this flag sparingly since it increases processing time.
!#zh
穿
:
- 穿
- 使 */
bullet: boolean;
/** !#en
Rigidbody type : Static, Kinematic, Dynamic or Animated.
!#zh
Static, Kinematic, Dynamic or Animated. */
type: RigidBodyType;
/** !#en
Set this flag to false if this body should never fall asleep.
Note that this increases CPU usage.
!#zh
false
使 CPU */
allowSleep: boolean;
/** !#en
Scale the gravity applied to this body.
!#zh
*/
gravityScale: number;
/** !#en
Linear damping is use to reduce the linear velocity.
The damping parameter can be larger than 1, but the damping effect becomes sensitive to the
time step when the damping parameter is large.
!#zh
Linear damping 线 1 */
linearDamping: number;
/** !#en
Angular damping is use to reduce the angular velocity. The damping parameter
can be larger than 1 but the damping effect becomes sensitive to the
time step when the damping parameter is large.
!#zh
Angular damping 1 */
angularDamping: number;
/** !#en
The linear velocity of the body's origin in world co-ordinates.
!#zh
线 */
linearVelocity: Vec2;
/** !#en
The angular velocity of the body.
!#zh
*/
angularVelocity: number;
/** !#en
Should this body be prevented from rotating?
!#zh
*/
fixedRotation: boolean;
/** !#en
Set the sleep state of the body. A sleeping body has very low CPU cost.(When the rigid body is hit, if the rigid body is in sleep state, it will be immediately awakened.)
!#zh
CPU */
awake: boolean;
/** !#en
Whether to wake up this rigid body during initialization
!#zh
*/
awakeOnLoad: boolean;
/** !#en
Set the active state of the body. An inactive body is not
simulated and cannot be collided with or woken up.
If body is active, all fixtures will be added to the
broad-phase.
If body is inactive, all fixtures will be removed from
the broad-phase and all contacts will be destroyed.
Fixtures on an inactive body are implicitly inactive and will
not participate in collisions, ray-casts, or queries.
Joints connected to an inactive body are implicitly inactive.
!#zh
broad-phase
broad-phase
线
*/
active: boolean;
/**
!#en
Converts a given point in the world coordinate system to this rigid body's local coordinate system
!#zh
@param worldPoint a point in world coordinates.
@param out optional, the receiving point
*/
getLocalPoint(worldPoint: Vec2, out: Vec2): Vec2;
/**
!#en
Converts a given point in this rigid body's local coordinate system to the world coordinate system
!#zh
@param localPoint a point in local coordinates.
@param out optional, the receiving point
*/
getWorldPoint(localPoint: Vec2, out: Vec2): Vec2;
/**
!#en
Converts a given vector in this rigid body's local coordinate system to the world coordinate system
!#zh
@param localVector a vector in world coordinates.
@param out optional, the receiving vector
*/
getWorldVector(localVector: Vec2, out: Vec2): Vec2;
/**
!#en
Converts a given vector in the world coordinate system to this rigid body's local coordinate system
!#zh
@param worldVector a vector in world coordinates.
@param out optional, the receiving vector
*/
getLocalVector(worldVector: Vec2, out: Vec2): Vec2;
/**
!#en
Get the world body origin position.
!#zh
@param out optional, the receiving point
*/
getWorldPosition(out: Vec2): Vec2;
/**
!#en
Get the world body rotation angle.
!#zh
*/
getWorldRotation(): number;
/**
!#en
Get the local position of the center of mass.
!#zh
*/
getLocalCenter(): Vec2;
/**
!#en
Get the world position of the center of mass.
!#zh
*/
getWorldCenter(): Vec2;
/**
!#en
Get the world linear velocity of a world point attached to this body.
!#zh
线
@param worldPoint a point in world coordinates.
@param out optional, the receiving point
*/
getLinearVelocityFromWorldPoint(worldPoint: Vec2, out: Vec2): Vec2;
/**
!#en
Get total mass of the body.
!#zh
*/
getMass(): number;
/**
!#en
Get the rotational inertia of the body about the local origin.
!#zh
*/
getInertia(): number;
/**
!#en
Get all the joints connect to the rigidbody.
!#zh
*/
getJointList(): Joint[];
/**
!#en
Apply a force at a world point. If the force is not
applied at the center of mass, it will generate a torque and
affect the angular velocity.
!#zh
@param force the world force vector.
@param point the world position.
@param wake also wake up the body.
*/
applyForce(force: Vec2, point: Vec2, wake: boolean): void;
/**
!#en
Apply a force to the center of mass.
!#zh
@param force the world force vector.
@param wake also wake up the body.
*/
applyForceToCenter(force: Vec2, wake: boolean): void;
/**
!#en
Apply a torque. This affects the angular velocity.
!#zh
@param torque about the z-axis (out of the screen), usually in N-m.
@param wake also wake up the body
*/
applyTorque(torque: number, wake: boolean): void;
/**
!#en
Apply a impulse at a world point, This immediately modifies the velocity.
If the impulse is not applied at the center of mass, it will generate a torque and
affect the angular velocity.
!#zh
线
@param impulse the world impulse vector, usually in N-seconds or kg-m/s.
@param point the world position
@param wake alse wake up the body
*/
applyLinearImpulse(impulse: Vec2, point: Vec2, wake: boolean): void;
/**
!#en
Apply an angular impulse.
!#zh
@param impulse the angular impulse in units of kg*m*m/s
@param wake also wake up the body
*/
applyAngularImpulse(impulse: number, wake: boolean): void;
/**
!#en
Synchronize node's world position to box2d rigidbody's position.
If enableAnimated is true and rigidbody's type is Animated type,
will set linear velocity instead of directly set rigidbody's position.
!#zh
box2d
enableAnimated true Animated 线
@param enableAnimated enableAnimated
*/
syncPosition(enableAnimated: boolean): void;
/**
!#en
Synchronize node's world angle to box2d rigidbody's angle.
If enableAnimated is true and rigidbody's type is Animated type,
will set angular velocity instead of directly set rigidbody's angle.
!#zh
box2d
enableAnimated true Animated
@param enableAnimated enableAnimated
*/
syncRotation(enableAnimated: boolean): void;
}
/** !#en
Representation of RGBA colors.
Each color component is a floating point value with a range from 0 to 255.
You can also use the convenience method {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} to create a new Color.
!#zh
cc.Color
RGBA 0 255
使 {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} 的便捷方法来创建一个新的 Color。 */
export class Color extends ValueType {
/** !#en Solid white, RGBA is [255, 255, 255, 255].
!#zh RGBA [255, 255, 255, 255] */
static WHITE: Color;
/** !#en Solid black, RGBA is [0, 0, 0, 255].
!#zh RGBA [0, 0, 0, 255] */
static BLACK: Color;
/** !#en Transparent, RGBA is [0, 0, 0, 0].
!#zh RGBA [0, 0, 0, 0] */
static TRANSPARENT: Color;
/** !#en Grey, RGBA is [127.5, 127.5, 127.5].
!#zh RGBA [127.5, 127.5, 127.5] */
static GRAY: Color;
/** !#en Solid red, RGBA is [255, 0, 0].
!#zh RGBA [255, 0, 0] */
static RED: Color;
/** !#en Solid green, RGBA is [0, 255, 0].
!#zh 绿RGBA [0, 255, 0] */
static GREEN: Color;
/** !#en Solid blue, RGBA is [0, 0, 255].
!#zh RGBA [0, 0, 255] */
static BLUE: Color;
/** !#en Yellow, RGBA is [255, 235, 4].
!#zh RGBA [255, 235, 4] */
static YELLOW: Color;
/** !#en Orange, RGBA is [255, 127, 0].
!#zh RGBA [255, 127, 0] */
static ORANGE: Color;
/** !#en Cyan, RGBA is [0, 255, 255].
!#zh RGBA [0, 255, 255] */
static CYAN: Color;
/** !#en Magenta, RGBA is [255, 0, 255].
!#zh RGBA [255, 0, 255] */
static MAGENTA: Color;
/**
Copy content of a color into another.
*/
static copy (out: Color, a: Color): Color;
/**
Clone a new color.
*/
static clone (a: Color): Color;
/**
Set the components of a color to the given values.
*/
static set (out: Color, r?: number, g?: number, b?: number, a?: number): Color;
/**
Converts the hexadecimal formal color into rgb formal.
*/
static fromHex (out: Color, hex: number): Color;
/**
Converts the hexadecimal formal color into rgb formal.
*/
static fromHEX (out: Color, hex: string): Color;
/**
Add components of two colors, respectively.
*/
static add (out: Color, a: Color, b: Color): Color;
/**
Subtract components of color b from components of color a, respectively.
*/
static subtract (out: Color, a: Color, b: Color): Color;
/**
Multiply components of two colors, respectively.
*/
static multiply (out: Color, a: Color, b: Color): Color;
/**
Divide components of color a by components of color b, respectively.
*/
static divide (out: Color, a: Color, b: Color): Color;
/**
Scales a color by a number.
*/
static scale (out: Color, a: Color, b: number): Color;
/**
Performs a linear interpolation between two colors.
*/
static lerp (out: Color, a: Color, b: Color, t: number): Color;
/**
!#zh
!#en Turn an array of colors
@param ofs
*/
static toArray <Out extends IWritableArrayLike<number>> (out: Out, a: IColorLike, ofs?: number): Out;
/**
!#zh
!#en An array of colors turn
@param ofs
*/
static fromArray <Out extends IColorLike> (arr: IWritableArrayLike<number>, out: Out, ofs?: number): Out;
/**
!#zh RGB Alpha
!#en RGB premultiply alpha channel
@param out
@param color
*/
static premultiplyAlpha <Out extends IColorLike> (out: Out, a: IColorLike);
/**
@param r red component of the color, default value is 0.
@param g green component of the color, defualt value is 0.
@param b blue component of the color, default value is 0.
@param a alpha component of the color, default value is 255.
*/
constructor(r?: number, g?: number, b?: number, a?: number);
/**
!#en Clone a new color from the current color.
!#zh
@example
```js
var color = new cc.Color();
var newColor = color.clone();// Color {r: 0, g: 0, b: 0, a: 255}
```
*/
clone(): Color;
/**
!#en TODO
!#zh
@param other other
@example
```js
var color1 = cc.Color.WHITE;
var color2 = new cc.Color(255, 255, 255);
cc.log(color1.equals(color2)); // true;
color2 = cc.Color.RED;
cc.log(color2.equals(color1)); // false;
```
*/
equals(other: Color): boolean;
/**
!#en TODO
!#zh 线
@param to to
@param ratio the interpolation coefficient.
@param out optional, the receiving vector.
@example
```js
// Converts a white color to a black one trough time.
update: function (dt) {
var color = this.node.color;
if (color.equals(cc.Color.BLACK)) {
return;
}
this.ratio += dt * 0.1;
this.node.color = cc.Color.WHITE.lerp(cc.Color.BLACK, ratio);
}
```
*/
lerp(to: Color, ratio: number, out?: Color): Color;
/**
!#en TODO
!#zh 便
@example
```js
var color = cc.Color.WHITE;
color.toString(); // "rgba(255, 255, 255, 255)"
```
*/
toString(): string;
/** !#en Get or set red channel value
!#zh */
r: number;
/** !#en Get or set green channel value
!#zh 绿 */
g: number;
/** !#en Get or set blue channel value
!#zh */
b: number;
/** !#en Get or set alpha channel value
!#zh */
a: number;
/**
!#en Gets red channel value
!#zh
*/
getR(): number;
/**
!#en Sets red value and return the current color object
!#zh
@param red the new Red component.
@example
```js
var color = new cc.Color();
color.setR(255); // Color {r: 255, g: 0, b: 0, a: 255}
```
*/
setR(red: number): Color;
/**
!#en Gets green channel value
!#zh 绿
*/
getG(): number;
/**
!#en Sets green value and return the current color object
!#zh 绿
@param green the new Green component.
@example
```js
var color = new cc.Color();
color.setG(255); // Color {r: 0, g: 255, b: 0, a: 255}
```
*/
setG(green: number): Color;
/**
!#en Gets blue channel value
!#zh
*/
getB(): number;
/**
!#en Sets blue value and return the current color object
!#zh
@param blue the new Blue component.
@example
```js
var color = new cc.Color();
color.setB(255); // Color {r: 0, g: 0, b: 255, a: 255}
```
*/
setB(blue: number): Color;
/**
!#en Gets alpha channel value
!#zh
*/
getA(): number;
/**
!#en Sets alpha value and return the current color object
!#zh
@param alpha the new Alpha component.
@example
```js
var color = new cc.Color();
color.setA(0); // Color {r: 0, g: 0, b: 0, a: 0}
```
*/
setA(alpha: number): Color;
/**
!#en Convert color to css format.
!#zh CSS
@param opt "rgba", "rgb", "#rgb" or "#rrggbb".
@example
```js
var color = cc.Color.BLACK;
color.toCSS(); // "rgba(0,0,0,1.00)";
color.toCSS("rgba"); // "rgba(0,0,0,1.00)";
color.toCSS("rgb"); // "rgba(0,0,0)";
color.toCSS("#rgb"); // "#000";
color.toCSS("#rrggbb"); // "#000000";
```
*/
toCSS(opt?: string): string;
/**
!#en Read hex string and store color data into the current color object, the hex string must be formated as rgba or rgb.
!#zh 16
@param hexString hexString
@example
```js
var color = cc.Color.BLACK;
color.fromHEX("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255};
```
*/
fromHEX(hexString: string): Color;
/**
!#en convert Color to HEX color string.
!#zh 16
@param fmt "#rgb", "#rrggbb" or "#rrggbbaa".
@example
```js
var color = cc.Color.BLACK;
color.toHEX("#rgb"); // "000";
color.toHEX("#rrggbb"); // "000000";
```
*/
toHEX(fmt?: string): string;
/**
!#en Convert to 24bit rgb value.
!#zh 24bit RGB
@example
```js
var color = cc.Color.YELLOW;
color.toRGBValue(); // 16771844;
```
*/
toRGBValue(): number;
/**
!#en Read HSV model color and convert to RGB color
!#zh HSV
@param h h
@param s s
@param v v
@example
```js
var color = cc.Color.YELLOW;
color.fromHSV(0, 0, 1); // Color {r: 255, g: 255, b: 255, a: 255};
```
*/
fromHSV(h: number, s: number, v: number): Color;
/**
!#en Transform to HSV model color
!#zh HSV
@example
```js
var color = cc.Color.YELLOW;
color.toHSV(); // Object {h: 0.1533864541832669, s: 0.9843137254901961, v: 1};
```
*/
toHSV(): any;
/**
!#en Set the color
!#zh
@param color color
*/
set (color: Color): Color;
/**
!#en Multiplies the current color by the specified color
!#zh
@param other other
*/
multiply(other: Color): Color;
}
/** Mathematical 3x3 matrix.
NOTE: we use column-major matrix for all matrix calculation.
This may lead to some confusion when referencing OpenGL documentation,
however, which represents out all matricies in column-major format.
This means that while in code a matrix may be typed out as:
[1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
x, y, z, 0]
The same matrix in the [OpenGL documentation](https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glTranslate.xml)
is written as:
1 0 0 x
0 1 0 y
0 0 1 z
0 0 0 0
Please rest assured, however, that they are the same thing!
This is not unique to glMatrix, either, as OpenGL developers have long been confused by the
apparent lack of consistency between the memory layout and the documentation. */
export class Mat3 extends ValueType {
/** Identity of Mat3 */
static IDENTITY: Mat3;
/**
!#zh
!#en Matrix transpose array
@param ofs
*/
static toArray <Out extends IWritableArrayLike<number>> (out: Out, mat: IMat3Like, ofs?: number): Out;
/**
!#zh
!#en Transfer matrix array
@param ofs
*/
static fromArray <Out extends IMat3Like> (out: Out, arr: IWritableArrayLike<number>, ofs?: number): Out;
/** !#en Matrix Data
!#zh */
m: Float64Array|Float32Array;
constructor (m00?: number | Float32Array, m01?: number, m02?: number, m03?: number, m04?: number, m05?: number, m06?: number, m07?: number, m08?: number);
}
/** !#en Representation of 4*4 matrix.
!#zh 4*4 */
export class Mat4 extends ValueType {
/**
!#en Multiply the current matrix with another one
!#zh
@param other the second operand
@param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created
*/
mul(other: Mat4, out?: Mat4): Mat4;
/**
!#en Multiply each element of the matrix by a scalar.
!#zh
@param number amount to scale the matrix's elements by
@param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created
*/
mulScalar(number: number, out?: Mat4): Mat4;
/**
!#en Subtracts the current matrix with another one
!#zh
@param other the second operand
@param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created
*/
sub(other: Mat4, out?: Mat4): Mat4;
/** Identity of Mat4 */
static IDENTITY: Mat4;
/**
!#zh
!#en Copy of the specified matrix to obtain
*/
static clone<Out extends IMat4Like> (a: Out): Mat4;
/**
!#zh
!#en Copy the target matrix
*/
static copy<Out extends IMat4Like> (out: Out, a: Out): Out;
/**
!#zh
!#en The target of an assignment is the identity matrix
*/
static identity<Out extends IMat4Like> (out: Out): Out;
/**
!#zh
!#en Transposed matrix
*/
static transpose<Out extends IMat4Like> (out: Out, a: Out): Out;
/**
!#zh
!#en Matrix inversion
*/
static invert<Out extends IMat4Like> (out: Out, a: Out): Out;
/**
!#zh
!#en Matrix determinant
*/
static determinant<Out extends IMat4Like> (a: Out): number;
/**
!#zh
!#en Matrix Multiplication
*/
static multiply<Out extends IMat4Like> (out: Out, a: Out, b: Out): Out;
/**
!#zh
!#en Was added in a given transformation matrix transformation on the basis of
*/
static transform<Out extends IMat4Like, VecLike extends IVec3Like> (out: Out, a: Out, v: VecLike): Out;
/**
!#zh
!#en Add new displacement transducer in a matrix transformation on the basis of a given
*/
static translate<Out extends IMat4Like, VecLike extends IVec3Like> (out: Out, a: Out, v: VecLike): Out;
/**
!#zh
!#en Add new scaling transformation in a given matrix transformation on the basis of
*/
static scale<Out extends IMat4Like, VecLike extends IVec3Like> (out: Out, a: Out, v: VecLike): Out;
/**
!#zh
!#en Add a new rotational transform matrix transformation on the basis of a given
@param rad
@param axis
*/
static rotate<Out extends IMat4Like, VecLike extends IVec3Like> (out: Out, a: Out, rad: number, axis: VecLike): Out;
/**
!#zh X
!#en Add rotational transformation around the X axis at a given matrix transformation on the basis of
@param rad
*/
static rotateX<Out extends IMat4Like> (out: Out, a: Out, rad: number): Out;
/**
!#zh Y
!#en Add about the Y axis rotation transformation in a given matrix transformation on the basis of
@param rad
*/
static rotateY<Out extends IMat4Like> (out: Out, a: Out, rad: number): Out;
/**
!#zh Z
!#en Added about the Z axis at a given rotational transformation matrix transformation on the basis of
@param rad
*/
static rotateZ<Out extends IMat4Like> (out: Out, a: Out, rad: number): Out;
/**
!#zh
!#en Displacement matrix calculation
*/
static fromTranslation<Out extends IMat4Like, VecLike extends IVec3Like> (out: Out, v: VecLike): Out;
/**
!#zh
!#en Scaling matrix calculation
*/
static fromScaling<Out extends IMat4Like, VecLike extends IVec3Like> (out: Out, v: VecLike): Out;
/**
!#zh
!#en Calculates the rotation matrix
*/
static fromRotation<Out extends IMat4Like, VecLike extends IVec3Like> (out: Out, rad: number, axis: VecLike): Out;
/**
!#zh X
!#en Calculating rotation matrix about the X axis
*/
static fromXRotation<Out extends IMat4Like> (out: Out, rad: number): Out;
/**
!#zh Y
!#en Calculating rotation matrix about the Y axis
*/
static fromYRotation<Out extends IMat4Like> (out: Out, rad: number): Out;
/**
!#zh Z
!#en Calculating rotation matrix about the Z axis
*/
static fromZRotation<Out extends IMat4Like> (out: Out, rad: number): Out;
/**
!#zh
!#en The rotation and displacement information calculating matrix
*/
static fromRT<Out extends IMat4Like, VecLike extends IVec3Like> (out: Out, q: Quat, v: VecLike): Out;
/**
!#zh , S->R->T
!#en Extracting displacement information of the matrix, the matrix transform to the default sequential application S-> R-> T is
*/
static getTranslation<Out extends IMat4Like, VecLike extends IVec3Like> (out: VecLike, mat: Out): VecLike;
/**
!#zh , S->R->T
!#en Scaling information extraction matrix, the matrix transform to the default sequential application S-> R-> T is
*/
static getScaling<Out extends IMat4Like, VecLike extends IVec3Like> (out: VecLike, mat: Out): VecLike;
/**
!#zh , 使 `toRTS`
!#en Rotation information extraction matrix, the matrix containing no default input scaling information, such as the use of `toRTS` should consider the scaling function.
*/
static getRotation<Out extends IMat4Like> (out: Quat, mat: Out): Quat;
/**
!#zh S->R->T
!#en Extracting rotational displacement, zoom information, the default matrix transformation in order S-> R-> T applications
*/
static toRTS<Out extends IMat4Like, VecLike extends IVec3Like> (mat: Out, q: Quat, v: VecLike, s: VecLike): void;
/**
!#zh S->R->T
!#en The rotary displacement, the scaling matrix calculation information, the order S-> R-> T applications
*/
static fromRTS<Out extends IMat4Like, VecLike extends IVec3Like> (out: Out, q: Quat, v: VecLike, s: VecLike): Out;
/**
!#zh S->R->T
!#en According to the specified rotation, displacement, and scale conversion matrix calculation information center, order S-> R-> T applications
@param q
@param v
@param s
@param o
*/
static fromRTSOrigin<Out extends IMat4Like, VecLike extends IVec3Like> (out: Out, q: Quat, v: VecLike, s: VecLike, o: VecLike): Out;
/**
!#zh
!#en The rotation matrix calculation information specified
*/
static fromQuat<Out extends IMat4Like> (out: Out, q: Quat): Out;
/**
!#zh
!#en The matrix calculation information specified frustum
@param left
@param right
@param bottom
@param top
@param near
@param far
*/
static frustum<Out extends IMat4Like> (out: Out, left: number, right: number, bottom: number, top: number, near: number, far: number): Out;
/**
!#zh
!#en Perspective projection matrix calculation
@param fovy
@param aspect
@param near
@param far
*/
static perspective<Out extends IMat4Like> (out: Out, fovy: number, aspect: number, near: number, far: number): Out;
/**
!#zh
!#en Computing orthogonal projection matrix
@param left
@param right
@param bottom
@param top
@param near
@param far
*/
static ortho<Out extends IMat4Like> (out: Out, left: number, right: number, bottom: number, top: number, near: number, far: number): Out;
/**
!#zh `eye - center` `up`
!#en `Up` parallel vector or vector center` not be zero - the matrix calculation according to the viewpoint, note` eye
@param eye
@param center
@param up
*/
static lookAt<Out extends IMat4Like, VecLike extends IVec3Like> (out: Out, eye: VecLike, center: VecLike, up: VecLike): Out;
/**
!#zh
!#en Reversal matrix calculation
*/
static inverseTranspose<Out extends IMat4Like> (out: Out, a: Out): Out;
/**
!#zh
!#en Element by element matrix addition
*/
static add<Out extends IMat4Like> (out: Out, a: Out, b: Out): Out;
/**
!#zh
!#en Matrix element by element subtraction
*/
static subtract<Out extends IMat4Like> (out: Out, a: Out, b: Out): Out;
/**
!#zh
!#en Matrix scalar multiplication
*/
static multiplyScalar<Out extends IMat4Like> (out: Out, a: Out, b: number): Out;
/**
!#zh : A + B * scale
!#en Elements of the matrix by the scalar multiplication and addition: A + B * scale
*/
static multiplyScalarAndAdd<Out extends IMat4Like> (out: Out, a: Out, b: Out, scale: number): Out;
/**
!#zh
!#en Analyzing the equivalent matrix
*/
static strictEquals<Out extends IMat4Like> (a: Out, b: Out): boolean;
/**
!#zh
!#en Negative floating point error is approximately equivalent to determining a matrix
*/
static equals<Out extends IMat4Like> (a: Out, b: Out, epsilon?: number): boolean;
/**
!#zh
!#en Matrix transpose array
@param ofs
*/
static toArray <Out extends IWritableArrayLike<number>> (out: Out, mat: IMat4Like, ofs?: number): Out;
/**
!#zh
!#en Transfer matrix array
@param ofs
*/
static fromArray <Out extends IMat4Like> (out: Out, arr: IWritableArrayLike<number>, ofs?: number): Out;
/** !#en Matrix Data
!#zh */
m: Float64Array|Float32Array;
/**
!#en
Constructor
see {{#crossLink "cc/mat4:method"}}cc.mat4{{/crossLink}}
!#zh
{{#crossLink "cc/mat4:method"}}cc.mat4{{/crossLink}}
*/
constructor ( m00?: number, m01?: number, m02?: number, m03?: number, m10?: number, m11?: number, m12?: number, m13?: number, m20?: number, m21?: number, m22?: number, m23?: number, m30?: number, m31?: number, m32?: number, m33?: number);
/**
!#en clone a Mat4 object
!#zh Mat4
*/
clone(): Mat4;
/**
!#en Sets the matrix with another one's value
!#zh
@param srcObj srcObj
*/
set(srcObj: Mat4): Mat4;
/**
!#en Check whether two matrix equal
!#zh
@param other other
*/
equals(other: Mat4): boolean;
/**
!#en Check whether two matrix equal with default degree of variance.
!#zh
<br/>
2 true false
@param other other
*/
fuzzyEquals(other: Mat4): boolean;
/**
!#en Transform to string with matrix informations
!#zh 便
*/
toString(): string;
/**
Set the matrix to the identity matrix
*/
identity(): Mat4;
/**
Transpose the values of a mat4
@param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created.
*/
transpose(out?: Mat4): Mat4;
/**
Inverts a mat4
@param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created.
*/
invert(out?: Mat4): Mat4;
/**
Calculates the adjugate of a mat4
@param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created.
*/
adjoint(out?: Mat4): Mat4;
/**
Calculates the determinant of a mat4
*/
determinant(): number;
/**
Adds two Mat4
@param other the second operand
@param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created.
*/
add(other: Mat4, out?: Mat4): Mat4;
/**
Subtracts the current matrix with another one
@param other the second operand
*/
subtract(other: Mat4): Mat4;
/**
Subtracts the current matrix with another one
@param other the second operand
*/
multiply(other: Mat4): Mat4;
/**
Multiply each element of the matrix by a scalar.
@param number amount to scale the matrix's elements by
*/
multiplyScalar(number: number): Mat4;
/**
Translate a mat4 by the given vector
@param v vector to translate by
@param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created
*/
translate(v: Vec3, out?: Mat4): Mat4;
/**
Scales the mat4 by the dimensions in the given vec3
@param v vector to scale by
@param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created
*/
scale(v: Vec3, out?: Mat4): Mat4;
/**
Rotates a mat4 by the given angle around the given axis
@param rad the angle to rotate the matrix by
@param axis the axis to rotate around
@param out the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created
*/
rotate(rad: number, axis: Vec3, out?: Mat4): Mat4;
/**
Returns the translation vector component of a transformation matrix.
@param out Vector to receive translation component, if not provided, a new vec3 will be created
*/
getTranslation(out: Vec3): Vec3;
/**
Returns the scale factor component of a transformation matrix
@param out Vector to receive scale component, if not provided, a new vec3 will be created
*/
getScale(out: Vec3): Vec3;
/**
Returns the rotation factor component of a transformation matrix
@param out Vector to receive rotation component, if not provided, a new quaternion object will be created
*/
getRotation(out: Quat): Quat;
/**
Restore the matrix values from a quaternion rotation, vector translation and vector scale
@param q Rotation quaternion
@param v Translation vector
@param s Scaling vector
*/
fromRTS(q: Quat, v: Vec3, s: Vec3): Mat4;
/**
Restore the matrix values from a quaternion rotation
@param q Rotation quaternion
*/
fromQuat(q: Quat): Mat4;
}
/** !#en Representation of 2D vectors and points.
!#zh 2D */
export class Quat extends ValueType {
/**
!#en
Constructor
see {{#crossLink "cc/quat:method"}}cc.quat{{/crossLink}}
!#zh
{{#crossLink "cc/quat:method"}}cc.quat{{/crossLink}}
@param x x
@param y y
@param z z
@param w w
*/
constructor(x?: number, y?: number, z?: number, w?: number);
/**
!#en Calculate the multiply result between this quaternion and another one
!#zh
@param other other
@param out out
*/
mul(other: Quat, out?: Quat): Quat;
/**
!#zh
!#en Obtaining copy specified quaternion
*/
static clone<Out extends IQuatLike> (a: Out): Quat;
/**
!#zh
!#en Copy quaternion target
*/
static copy<Out extends IQuatLike, QuatLike extends IQuatLike> (out: Out, a: QuatLike): Out;
/**
!#zh
!#en Provided Quaternion Value
*/
static set<Out extends IQuatLike> (out: Out, x: number, y: number, z: number, w: number): Out;
/**
!#zh
!#en The target of an assignment as a unit quaternion
*/
static identity<Out extends IQuatLike> (out: Out): Out;
/**
!#zh
!#en Set quaternion rotation is the shortest path between two vectors, the default two vectors are normalized
*/
static rotationTo<Out extends IQuatLike, VecLike extends IVec3Like> (out: Out, a: VecLike, b: VecLike): Out;
/**
!#zh
!#en Get the rotary shaft and the arc of rotation quaternion
@param outAxis
@param q
*/
static getAxisAngle<Out extends IQuatLike, VecLike extends IVec3Like> (outAxis: VecLike, q: Out): number;
/**
!#zh
!#en Quaternion multiplication
*/
static multiply<Out extends IQuatLike, QuatLike_1 extends IQuatLike, QuatLike_2 extends IQuatLike> (out: Out, a: QuatLike_1, b: QuatLike_2): Out;
/**
!#zh
!#en Quaternion scalar multiplication
*/
static multiplyScalar<Out extends IQuatLike> (out: Out, a: Out, b: number): Out;
/**
!#zh A + B * scale
!#en Quaternion multiplication and addition: A + B * scale
*/
static scaleAndAdd<Out extends IQuatLike> (out: Out, a: Out, b: Out, scale: number): Out;
/**
!#zh X
!#en About the X axis specified quaternion
@param rad
*/
static rotateX<Out extends IQuatLike> (out: Out, a: Out, rad: number): Out;
/**
!#zh Y
!#en Rotation about the Y axis designated quaternion
@param rad
*/
static rotateY<Out extends IQuatLike> (out: Out, a: Out, rad: number): Out;
/**
!#zh Z
!#en Around the Z axis specified quaternion
@param rad
*/
static rotateZ<Out extends IQuatLike> (out: Out, a: Out, rad: number): Out;
/**
!#zh
!#en Space around the world at a given axis of rotation quaternion
@param axis
@param rad
*/
static rotateAround<Out extends IQuatLike, VecLike extends IVec3Like> (out: Out, rot: Out, axis: VecLike, rad: number): Out;
/**
!#zh
!#en Local space around the specified axis rotation quaternion
@param axis
@param rad
*/
static rotateAroundLocal<Out extends IQuatLike, VecLike extends IVec3Like> (out: Out, rot: Out, axis: VecLike, rad: number): Out;
/**
!#zh xyz w
!#en The component w xyz components calculated, normalized by default
*/
static calculateW<Out extends IQuatLike> (out: Out, a: Out): Out;
/**
!#zh
!#en Quaternion dot product (scalar product)
*/
static dot<Out extends IQuatLike> (a: Out, b: Out): number;
/**
!#zh 线 A + t * (B - A)
!#en Element by element linear interpolation: A + t * (B - A)
*/
static lerp<Out extends IQuatLike> (out: Out, a: Out, b: Out, t: number): Out;
/**
!#zh
!#en Spherical quaternion interpolation
*/
static slerp<Out extends IQuatLike, QuatLike_1 extends IQuatLike, QuatLike_2 extends IQuatLike>(out: Out, a: QuatLike_1, b: QuatLike_2, t: number): Out;
/**
!#zh
!#en Quaternion with two spherical interpolation control points
*/
static sqlerp<Out extends IQuatLike> (out: Out, a: Out, b: Out, c: Out, d: Out, t: number): Out;
/**
!#zh
!#en Quaternion inverse
*/
static invert<Out extends IQuatLike, QuatLike extends IQuatLike> (out: Out, a: QuatLike): Out;
/**
!#zh
!#en Conjugating a quaternion, and the unit quaternion equivalent to inversion, but more efficient
*/
static conjugate<Out extends IQuatLike> (out: Out, a: Out): Out;
/**
!#zh
!#en Seek length quaternion
*/
static len<Out extends IQuatLike> (a: Out): number;
/**
!#zh
!#en Seeking quaternion square of the length
*/
static lengthSqr<Out extends IQuatLike> (a: Out): number;
/**
!#zh
!#en Normalized quaternions
*/
static normalize<Out extends IQuatLike> (out: Out, a: Out): Out;
/**
!#zh
!#en Calculated according to the local orientation quaternion coordinate axis, the default three vectors are normalized and mutually perpendicular
*/
static fromAxes<Out extends IQuatLike, VecLike extends IVec3Like> (out: Out, xAxis: VecLike, yAxis: VecLike, zAxis: VecLike): Out;
/**
!#zh
!#en The forward direction and the direction of the viewport computing quaternion
@param view
@param up (0, 1, 0)
*/
static fromViewUp<Out extends IQuatLike> (out: Out, view: Vec3, up?: Vec3): Out;
/**
!#zh
!#en The quaternion calculated and the arc of rotation of the rotary shaft
*/
static fromAxisAngle<Out extends IQuatLike, VecLike extends IVec3Like> (out: Out, axis: VecLike, rad: number): Out;
/**
!#zh
!#en Calculating the three-dimensional quaternion matrix information, default zoom information input matrix does not contain
*/
static fromMat3<Out extends IQuatLike> (out: Out, mat: Mat3): Out;
/**
!#zh YZX
!#en The quaternion calculated Euler angle information, rotation order YZX
*/
static fromEuler<Out extends IQuatLike> (out: Out, x: number, y: number, z: number): Out;
/**
!#zh X
!#en This returns the result of the quaternion coordinate system X-axis vector
*/
static toAxisX<Out extends IQuatLike, VecLike extends IVec3Like> (out: VecLike, q: Out): VecLike;
/**
!#zh Y
!#en This returns the result of the quaternion coordinate system Y axis vector
*/
static toAxisY<Out extends IQuatLike, VecLike extends IVec3Like> (out: VecLike, q: Out): VecLike;
/**
!#zh Z
!#en This returns the result of the quaternion coordinate system the Z-axis vector
*/
static toAxisZ<Out extends IQuatLike, VecLike extends IVec3Like> (out: VecLike, q: Out): VecLike;
/**
!#zh x, y [-180, 180] , z [-90, 90] YZX
!#en The quaternion calculated Euler angles, return angle x, y in the [-180, 180] interval, z default the range [-90, 90] interval, the rotation order YZX
@param outerZ z [-180, -90] U [90, 180]
*/
static toEuler<Out extends IVec3Like> (out: Out, q: IQuatLike, outerZ?: boolean): Out;
/**
!#zh
!#en Analyzing quaternion equivalent
*/
static strictEquals<Out extends IQuatLike> (a: Out, b: Out): boolean;
/**
!#zh
!#en Negative floating point error quaternion approximately equivalent Analyzing
*/
static equals<Out extends IQuatLike> (a: Out, b: Out, epsilon?: number): boolean;
/**
!#zh
!#en Quaternion rotation array
@param ofs
*/
static toArray <Out extends IWritableArrayLike<number>> (out: Out, q: IQuatLike, ofs?: number): Out;
/**
!#zh
!#en Array to a quaternion
@param ofs
*/
static fromArray <Out extends IQuatLike> (out: Out, arr: IWritableArrayLike<number>, ofs?: number): Out;
x: number;
y: number;
z: number;
w: number;
/**
!#en clone a Quat object and return the new object
!#zh
*/
clone(): Quat;
/**
!#en Set values with another quaternion
!#zh
@param newValue !#en new value to set. !#zh
*/
set(newValue: Quat): Quat;
/**
!#en Check whether current quaternion equals another
!#zh
@param other other
*/
equals(other: Quat): boolean;
/**
!#en Convert quaternion to euler
!#zh
@param out out
*/
toEuler(out: Vec3): Vec3;
/**
!#en Convert euler to quaternion
!#zh
@param euler euler
*/
fromEuler(euler: Vec3): Quat;
/**
!#en Calculate the interpolation result between this quaternion and another one with given ratio
!#zh
@param to to
@param ratio ratio
@param out out
*/
lerp(to: Quat, ratio: number, out?: Quat): Quat;
/**
!#en Calculate the multiply result between this quaternion and another one
!#zh
@param other other
*/
multiply(other: Quat): Quat;
/**
!#en Rotates a quaternion by the given angle (in radians) about a world space axis.
!#zh
@param rot Quaternion to rotate
@param axis The axis around which to rotate in world space
@param rad Angle (in radians) to rotate
@param out Quaternion to store result
*/
rotateAround(rot: Quat, axis: Vec3, rad: number, out?: Quat): Quat;
}
/** !#en A 2D rectangle defined by x, y position and width, height.
!#zh 2D */
export class Rect extends ValueType {
/**
!#en
Constructor of Rect class.
see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
!#zh
Rect {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} 便
@param x x
@param y y
@param w w
@param h h
*/
constructor(x?: number, y?: number, w?: number, h?: number);
/**
!#en Creates a rectangle from two coordinate values.
!#zh 2
@param v1 v1
@param v2 v2
@example
```js
cc.Rect.fromMinMax(cc.v2(10, 10), cc.v2(20, 20)); // Rect {x: 10, y: 10, width: 10, height: 10};
```
*/
static fromMinMax(v1: Vec2, v2: Vec2): Rect;
x: number;
y: number;
width: number;
height: number;
/**
!#en TODO
!#zh Rect
@example
```js
var a = new cc.Rect(0, 0, 10, 10);
a.clone();// Rect {x: 0, y: 0, width: 10, height: 10}
```
*/
clone(): Rect;
/**
!#en TODO
!#zh
@param other other
@example
```js
var a = new cc.Rect(0, 0, 10, 10);
var b = new cc.Rect(0, 0, 10, 10);
a.equals(b);// true;
```
*/
equals(other: Rect): boolean;
/**
!#en TODO
!#zh 线
@param to to
@param ratio the interpolation coefficient.
@param out optional, the receiving vector.
@example
```js
var a = new cc.Rect(0, 0, 10, 10);
var b = new cc.Rect(50, 50, 100, 100);
update (dt) {
// method 1;
var c = a.lerp(b, dt * 0.1);
// method 2;
a.lerp(b, dt * 0.1, c);
}
```
*/
lerp(to: Rect, ratio: number, out?: Rect): Rect;
/**
!#en Check whether the current rectangle intersects with the given one
!#zh
@param rect rect
@example
```js
var a = new cc.Rect(0, 0, 10, 10);
var b = new cc.Rect(0, 0, 20, 20);
a.intersects(b);// true
```
*/
intersects(rect: Rect): boolean;
/**
!#en Returns the overlapping portion of 2 rectangles.
!#zh 2
@param out Stores the result
@param rectB rectB
@example
```js
var a = new cc.Rect(0, 10, 20, 20);
var b = new cc.Rect(0, 10, 10, 10);
var intersection = new cc.Rect();
a.intersection(intersection, b); // intersection {x: 0, y: 10, width: 10, height: 10};
```
*/
intersection(out: Rect, rectB: Rect): Rect;
/**
!#en Check whether the current rect contains the given point
!#zh
Returns true if the point inside this rectangle.
@param point point
@example
```js
var a = new cc.Rect(0, 0, 10, 10);
var b = new cc.Vec2(0, 5);
a.contains(b);// true
```
*/
contains(point: Vec2): boolean;
/**
!#en Returns true if the other rect totally inside this rectangle.
!#zh
@param rect rect
@example
```js
var a = new cc.Rect(0, 0, 20, 20);
var b = new cc.Rect(0, 0, 10, 10);
a.containsRect(b);// true
```
*/
containsRect(rect: Rect): boolean;
/**
!#en Returns the smallest rectangle that contains the current rect and the given rect.
!#zh
@param out Stores the result
@param rectB rectB
@example
```js
var a = new cc.Rect(0, 10, 20, 20);
var b = new cc.Rect(0, 10, 10, 10);
var union = new cc.Rect();
a.union(union, b); // union {x: 0, y: 10, width: 20, height: 20};
```
*/
union(out: Rect, rectB: Rect): Rect;
/**
!#en Apply matrix4 to the rect.
!#zh 使 mat4
@param out The output rect
@param mat The matrix4
*/
transformMat4(out: Rect, mat: Mat4): void;
/**
!#en Output rect informations to string
!#zh 便
@example
```js
var a = new cc.Rect(0, 0, 10, 10);
a.toString();// "(0.00, 0.00, 10.00, 10.00)";
```
*/
toString(): string;
/** !#en The minimum x value, equals to rect.x
!#zh x rect.x */
xMin: number;
/** !#en The minimum y value, equals to rect.y
!#zh y */
yMin: number;
/** !#en The maximum x value.
!#zh x */
xMax: number;
/** !#en The maximum y value.
!#zh y */
yMax: number;
/** !#en The position of the center of the rectangle.
!#zh */
center: Vec2;
/** !#en The X and Y position of the rectangle.
!#zh x y */
origin: Vec2;
/** !#en Width and height of the rectangle.
!#zh */
size: Size;
}
/** !#en
cc.Size is the class for size object,<br/>
please do not use its constructor to create sizes,<br/>
use {{#crossLink "cc/size:method"}}{{/crossLink}} alias function instead.<br/>
It will be deprecated soon, please use cc.Vec2 instead.
!#zh
cc.Size size <br/>
使 size<br/>
使 {{#crossLink "cc/size:method"}}{{/crossLink}} 别名函数。<br/>
使cc.Vec2 */
export class Size {
/**
@param width width
@param height height
*/
constructor(width: number|Size, height?: number);
/** !#en return a Size object with width = 0 and height = 0.
!#zh 0 0 Size */
static ZERO: Size;
width: number;
height: number;
/**
!#en TODO
!#zh size
@example
```js
var a = new cc.size(10, 10);
a.clone();// return Size {width: 0, height: 0};
```
*/
clone(): Size;
/**
!#en TODO
!#zh Size Size
@param other other
@example
```js
var a = new cc.size(10, 10);
a.equals(new cc.size(10, 10));// return true;
```
*/
equals(other: Size): boolean;
/**
!#en TODO
!#zh 线
@param to to
@param ratio the interpolation coefficient.
@param out optional, the receiving vector.
@example
```js
var a = new cc.size(10, 10);
var b = new cc.rect(50, 50, 100, 100);
update (dt) {
// method 1;
var c = a.lerp(b, dt * 0.1);
// method 2;
a.lerp(b, dt * 0.1, c);
}
```
*/
lerp(to: Rect, ratio: number, out?: Size): Size;
/**
!#en TODO
!#zh 便
@example
```js
var a = new cc.size(10, 10);
a.toString();// return "(10.00, 10.00)";
```
*/
toString(): string;
}
/** !#en The base class of all value types.
!#zh */
export class ValueType {
/**
!#en This method returns an exact copy of current value.
!#zh
*/
clone(): ValueType;
/**
!#en Compares this object with the other one.
!#zh
@param other other
*/
equals(other: ValueType): boolean;
/**
!#en
Linearly interpolates between this value to to value by ratio which is in the range [0, 1].
When ratio = 0 returns this. When ratio = 1 return to. When ratio = 0.5 returns the average of this and to.
!#zh
线<br/>
ratio = 0 ratio = 1 ratio = 0.5
@param to the to value
@param ratio the interpolation coefficient
*/
lerp(to: ValueType, ratio: number): ValueType;
/**
!#en
Copys all the properties from another given object to this value.
!#zh
@param source the source to copy
*/
set(source: ValueType): void;
/**
!#en Convert to a readable string.
!#zh 便
*/
toString(): string;
}
/** !#en Representation of 2D vectors and points.
!#zh 2D */
export class Vec2 extends ValueType {
/**
!#en Returns the length of this vector.
!#zh
@example
```js
var v = cc.v2(10, 10);
v.mag(); // return 14.142135623730951;
```
*/
mag(): number;
/**
!#en Returns the squared length of this vector.
!#zh
@example
```js
var v = cc.v2(10, 10);
v.magSqr(); // return 200;
```
*/
magSqr(): number;
/**
!#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead.
!#zh 使 sub()
@param vector vector
@example
```js
var v = cc.v2(10, 10);
v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5};
```
*/
subSelf(vector: Vec2): Vec2;
/**
!#en Subtracts one vector from this, and returns the new result.
!#zh
@param vector vector
@param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
@example
```js
var v = cc.v2(10, 10);
v.sub(cc.v2(5, 5)); // return Vec2 {x: 5, y: 5};
var v1 = new Vec2;
v.sub(cc.v2(5, 5), v1); // return Vec2 {x: 5, y: 5};
```
*/
sub(vector: Vec2, out?: Vec2): Vec2;
/**
!#en Multiplies this by a number. If you want to save result to another vector, use mul() instead.
!#zh 使 mul()
@param num num
@example
```js
var v = cc.v2(10, 10);
v.mulSelf(5);// return Vec2 {x: 50, y: 50};
```
*/
mulSelf(num: number): Vec2;
/**
!#en Multiplies by a number, and returns the new result.
!#zh
@param num num
@param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
@example
```js
var v = cc.v2(10, 10);
v.mul(5); // return Vec2 {x: 50, y: 50};
var v1 = new Vec2;
v.mul(5, v1); // return Vec2 {x: 50, y: 50};
```
*/
mul(num: number, out?: Vec2): Vec2;
/**
!#en Divides by a number. If you want to save result to another vector, use div() instead.
!#zh 使 div()
@param num num
@example
```js
var v = cc.v2(10, 10);
v.divSelf(5); // return Vec2 {x: 2, y: 2};
```
*/
divSelf(num: number): Vec2;
/**
!#en Divides by a number, and returns the new result.
!#zh
@param num num
@param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
@example
```js
var v = cc.v2(10, 10);
v.div(5); // return Vec2 {x: 2, y: 2};
var v1 = new Vec2;
v.div(5, v1); // return Vec2 {x: 2, y: 2};
```
*/
div(num: number, out?: Vec2): Vec2;
/**
!#en Multiplies two vectors.
!#zh
@param vector vector
@example
```js
var v = cc.v2(10, 10);
v.scaleSelf(cc.v2(5, 5));// return Vec2 {x: 50, y: 50};
```
*/
scaleSelf(vector: Vec2): Vec2;
/**
!#en Multiplies two vectors, and returns the new result.
!#zh
@param vector vector
@param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
@example
```js
var v = cc.v2(10, 10);
v.scale(cc.v2(5, 5)); // return Vec2 {x: 50, y: 50};
var v1 = new Vec2;
v.scale(cc.v2(5, 5), v1); // return Vec2 {x: 50, y: 50};
```
*/
scale(vector: Vec2, out?: Vec2): Vec2;
/**
!#en Negates the components. If you want to save result to another vector, use neg() instead.
!#zh 使 neg()
@example
```js
var v = cc.v2(10, 10);
v.negSelf(); // return Vec2 {x: -10, y: -10};
```
*/
negSelf(): Vec2;
/**
!#en Negates the components, and returns the new result.
!#zh
@param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
@example
```js
var v = cc.v2(10, 10);
var v1 = new Vec2;
v.neg(v1); // return Vec2 {x: -10, y: -10};
```
*/
neg(out?: Vec2): Vec2;
/** !#en return a Vec2 object with x = 1 and y = 1.
!#zh Vec2 */
static ONE: Vec2;
/** !#en return a Vec2 object with x = 0 and y = 0.
!#zh x = 0 y = 0 Vec2 */
static ZERO: Vec2;
/** !#en return a readonly Vec2 object with x = 0 and y = 0.
!#zh x = 0 y = 0 Vec2 */
static ZERO_R: Vec2;
/** !#en return a Vec2 object with x = 0 and y = 1.
!#zh x = 0 y = 1 Vec2 */
static UP: Vec2;
/** !#en return a readonly Vec2 object with x = 0 and y = 1.
!#zh x = 0 y = 1 Vec2 */
static UP_R: Vec2;
/** !#en return a readonly Vec2 object with x = 1 and y = 0.
!#zh x = 1 y = 0 Vec2 */
static RIGHT: Vec2;
/** !#en return a Vec2 object with x = 1 and y = 0.
!#zh x = 1 y = 0 Vec2 */
static RIGHT_R: Vec2;
/**
!#zh
*/
static clone <Out extends IVec2Like> (a: Out): Vec2;
/**
!#zh
*/
static copy <Out extends IVec2Like> (out: Out, a: Out): Out;
/**
!#zh
*/
static set <Out extends IVec2Like> (out: Out, x: number, y: number): Out;
/**
!#zh
*/
static add <Out extends IVec2Like> (out: Out, a: Out, b: Out): Out;
/**
!#zh
*/
static subtract <Out extends IVec2Like> (out: Out, a: Out, b: Out): Out;
/**
!#zh
*/
static multiply <Out extends IVec2Like> (out: Out, a: Out, b: Out): Out;
/**
!#zh
*/
static divide <Out extends IVec2Like> (out: Out, a: Out, b: Out): Out;
/**
!#zh
*/
static ceil <Out extends IVec2Like> (out: Out, a: Out): Out;
/**
!#zh
*/
static floor <Out extends IVec2Like> (out: Out, a: Out): Out;
/**
!#zh
*/
static min <Out extends IVec2Like> (out: Out, a: Out, b: Out): Out;
/**
!#zh
*/
static max <Out extends IVec2Like> (out: Out, a: Out, b: Out): Out;
/**
!#zh
*/
static round <Out extends IVec2Like> (out: Out, a: Out): Out;
/**
!#zh
*/
static multiplyScalar <Out extends IVec2Like> (out: Out, a: Out, b: number): Out;
/**
!#zh : A + B * scale
*/
static scaleAndAdd <Out extends IVec2Like> (out: Out, a: Out, b: Out, scale: number): Out;
/**
!#zh
*/
static distance <Out extends IVec2Like> (a: Out, b: Out): number;
/**
!#zh
*/
static squaredDistance <Out extends IVec2Like> (a: Out, b: Out): number;
/**
!#zh
*/
static len <Out extends IVec2Like> (a: Out): number;
/**
!#zh
*/
static lengthSqr <Out extends IVec2Like> (a: Out): number;
/**
!#zh
*/
static negate <Out extends IVec2Like> (out: Out, a: Out): Out;
/**
!#zh 0 Infinity
*/
static inverse <Out extends IVec2Like> (out: Out, a: Out): Out;
/**
!#zh 0 0
*/
static inverseSafe <Out extends IVec2Like> (out: Out, a: Out): Out;
/**
!#zh
*/
static normalize <Out extends IVec2Like, Vec2Like extends IVec2Like> (out: Out, a: Vec2Like): Out;
/**
!#zh
*/
static dot <Out extends IVec2Like> (a: Out, b: Out): number;
/**
!#zh Z
*/
static cross <Out extends IVec2Like> (out: Vec2, a: Out, b: Out): Vec2;
/**
!#zh 线 A + t * (B - A)
*/
static lerp <Out extends IVec2Like> (out: Out, a: Out, b: Out, t: number): Out;
/**
!#zh
*/
static random <Out extends IVec2Like> (out: Out, scale?: number): Out;
/**
!#zh 1
*/
static transformMat3 <Out extends IVec2Like, MatLike extends IMat3Like> (out: Out, a: Out, mat: IMat3Like): Out;
/**
!#zh 0 1
*/
static transformMat4 <Out extends IVec2Like, MatLike extends IMat4Like> (out: Out, a: Out, mat: MatLike): Out;
/**
!#zh
*/
static strictEquals <Out extends IVec2Like> (a: Out, b: Out): boolean;
/**
!#zh
*/
static equals <Out extends IVec2Like> (a: Out, b: Out, epsilon?: number): boolean;
/**
!#zh
*/
static angle <Out extends IVec2Like> (a: Out, b: Out): number;
/**
!#zh
*/
static toArray <Out extends IWritableArrayLike<number>> (out: Out, v: IVec2Like, ofs?: number): Out;
/**
!#zh
*/
static fromArray <Out extends IVec2Like> (out: Out, arr: IWritableArrayLike<number>, ofs?: number): Out;
x: number;
y: number;
/**
!#en
Constructor
see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
!#zh
{{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
@param x x
@param y y
*/
constructor(x?: number, y?: number);
/**
!#en clone a Vec2 object
!#zh Vec2
*/
clone(): Vec2;
/**
!#en Sets vector with another's value
!#zh
@param newValue !#en new value to set. !#zh
*/
set(newValue: Vec2): Vec2;
/**
!#en Check whether two vector equal
!#zh
@param other other
*/
equals(other: Vec2): boolean;
/**
!#en Check whether two vector equal with some degree of variance.
!#zh
<br/>
2 true false
@param other other
@param variance variance
*/
fuzzyEquals(other: Vec2, variance: number): boolean;
/**
!#en Transform to string with vector informations
!#zh 便
*/
toString(): string;
/**
!#en Calculate linear interpolation result between this vector and another one with given ratio
!#zh 线
@param to to
@param ratio the interpolation coefficient
@param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
*/
lerp(to: Vec2, ratio: number, out?: Vec2): Vec2;
/**
!#en Clamp the vector between from float and to float.
!#zh
<br/>
max_inclusive max_inclusive<br/>
min_inclusive min_inclusive<br/>
@param min_inclusive min_inclusive
@param max_inclusive max_inclusive
@example
```js
var min_inclusive = cc.v2(0, 0);
var max_inclusive = cc.v2(20, 20);
var v1 = cc.v2(20, 20).clampf(min_inclusive, max_inclusive); // Vec2 {x: 20, y: 20};
var v2 = cc.v2(0, 0).clampf(min_inclusive, max_inclusive); // Vec2 {x: 0, y: 0};
var v3 = cc.v2(10, 10).clampf(min_inclusive, max_inclusive); // Vec2 {x: 10, y: 10};
```
*/
clampf(min_inclusive: Vec2, max_inclusive: Vec2): Vec2;
/**
!#en Adds this vector.
!#zh
@param vector vector
@param out out
@example
```js
var v = cc.v2(10, 10);
v.add(cc.v2(5, 5));// return Vec2 {x: 15, y: 15};
```
*/
add(vector: Vec2, out?: Vec2): Vec2;
/**
!#en Adds this vector. If you want to save result to another vector, use add() instead.
!#zh 使 add()
@param vector vector
*/
addSelf(vector: Vec2): Vec2;
/**
!#en Subtracts one vector from this.
!#zh
@param vector vector
@example
```js
var v = cc.v2(10, 10);
v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5};
```
*/
subtract(vector: Vec2): Vec2;
/**
!#en Multiplies this by a number.
!#zh
@param num num
@example
```js
var v = cc.v2(10, 10);
v.multiply(5);// return Vec2 {x: 50, y: 50};
```
*/
multiplyScalar(num: number): Vec2;
/**
!#en Multiplies two vectors.
!#zh
@param vector vector
@example
```js
var v = cc.v2(10, 10);
v.multiply(cc.v2(5, 5));// return Vec2 {x: 50, y: 50};
```
*/
multiply(vector: Vec2): Vec2;
/**
!#en Divides by a number.
!#zh
@param num num
@example
```js
var v = cc.v2(10, 10);
v.divide(5); // return Vec2 {x: 2, y: 2};
```
*/
divide(num: number): Vec2;
/**
!#en Negates the components.
!#zh
@example
```js
var v = cc.v2(10, 10);
v.negate(); // return Vec2 {x: -10, y: -10};
```
*/
negate(): Vec2;
/**
!#en Dot product
!#zh
@param vector vector
@example
```js
var v = cc.v2(10, 10);
v.dot(cc.v2(5, 5)); // return 100;
```
*/
dot(vector?: Vec2): number;
/**
!#en Cross product
!#zh
@param vector vector
@example
```js
var v = cc.v2(10, 10);
v.cross(cc.v2(5, 5)); // return 0;
```
*/
cross(vector?: Vec2): number;
/**
!#en Returns the length of this vector.
!#zh
@example
```js
var v = cc.v2(10, 10);
v.len(); // return 14.142135623730951;
```
*/
len(): number;
/**
!#en Returns the squared length of this vector.
!#zh
@example
```js
var v = cc.v2(10, 10);
v.lengthSqr(); // return 200;
```
*/
lengthSqr(): number;
/**
!#en Make the length of this vector to 1.
!#zh 1
@example
```js
var v = cc.v2(10, 10);
v.normalizeSelf(); // return Vec2 {x: 0.7071067811865475, y: 0.7071067811865475};
```
*/
normalizeSelf(): Vec2;
/**
!#en
Returns this vector with a magnitude of 1.<br/>
<br/>
Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function.
!#zh
<br/>
<br/>
使 normalizeSelf
@param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
*/
normalize(out?: Vec2): Vec2;
/**
!#en Get angle in radian between this and vector.
!#zh
@param vector vector
*/
angle(vector: Vec2): number;
/**
!#en Get angle in radian between this and vector with direction.
!#zh
@param vector vector
*/
signAngle(vector: Vec2): number;
/**
!#en rotate
!#zh
@param radians radians
@param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
*/
rotate(radians: number, out?: Vec2): Vec2;
/**
!#en rotate self
!#zh
@param radians radians
*/
rotateSelf(radians: number): Vec2;
/**
!#en Calculates the projection of the current vector over the given vector.
!#zh vector
@param vector vector
@example
```js
var v1 = cc.v2(20, 20);
var v2 = cc.v2(5, 5);
v1.project(v2); // Vec2 {x: 20, y: 20};
```
*/
project(vector: Vec2): Vec2;
/**
Transforms the vec2 with a mat4. 3rd vector component is implicitly '0', 4th vector component is implicitly '1'
@param m matrix to transform with
@param out the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
*/
transformMat4(m: Mat4, out?: Vec2): Vec2;
/**
Returns the maximum value in x, y.
*/
maxAxis(): number;
}
/** !#en Representation of 3D vectors and points.
!#zh 3D */
export class Vec3 extends ValueType {
/**
!#en Returns the length of this vector.
!#zh
@example
```js
var v = cc.v3(10, 10, 10);
v.mag(); // return 17.320508075688775;
```
*/
mag(): number;
/**
!#en Returns the squared length of this vector.
!#zh
*/
magSqr(): number;
/**
!#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead.
!#zh 使 sub()
@param vector vector
*/
subSelf(vector: Vec3): Vec3;
/**
!#en Subtracts one vector from this, and returns the new result.
!#zh
@param vector vector
@param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created
*/
sub(vector: Vec3, out?: Vec3): Vec3;
/**
!#en Multiplies this by a number. If you want to save result to another vector, use mul() instead.
!#zh 使 mul()
@param num num
*/
mulSelf(num: number): Vec3;
/**
!#en Multiplies by a number, and returns the new result.
!#zh
@param num num
@param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created
*/
mul(num: number, out?: Vec3): Vec3;
/**
!#en Divides by a number. If you want to save result to another vector, use div() instead.
!#zh 使 div()
@param num num
*/
divSelf(num: number): Vec3;
/**
!#en Divides by a number, and returns the new result.
!#zh
@param num num
@param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created
*/
div(num: number, out?: Vec3): Vec3;
/**
!#en Multiplies two vectors.
!#zh
@param vector vector
*/
scaleSelf(vector: Vec3): Vec3;
/**
!#en Multiplies two vectors, and returns the new result.
!#zh
@param vector vector
@param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created
*/
scale(vector: Vec3, out?: Vec3): Vec3;
/**
!#en Negates the components. If you want to save result to another vector, use neg() instead.
!#zh 使 neg()
*/
negSelf(): Vec3;
/**
!#en Negates the components, and returns the new result.
!#zh
@param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created
*/
neg(out?: Vec3): Vec3;
/** !#en return a Vec3 object with x = 1, y = 1, z = 1.
!#zh Vec3 */
static ONE: Vec3;
/** !#en return a Vec3 object with x = 0, y = 0, z = 0.
!#zh x = 0y = 0z = 0 Vec3 */
static ZERO: Vec3;
/** !#en return a Vec3 object with x = 0, y = 1, z = 0.
!#zh x = 0, y = 1, z = 0 Vec3 */
static UP: Vec3;
/** !#en return a Vec3 object with x = 1, y = 0, z = 0.
!#zh x = 1y = 0z = 0 Vec3 */
static RIGHT: Vec3;
/** !#en return a Vec3 object with x = 0, y = 0, z = 1.
!#zh x = 0y = 0z = 1 Vec3 */
static FORWARD: Vec3;
/**
!#zh
!#en The target of an assignment zero vector
*/
static zero<Out extends IVec3Like> (out: Out): Out;
/**
!#zh
!#en Obtaining copy vectors designated
*/
static clone<Out extends IVec3Like> (a: Out): Vec3;
/**
!#zh
!#en Copy the target vector
*/
static copy<Out extends IVec3Like, Vec3Like extends IVec3Like> (out: Out, a: Vec3Like): Out;
/**
!#zh
!#en Set to value
*/
static set<Out extends IVec3Like> (out: Out, x: number, y: number, z: number): Out;
/**
!#zh
!#en Element-wise vector addition
*/
static add<Out extends IVec3Like> (out: Out, a: Out, b: Out): Out;
/**
!#zh
!#en Element-wise vector subtraction
*/
static subtract<Out extends IVec3Like> (out: Out, a: Out, b: Out): Out;
/**
!#zh ()
!#en Element-wise vector multiplication (product component)
*/
static multiply<Out extends IVec3Like, Vec3Like_1 extends IVec3Like, Vec3Like_2 extends IVec3Like> (out: Out, a: Vec3Like_1, b: Vec3Like_2): Out;
/**
!#zh
!#en Element-wise vector division
*/
static divide<Out extends IVec3Like> (out: Out, a: Out, b: Out): Out;
/**
!#zh
!#en Rounding up by elements of the vector
*/
static ceil<Out extends IVec3Like> (out: Out, a: Out): Out;
/**
!#zh
!#en Element vector by rounding down
*/
static floor<Out extends IVec3Like> (out: Out, a: Out): Out;
/**
!#zh
!#en The minimum by-element vector
*/
static min<Out extends IVec3Like> (out: Out, a: Out, b: Out): Out;
/**
!#zh
!#en The maximum value of the element-wise vector
*/
static max<Out extends IVec3Like> (out: Out, a: Out, b: Out): Out;
/**
!#zh
!#en Element-wise vector of rounding to whole
*/
static round<Out extends IVec3Like> (out: Out, a: Out): Out;
/**
!#zh
!#en Vector scalar multiplication
*/
static multiplyScalar<Out extends IVec3Like, Vec3Like extends IVec3Like> (out: Out, a: Vec3Like, b: number): Out;
/**
!#zh : A + B * scale
!#en Element-wise vector multiply add: A + B * scale
*/
static scaleAndAdd<Out extends IVec3Like> (out: Out, a: Out, b: Out, scale: number): Out;
/**
!#zh
!#en Seeking two vectors Euclidean distance
*/
static distance<Out extends IVec3Like> (a: Out, b: Out): number;
/**
!#zh
!#en Euclidean distance squared seeking two vectors
*/
static squaredDistance<Out extends IVec3Like> (a: Out, b: Out): number;
/**
!#zh
!#en Seeking vector length
*/
static len<Out extends IVec3Like> (a: Out): number;
/**
!#zh
!#en Seeking squared vector length
*/
static lengthSqr<Out extends IVec3Like> (a: Out): number;
/**
!#zh
!#en By taking the negative elements of the vector
*/
static negate<Out extends IVec3Like> (out: Out, a: Out): Out;
/**
!#zh 0 Infinity
!#en Element vector by taking the inverse, return near 0 Infinity
*/
static inverse<Out extends IVec3Like> (out: Out, a: Out): Out;
/**
!#zh 0 0
!#en Element vector by taking the inverse, return near 0 0
*/
static inverseSafe<Out extends IVec3Like> (out: Out, a: Out): Out;
/**
!#zh
!#en Normalized vector
*/
static normalize<Out extends IVec3Like, Vec3Like extends IVec3Like> (out: Out, a: Vec3Like): Out;
/**
!#zh
!#en Vector dot product (scalar product)
*/
static dot<Out extends IVec3Like> (a: Out, b: Out): number;
/**
!#zh
!#en Vector cross product (vector product)
*/
static cross<Out extends IVec3Like, Vec3Like_1 extends IVec3Like, Vec3Like_2 extends IVec3Like> (out: Out, a: Vec3Like_1, b: Vec3Like_2): Out;
/**
!#zh 线 A + t * (B - A)
!#en Vector element by element linear interpolation: A + t * (B - A)
*/
static lerp<Out extends IVec3Like> (out: Out, a: Out, b: Out, t: number): Out;
/**
!#zh
!#en Generates a uniformly distributed random vectors on the unit sphere
@param scale
*/
static random<Out extends IVec3Like> (out: Out, scale?: number): Out;
/**
!#zh 1
!#en Four-dimensional vector and matrix multiplication, the default vectors fourth one.
*/
static transformMat4<Out extends IVec3Like, Vec3Like extends IVec3Like, MatLike extends IMat4Like> (out: Out, a: Vec3Like, mat: MatLike): Out;
/**
!#zh 0
!#en Four-dimensional vector and matrix multiplication, vector fourth default is 0.
*/
static transformMat4Normal<Out extends IVec3Like, MatLike extends IMat4Like> (out: Out, a: Out, mat: MatLike): Out;
/**
!#zh
!#en Dimensional vector matrix multiplication
*/
static transformMat3<Out extends IVec3Like, MatLike extends IMat3Like> (out: Out, a: Out, mat: MatLike): Out;
/**
!#zh 仿
!#en Affine transformation vector
*/
static transformAffine<Out extends IVec3Like, VecLike extends IVec3Like, MatLike extends IMat4Like>(out: Out, v: VecLike, mat: MatLike): Out;
/**
!#zh
!#en Vector quaternion multiplication
*/
static transformQuat<Out extends IVec3Like, VecLike extends IVec3Like, QuatLike extends IQuatLike> (out: Out, a: VecLike, q: QuatLike): Out;
/**
!#zh -> ->
!#en To scale -> rotation -> transformation vector sequence translation
*/
static transformRTS<Out extends IVec3Like, VecLike extends IVec3Like, QuatLike extends IQuatLike>(out: Out, a: VecLike, r: QuatLike, t: VecLike, s: VecLike): Out;
/**
!#zh -> ->
!#en Translational -> rotation -> Zoom inverse transformation vector sequence
*/
static transformInverseRTS<Out extends IVec3Like, VecLike extends IVec3Like, QuatLike extends IQuatLike>(out: Out, a: VecLike, r: QuatLike, t: VecLike, s: VecLike): Out;
/**
!#zh X
!#en Rotation vector specified angle about the X axis
@param v
@param o
@param a
*/
static rotateX<Out extends IVec3Like> (out: Out, v: Out, o: Out, a: number): Out;
/**
!#zh Y
!#en Rotation vector specified angle around the Y axis
@param v
@param o
@param a
*/
static rotateY<Out extends IVec3Like> (out: Out, v: Out, o: Out, a: number): Out;
/**
!#zh Z
!#en Around the Z axis specified angle vector
@param v
@param o
@param a
*/
static rotateZ<Out extends IVec3Like> (out: Out, v: Out, o: Out, a: number): Out;
/**
!#zh
!#en Equivalent vectors Analyzing
*/
static strictEquals<Out extends IVec3Like> (a: Out, b: Out): boolean;
/**
!#zh
!#en Negative error vector floating point approximately equivalent Analyzing
*/
static equals<Out extends IVec3Like> (a: Out, b: Out, epsilon?: number): boolean;
/**
!#zh
!#en Radian angle between two vectors seek
*/
static angle<Out extends IVec3Like> (a: Out, b: Out): number;
/**
!#zh
!#en Calculating a projection vector in the specified plane
@param a
@param n 线
*/
static projectOnPlane<Out extends IVec3Like> (out: Out, a: Out, n: Out): Out;
/**
!#zh
!#en Projection vector calculated in the vector designated
@param a
@param n
*/
static project<Out extends IVec3Like> (out: Out, a: Out, b: Out): Out;
/**
!#zh
!#en Vector transfer array
@param ofs
*/
static toArray <Out extends IWritableArrayLike<number>> (out: Out, v: IVec3Like, ofs?: number): Out;
/**
!#zh
!#en Array steering amount
@param ofs
*/
static fromArray <Out extends IVec3Like> (out: Out, arr: IWritableArrayLike<number>, ofs?: number): Out;
x: number;
y: number;
z: number;
/**
!#en
Constructor
see {{#crossLink "cc/vec3:method"}}cc.v3{{/crossLink}}
!#zh
{{#crossLink "cc/vec3:method"}}cc.v3{{/crossLink}}
@param x x
@param y y
@param z z
*/
constructor(x?: Vec3|number, y?: number, z?: number);
/**
!#en clone a Vec3 value
!#zh Vec3
*/
clone(): Vec3;
/**
!#en Set the current vector value with the given vector.
!#zh
@param newValue !#en new value to set. !#zh
*/
set(newValue: Vec3): Vec3;
/**
!#en Check whether the vector equals another one
!#zh
@param other other
*/
equals(other: Vec3): boolean;
/**
!#en Check whether two vector equal with some degree of variance.
!#zh
<br/>
2 true false
@param other other
@param variance variance
*/
fuzzyEquals(other: Vec3, variance: number): boolean;
/**
!#en Transform to string with vector informations
!#zh 便
*/
toString(): string;
/**
!#en Calculate linear interpolation result between this vector and another one with given ratio
!#zh 线
@param to to
@param ratio the interpolation coefficient
@param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created
*/
lerp(to: Vec3, ratio: number, out?: Vec3): Vec3;
/**
!#en Clamp the vector between from float and to float.
!#zh
<br/>
max_inclusive max_inclusive<br/>
min_inclusive min_inclusive<br/>
@param min_inclusive min_inclusive
@param max_inclusive max_inclusive
*/
clampf(min_inclusive: Vec3, max_inclusive: Vec3): Vec3;
/**
!#en Adds this vector. If you want to save result to another vector, use add() instead.
!#zh 使 add()
@param vector vector
*/
addSelf(vector: Vec3): Vec3;
/**
!#en Adds two vectors, and returns the new result.
!#zh
@param vector vector
@param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created
*/
add(vector: Vec3, out?: Vec3): Vec3;
/**
!#en Subtracts one vector from this.
!#zh
@param vector vector
*/
subtract(vector: Vec3): Vec3;
/**
!#en Multiplies this by a number.
!#zh
@param num num
*/
multiplyScalar(num: number): Vec3;
/**
!#en Multiplies two vectors.
!#zh
@param vector vector
*/
multiply(vector: Vec3): Vec3;
/**
!#en Divides by a number.
!#zh
@param num num
*/
divide(num: number): Vec3;
/**
!#en Negates the components.
!#zh
*/
negate(): Vec3;
/**
!#en Dot product
!#zh
@param vector vector
*/
dot(vector?: Vec3): number;
/**
!#en Cross product
!#zh
@param vector vector
@param out out
*/
cross(vector: Vec3, out?: Vec3): Vec3;
/**
!#en Returns the length of this vector.
!#zh
@example
```js
var v = cc.v3(10, 10, 10);
v.len(); // return 17.320508075688775;
```
*/
len(): number;
/**
!#en Returns the squared length of this vector.
!#zh
*/
lengthSqr(): number;
/**
!#en Make the length of this vector to 1.
!#zh 1
*/
normalizeSelf(): Vec3;
/**
!#en
Returns this vector with a magnitude of 1.<br/>
<br/>
Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function.
!#zh
<br/>
<br/>
使 normalizeSelf
@param out optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created
*/
normalize(out?: Vec3): Vec3;
/**
Transforms the vec3 with a mat4. 4th vector component is implicitly '1'
@param m matrix to transform with
@param out the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created
*/
transformMat4(m: Mat4, out?: Vec3): Vec3;
/**
Returns the maximum value in x, y, and z
*/
maxAxis(): number;
/**
!#en Get angle in radian between this and vector.
!#zh
@param vector vector
*/
angle(vector: Vec3): number;
/**
!#en Calculates the projection of the current vector over the given vector.
!#zh vector
@param vector vector
@example
```js
var v1 = cc.v3(20, 20, 20);
var v2 = cc.v3(5, 5, 5);
v1.project(v2); // Vec3 {x: 20, y: 20, z: 20};
```
*/
project(vector: Vec3): Vec3;
/**
!#en Get angle in radian between this and vector with direction. <br/>
In order to compatible with the vec2 API.
!#zh 2D
@param vector vector
*/
signAngle(vector: Vec3|Vec2): number;
/**
!#en rotate. In order to compatible with the vec2 API.
!#zh 2D
@param radians radians
@param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
*/
rotate(radians: number, out?: Vec3): Vec2;
/**
!#en rotate self. In order to compatible with the vec2 API.
!#zh 2D
@param radians radians
*/
rotateSelf(radians: number): Vec3;
}
/** !#en Representation of 3D vectors and points.
!#zh 3D */
export class Vec4 extends ValueType {
/**
!#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead.
!#zh 使 sub()
@param vector vector
*/
subSelf(vector: Vec4): Vec4;
/**
!#en Subtracts one vector from this, and returns the new result.
!#zh
@param vector vector
@param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
*/
sub(vector: Vec4, out?: Vec4): Vec4;
/**
!#en Multiplies this by a number. If you want to save result to another vector, use mul() instead.
!#zh 使 mul()
@param num num
*/
mulSelf(num: number): Vec4;
/**
!#en Multiplies by a number, and returns the new result.
!#zh
@param num num
@param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
*/
mul(num: number, out?: Vec4): Vec4;
/**
!#en Divides by a number. If you want to save result to another vector, use div() instead.
!#zh 使 div()
@param num num
*/
divSelf(num: number): Vec4;
/**
!#en Divides by a number, and returns the new result.
!#zh
@param num num
@param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
*/
div(num: number, out?: Vec4): Vec4;
/**
!#en Multiplies two vectors.
!#zh
@param vector vector
*/
scaleSelf(vector: Vec4): Vec4;
/**
!#en Multiplies two vectors, and returns the new result.
!#zh
@param vector vector
@param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
*/
scale(vector: Vec4, out?: Vec4): Vec4;
/**
!#en Negates the components. If you want to save result to another vector, use neg() instead.
!#zh 使 neg()
*/
negSelf(): Vec4;
/**
!#en Negates the components, and returns the new result.
!#zh
@param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
*/
neg(out?: Vec4): Vec4;
/**
!#zh
!#en Obtaining copy vectors designated
*/
static clone <Out extends IVec4Like> (a: Out): Vec4;
/**
!#zh
!#en Copy the target vector
*/
static copy <Out extends IVec4Like> (out: Out, a: Out): Out;
/**
!#zh
!#en Set to value
*/
static set <Out extends IVec4Like> (out: Out, x: number, y: number, z: number, w: number): Out;
/**
!#zh
!#en Element-wise vector addition
*/
static add <Out extends IVec4Like> (out: Out, a: Out, b: Out): Out;
/**
!#zh
!#en Element-wise vector subtraction
*/
static subtract <Out extends IVec4Like> (out: Out, a: Out, b: Out): Out;
/**
!#zh
!#en Element-wise vector multiplication
*/
static multiply <Out extends IVec4Like> (out: Out, a: Out, b: Out): Out;
/**
!#zh
!#en Element-wise vector division
*/
static divide <Out extends IVec4Like> (out: Out, a: Out, b: Out): Out;
/**
!#zh
!#en Rounding up by elements of the vector
*/
static ceil <Out extends IVec4Like> (out: Out, a: Out): Out;
/**
!#zh
!#en Element vector by rounding down
*/
static floor <Out extends IVec4Like> (out: Out, a: Out): Out;
/**
!#zh
!#en The minimum by-element vector
*/
static min <Out extends IVec4Like> (out: Out, a: Out, b: Out): Out;
/**
!#zh
!#en The maximum value of the element-wise vector
*/
static max <Out extends IVec4Like> (out: Out, a: Out, b: Out): Out;
/**
!#zh
!#en Element-wise vector of rounding to whole
*/
static round <Out extends IVec4Like> (out: Out, a: Out): Out;
/**
!#zh
!#en Vector scalar multiplication
*/
static multiplyScalar <Out extends IVec4Like> (out: Out, a: Out, b: number): Out;
/**
!#zh : A + B * scale
!#en Element-wise vector multiply add: A + B * scale
*/
static scaleAndAdd <Out extends IVec4Like> (out: Out, a: Out, b: Out, scale: number): Out;
/**
!#zh
!#en Seeking two vectors Euclidean distance
*/
static distance <Out extends IVec4Like> (a: Out, b: Out): number;
/**
!#zh
!#en Euclidean distance squared seeking two vectors
*/
static squaredDistance <Out extends IVec4Like> (a: Out, b: Out): number;
/**
!#zh
!#en Seeking vector length
*/
static len <Out extends IVec4Like> (a: Out): number;
/**
!#zh
!#en Seeking squared vector length
*/
static lengthSqr <Out extends IVec4Like> (a: Out): number;
/**
!#zh
!#en By taking the negative elements of the vector
*/
static negate <Out extends IVec4Like> (out: Out, a: Out): Out;
/**
!#zh 0 Infinity
!#en Element vector by taking the inverse, return near 0 Infinity
*/
static inverse <Out extends IVec4Like> (out: Out, a: Out): Out;
/**
!#zh 0 0
!#en Element vector by taking the inverse, return near 0 0
*/
static inverseSafe <Out extends IVec4Like> (out: Out, a: Out): Out;
/**
!#zh
!#en Normalized vector
*/
static normalize <Out extends IVec4Like> (out: Out, a: Out): Out;
/**
!#zh
!#en Vector dot product (scalar product)
*/
static dot <Out extends IVec4Like> (a: Out, b: Out): number;
/**
!#zh 线 A + t * (B - A)
!#en Vector element by element linear interpolation: A + t * (B - A)
*/
static lerp <Out extends IVec4Like> (out: Out, a: Out, b: Out, t: number): Out;
/**
!#zh
!#en Generates a uniformly distributed random vectors on the unit sphere
@param scale
*/
static random <Out extends IVec4Like> (out: Out, scale?: number): Out;
/**
!#zh
!#en Vector matrix multiplication
*/
static transformMat4 <Out extends IVec4Like, MatLike extends IMat4Like> (out: Out, a: Out, mat: MatLike): Out;
/**
!#zh 仿
!#en Affine transformation vector
*/
static transformAffine<Out extends IVec4Like, VecLike extends IVec4Like, MatLike extends IMat4Like>(out: Out, v: VecLike, mat: MatLike): Out;
/**
!#zh
!#en Vector quaternion multiplication
*/
static transformQuat <Out extends IVec4Like, QuatLike extends IQuatLike> (out: Out, a: Out, q: QuatLike): Out;
/**
!#zh
!#en Equivalent vectors Analyzing
*/
static strictEquals <Out extends IVec4Like> (a: Out, b: Out): boolean;
/**
!#zh
!#en Negative error vector floating point approximately equivalent Analyzing
*/
static equals <Out extends IVec4Like> (a: Out, b: Out, epsilon?: number): boolean;
/**
!#zh
!#en Vector transfer array
@param ofs
*/
static toArray <Out extends IWritableArrayLike<number>> (out: Out, v: IVec4Like, ofs?: number): Out;
/**
!#zh
!#en Array steering amount
@param ofs
*/
static fromArray <Out extends IVec4Like> (out: Out, arr: IWritableArrayLike<number>, ofs?: number): Out;
x: number;
y: number;
z: number;
w: number;
/**
!#en
Constructor
see {{#crossLink "cc/vec4:method"}}cc.v4{{/crossLink}}
!#zh
{{#crossLink "cc/vec4:method"}}cc.v4{{/crossLink}}
@param x x
@param y y
@param z z
@param w w
*/
constructor(x?: number, y?: number, z?: number, w?: number);
/**
!#en clone a Vec4 value
!#zh Vec4
*/
clone(): Vec4;
/**
!#en Set the current vector value with the given vector.
!#zh
@param newValue !#en new value to set. !#zh
*/
set(newValue: Vec4): Vec4;
/**
!#en Check whether the vector equals another one
!#zh
@param other other
@param epsilon epsilon
*/
equals(other: Vec4, epsilon?: number): boolean;
/**
!#en Check whether the vector equals another one
!#zh
@param x x
@param y y
@param z z
@param w w
@param epsilon
*/
equals4f(x: number, y: number, z: number, w: number, epsilon?: number): boolean;
/**
!#en Check whether strict equals other Vec4
!#zh `true` `false`
@param other
*/
strictEquals(other: Vec4): boolean;
/**
!#en Check whether strict equals other Vec4
!#zh `true` `false`
@param x x
@param y y
@param z z
@param w w
*/
strictEquals4f(x: number, y: number, z: number, w: number): boolean;
/**
!#en Calculate linear interpolation result between this vector and another one with given ratio
!#zh
@param to
@param ratio [0,1]
*/
lerp(to: Vec4, ratio: number): Vec4;
/**
!#en Transform to string with vector informations
!#zh
*/
toString(): string;
/**
!#en Clamp the vector between minInclusive and maxInclusive.
!#zh 使
@param minInclusive
@param maxInclusive
*/
clampf(minInclusive: Vec4, maxInclusive: Vec4): Vec4;
/**
!#en Adds this vector. If you want to save result to another vector, use add() instead.
!#zh 使 add()
@param vector vector
*/
addSelf(vector: Vec4): Vec4;
/**
!#en Adds two vectors, and returns the new result.
!#zh
@param vector vector
@param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
*/
add(vector: Vec4, out?: Vec4): Vec4;
/**
!#en Subtracts one vector from this, and returns the new result.
!#zh
@param vector vector
@param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
*/
subtract(vector: Vec4, out?: Vec4): Vec4;
/**
!#en Multiplies this by a number.
!#zh
@param num num
*/
multiplyScalar(num: number): Vec4;
/**
!#en Multiplies two vectors.
!#zh
@param vector vector
*/
multiply(vector: Vec4): Vec4;
/**
!#en Divides by a number.
!#zh
@param num num
*/
divide(num: number): Vec4;
/**
!#en Negates the components.
!#zh
*/
negate(): Vec4;
/**
!#en Dot product
!#zh
@param vector vector
*/
dot(vector?: Vec4): number;
/**
!#en Cross product
!#zh
@param vector vector
@param out out
*/
cross(vector: Vec4, out?: Vec4): Vec4;
/**
!#en Returns the length of this vector.
!#zh
@example
```js
var v = cc.v4(10, 10);
v.len(); // return 14.142135623730951;
```
*/
len(): number;
/**
!#en Returns the squared length of this vector.
!#zh
*/
lengthSqr(): number;
/**
!#en Make the length of this vector to 1.
!#zh 1
*/
normalizeSelf(): Vec4;
/**
!#en
Returns this vector with a magnitude of 1.<br/>
<br/>
Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function.
!#zh
<br/>
<br/>
使 normalizeSelf
@param out optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
*/
normalize(out?: Vec4): Vec4;
/**
Transforms the vec4 with a mat4. 4th vector component is implicitly '1'
@param m matrix to transform with
@param out the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
*/
transformMat4(m: Mat4, out?: Vec4): Vec4;
/**
Returns the maximum value in x, y, z, w.
*/
maxAxis(): number;
}
/** !#en .
!#zh */
export class SkeletonAnimation extends Animation {
}
/** !#en SkeletonAnimationClip Asset.
!#zh */
export class SkeletonAnimationClip extends AnimationClip {
}
/** !#en
Skinned Mesh Renderer
!#zh
*/
export class SkinnedMeshRenderer extends MeshRenderer {
/** !#en
Skeleton Asset
!#zh
*/
skeleton: sp.Skeleton;
/** !#en
Root Bone
!#zh
*/
rootBone: Node;
}
/** !#en The animation curve of 3d particle.
!#zh 3D 线 */
export class AnimationCurve {
/** !#en Array of key value.
!#zh */
keyFrames: Keyframe[];
/** !#en Pre-wrap mode.
!#zh */
preWrapMode: WrapMode;
/** !#en Post-wrap mode.
!#zh */
postWrapMode: WrapMode;
}
/** !#en The burst of 3d particle.
!#zh 3D */
export class Burst {
/** !#en Time between the start of the particle system and the trigger of this Brust
!#zh Brust */
time: number;
/** !#en Minimum number of emitted particles
!#zh */
minCount: number;
/** !#en Maximum number of emitted particles
!#zh */
maxCount: number;
/** !#en The number of times Burst was triggered.
!#zh Burst */
repeatCount: number;
/** !#en Interval of each trigger
!#zh */
repeatInterval: number;
/** !#en Number of particles emitted
!#zh */
count: CurveRange;
}
/** !#en The ParticleSystem3D Component.
!#zh 3D */
export class ParticleSystem3D extends RenderComponent {
/** !#en The run time of particle.
!#zh */
duration: number;
/** !#en The maximum number of particles that a particle system can generate.
!#zh */
capacity: number;
/** !#en Whether the particle system loops.
!#zh */
loop: boolean;
/** !#en Whether the particles start playing automatically after loaded.
!#zh */
playOnAwake: boolean;
/** !#en When selected, the particle system will start playing after one round has been played (only effective when loop is enabled).
!#zh */
prewarm: boolean;
/** !#en The coordinate system in which the particle system is located.<br>
World coordinates (does not change when the position of other objects changes)<br>
Local coordinates (moving as the position of the parent node changes)<br>
Custom coordinates (moving with the position of a custom node)
!#zh <br>
<br>
<br>
*/
simulationSpace: ParticleSystem3DAssembler.Space;
/** !#en Controlling the update speed of the entire particle system.
!#zh */
simulationSpeed: number;
/** !#en Delay particle emission time after particle system starts running.
!#zh */
startDelay: CurveRange;
/** !#en Particle life cycle
!#zh */
startLifetime: CurveRange;
/** !#en Particle initial color
!#zh */
startColor: GradientRange;
/** !#en Particle scale space
!#zh */
scaleSpace: ParticleSystem3DAssembler.Space;
/** !#en Initial particle size
!#zh */
startSize: CurveRange;
/** !#en Initial particle speed
!#zh */
startSpeed: CurveRange;
/** !#en Particle initial rotation angle
!#zh */
startRotation: CurveRange;
/** !#en Gravity coefficient of particles affected by gravity
!#zh */
gravityModifier: CurveRange;
/** !#en Particles emitted per second
!#zh */
rateOverTime: CurveRange;
/** !#en Number of particles emitted per unit distance moved
!#zh */
rateOverDistance: CurveRange;
/** !#en The number of Brusts that emit a specified number of particles at a specified time
!#zh Brust */
bursts: Burst[];
/** !#en Particle emitter module
!#zh */
shapeModule: ShapeModule;
/** !#en Color control module
!#zh */
colorOverLifetimeModule: ColorOverLifetimeModule;
/** !#en Particle size module
!#zh */
sizeOvertimeModule: SizeOvertimeModule;
/** !#en Particle speed module
!#zh */
velocityOvertimeModule: VelocityOvertimeModule;
/** !#en Particle acceleration module
!#zh */
forceOvertimeModule: ForceOvertimeModule;
/** !#en Particle limit speed module (only CPU particles are supported)
!#zh CPU */
limitVelocityOvertimeModule: LimitVelocityOvertimeModule;
/** !#en Particle rotation module
!#zh */
rotationOvertimeModule: RotationOvertimeModule;
/** !#en Texture Animation Module
!#zh */
textureAnimationModule: TextureAnimationModule;
/** !#en Particle Trajectory Module
!#zh */
trailModule: TrailModule;
/** !#en Particle generation mode
!#zh */
renderMode: ParticleSystem3DAssembler.RenderMode;
/** !#en When the particle generation mode is StrecthedBillboard, in the direction of movement of the particles is stretched by velocity magnitude
!#zh StrecthedBillboard , */
velocityScale: number;
/** !#en When the particle generation method is StrecthedBillboard, the particles are stretched according to the particle size in the direction of motion
!#zh StrecthedBillboard , */
lengthScale: number;
/** !#en Particle model
!#zh */
mesh: Mesh;
/** !#en Particle material
!#zh */
particleMaterial: Material;
/** !#en Particle trail material
!#zh */
trailMaterial: Material;
/**
!#en Playing particle effects
!#zh
*/
play(): void;
/**
!#en Pause particle effect
!#zh
*/
pause(): void;
/**
!#en Stop particle effect
!#zh
*/
stop(): void;
/**
!#en Remove all particle effect
!#zh
*/
clear(): void;
}
/** !#en
Helper class for ES5 Map.
!#zh
ES5 Map */
export class MapUtils {
}
/** !#en Effect Asset.
!#zh Effect */
export class EffectAsset extends Asset {
}
/** !#en Material Asset.
!#zh */
export class Material extends Asset {
/**
!#en Get built-in materials
!#zh
@param name name
*/
static getBuiltinMaterial(name: string): Material;
/**
!#en Creates a Material with builtin Effect.
!#zh 使 Effect
@param effectName effectName
@param techniqueIndex techniqueIndex
*/
static createWithBuiltin(effectName: string, techniqueIndex?: number): Material;
/**
!#en Creates a Material.
!#zh
@param effectAsset effectAsset
@param techniqueIndex techniqueIndex
*/
static create(effectAsset: EffectAsset, techniqueIndex?: number): Material;
/**
!#en Sets the Material property
!#zh
@param name name
@param val val
@param passIdx passIdx
@param directly directly
*/
setProperty(name: string, val: any, passIdx?: number, directly?: boolean): void;
/**
!#en Gets the Material property.
!#zh
@param name name
@param passIdx passIdx
*/
getProperty(name: string, passIdx: number): any;
/**
!#en Sets the Material define.
!#zh
@param name name
@param val val
@param passIdx passIdx
@param force force
*/
define(name: string, val: boolean|number, passIdx?: number, force?: boolean): void;
/**
!#en Gets the Material define.
!#zh
@param name name
@param passIdx passIdx
*/
getDefine(name: string, passIdx?: number): boolean;
/**
!#en Sets the Material cull mode.
!#zh
@param cullMode cullMode
@param passIdx passIdx
*/
setCullMode(cullMode: number, passIdx: number): void;
/**
!#en Sets the Material depth states.
!#zh
@param depthTest depthTest
@param depthWrite depthWrite
@param depthFunc depthFunc
@param passIdx passIdx
*/
setDepth(depthTest: boolean, depthWrite: boolean, depthFunc: number, passIdx: number): void;
/**
!#en Sets the Material blend states.
!#zh
@param enabled enabled
@param blendEq blendEq
@param blendSrc blendSrc
@param blendDst blendDst
@param blendAlphaEq blendAlphaEq
@param blendSrcAlpha blendSrcAlpha
@param blendDstAlpha blendDstAlpha
@param blendColor blendColor
@param passIdx passIdx
*/
setBlend(enabled: boolean, blendEq: number, blendSrc: number, blendDst: number, blendAlphaEq: number, blendSrcAlpha: number, blendDstAlpha: number, blendColor: number, passIdx: number): void;
/**
!#en Sets whether enable the stencil test.
!#zh
@param stencilTest stencilTest
@param passIdx passIdx
*/
setStencilEnabled(stencilTest: number, passIdx: number): void;
/**
!#en Sets the Material stencil render states.
!#zh
@param stencilTest stencilTest
@param stencilFunc stencilFunc
@param stencilRef stencilRef
@param stencilMask stencilMask
@param stencilFailOp stencilFailOp
@param stencilZFailOp stencilZFailOp
@param stencilZPassOp stencilZPassOp
@param stencilWriteMask stencilWriteMask
@param passIdx passIdx
*/
setStencil(stencilTest: number, stencilFunc: number, stencilRef: number, stencilMask: number, stencilFailOp: number, stencilZFailOp: number, stencilZPassOp: number, stencilWriteMask: number, passIdx: number): void;
}
/** !#en
Material Variant is an extension of the Material Asset.
Changes to Material Variant do not affect other Material Variant or Material Asset,
and changes to Material Asset are synchronized to the Material Variant.
However, when a Material Variant had already modifies a state, the Material Asset state is not synchronized to the Material Variant.
!#zh
*/
export class MaterialVariant extends Material {
/**
@param materialName materialName
@param owner owner
*/
static createWithBuiltin (materialName: string, owner: cc.RenderComponent): MaterialVariant | null;
/**
@param material material
@param owner owner
*/
static create (material: Material, owner: cc.RenderComponent): MaterialVariant | null;
}
/** !#en cc.EditBox is a component for inputing text, you can use it to gather small amounts of text from users.
!#zh EditBox */
export class EditBox extends Component {
/** !#en Input string of EditBox.
!#zh */
string: string;
/** !#en The Label component attached to the node for EditBox's input text label
!#zh Label */
textLabel: Label;
/** !#en The Label component attached to the node for EditBox's placeholder text label
!#zh Label */
placeholderLabel: Label;
/** !#en The Sprite component attached to the node for EditBox's background
!#zh Sprite */
background: Sprite;
/** !#en The background image of EditBox. This property will be removed in the future, use editBox.background instead please.
!#zh editBox.background */
backgroundImage: SpriteFrame;
/** !#en
The return key type of EditBox.
Note: it is meaningless for web platforms and desktop platforms.
!#zh
web desktop */
returnType: EditBox.KeyboardReturnType;
/** !#en Set the input flags that are to be applied to the EditBox.
!#zh */
inputFlag: EditBox.InputFlag;
/** !#en
Set the input mode of the edit box.
If you pass ANY, it will create a multiline EditBox.
!#zh
: ANY */
inputMode: EditBox.InputMode;
/** !#en Font size of the input text. This property will be removed in the future, use editBox.textLabel.fontSize instead please.
!#zh 使 editBox.textLabel.fontSize */
fontSize: number;
/** !#en Change the lineHeight of displayed text. This property will be removed in the future, use editBox.textLabel.lineHeight instead.
!#zh 使 editBox.textLabel.lineHeight */
lineHeight: number;
/** !#en Font color of the input text. This property will be removed in the future, use editBox.textLabel.node.color instead.
!#zh 使 editBox.textLabel.node.color */
fontColor: Color;
/** !#en The display text of placeholder.
!#zh */
placeholder: string;
/** !#en The font size of placeholder. This property will be removed in the future, use editBox.placeholderLabel.fontSize instead.
!#zh 使 editBox.placeholderLabel.fontSize */
placeholderFontSize: number;
/** !#en The font color of placeholder. This property will be removed in the future, use editBox.placeholderLabel.node.color instead.
!#zh 使 editBox.placeholderLabel.node.color */
placeholderFontColor: Color;
/** !#en The maximize input length of EditBox.
- If pass a value less than 0, it won't limit the input number of characters.
- If pass 0, it doesn't allow input any characters.
!#zh
- 0
- 0 */
maxLength: number;
/** !#en The input is always visible and be on top of the game view (only useful on Web), this property will be removed on v2.1
!zh Web v2.1
Note: only available on Web at the moment. */
stayOnTop: boolean;
/** !#en Set the tabIndex of the DOM input element (only useful on Web).
!#zh DOM tabIndex Web */
tabIndex: number;
/** !#en The event handler to be called when EditBox began to edit text.
!#zh */
editingDidBegan: Component.EventHandler[];
/** !#en The event handler to be called when EditBox text changes.
!#zh */
textChanged: Component.EventHandler[];
/** !#en The event handler to be called when EditBox edit ends.
!#zh */
editingDidEnded: Component.EventHandler[];
/** !#en The event handler to be called when return key is pressed. Windows is not supported.
!#zh windows */
editingReturn: Component.EventHandler[];
/**
!#en Let the EditBox get focus, this method will be removed on v2.1
!#zh EditBox , v2.1
*/
setFocus(): void;
/**
!#en Let the EditBox get focus
!#zh EditBox
*/
focus(): void;
/**
!#en Let the EditBox lose focus
!#zh EditBox
*/
blur(): void;
/**
!#en Determine whether EditBox is getting focus or not.
!#zh EditBox
*/
isFocused(): void;
/**
!#en if you don't need the EditBox and it isn't in any running Scene, you should
call the destroy method on this component or the associated node explicitly.
Otherwise, the created DOM element won't be removed from web page.
!#zh
使 EditBox destroy
DOM Web
@example
```js
editbox.node.parent = null; // or editbox.node.removeFromParent(false);
// when you don't need editbox anymore
editbox.node.destroy();
```
*/
destroy(): boolean;
}
/** undefined */
export class PhysicsBoxCollider extends PhysicsCollider implements Collider.Box {
/** !#en Position offset
!#zh */
offset: Vec2;
/** !#en Box size
!#zh */
size: Size;
}
/** undefined */
export class PhysicsChainCollider extends PolygonCollider {
/** !#en Whether the chain is loop
!#zh */
loop: boolean;
/** !#en Chain points
!#zh */
points: Vec2[];
}
/** undefined */
export class PhysicsCircleCollider extends PhysicsCollider implements Collider.Circle {
/** !#en Position offset
!#zh */
offset: Vec2;
/** !#en Circle radius
!#zh */
radius: number;
}
/** undefined */
export class PhysicsCollider extends Collider {
/** !#en
The density.
!#zh
*/
density: number;
/** !#en
A sensor collider collects contact information but never generates a collision response
!#zh
*/
sensor: boolean;
/** !#en
The friction coefficient, usually in the range [0,1].
!#zh
[0, 1] */
friction: number;
/** !#en
The restitution (elasticity) usually in the range [0,1].
!#zh
[0, 1] */
restitution: number;
/** !#en
Physics collider will find the rigidbody component on the node and set to this property.
!#zh
*/
body: RigidBody;
/**
!#en
Apply current changes to collider, this will regenerate inner box2d fixtures.
!#zh
collider box2d
*/
apply(): void;
/**
!#en
Get the world aabb of the collider
!#zh
*/
getAABB(): void;
}
/** undefined */
export class PhysicsPolygonCollider extends PhysicsCollider implements Collider.Polygon {
/** !#en Position offset
!#zh */
offset: Vec2;
/** !#en Polygon points
!#zh */
points: Vec2[];
}
/** !#en
A distance joint constrains two points on two bodies
to remain at a fixed distance from each other. You can view
this as a massless, rigid rod.
!#zh
*/
export class DistanceJoint extends Joint {
/** !#en
The distance separating the two ends of the joint.
!#zh
*/
distance: number;
/** !#en
The spring frequency.
!#zh
*/
frequency: number;
/** !#en
The damping ratio.
!#zh
*/
dampingRatio: number;
}
/** !#en
Base class for joints to connect rigidbody.
!#zh
*/
export class Joint extends Component {
/** !#en
The anchor of the rigidbody.
!#zh
*/
anchor: Vec2;
/** !#en
The anchor of the connected rigidbody.
!#zh
*/
connectedAnchor: Vec2;
/** !#en
The rigidbody to which the other end of the joint is attached.
!#zh
*/
connectedBody: RigidBody;
/** !#en
Should the two rigid bodies connected with this joint collide with each other?
!#zh
*/
collideConnected: boolean;
/**
!#en
Apply current changes to joint, this will regenerate inner box2d joint.
!#zh
box2d
*/
apply(): void;
/**
!#en
Get the anchor point on rigidbody in world coordinates.
!#zh
*/
getWorldAnchor(): Vec2;
/**
!#en
Get the anchor point on connected rigidbody in world coordinates.
!#zh
*/
getWorldConnectedAnchor(): Vec2;
/**
!#en
Gets the reaction force of the joint.
!#zh
@param timeStep The time to calculate the reaction force for.
*/
getReactionForce(timeStep: number): Vec2;
/**
!#en
Gets the reaction torque of the joint.
!#zh
@param timeStep The time to calculate the reaction torque for.
*/
getReactionTorque(timeStep: number): number;
}
/** !#en
A motor joint is used to control the relative motion
between two bodies. A typical usage is to control the movement
of a dynamic body with respect to the ground.
!#zh
*/
export class MotorJoint extends Joint {
/** !#en
The anchor of the rigidbody.
!#zh
*/
anchor: Vec2;
/** !#en
The anchor of the connected rigidbody.
!#zh
*/
connectedAnchor: Vec2;
/** !#en
The linear offset from connected rigidbody to rigidbody.
!#zh
*/
linearOffset: Vec2;
/** !#en
The angular offset from connected rigidbody to rigidbody.
!#zh
*/
angularOffset: number;
/** !#en
The maximum force can be applied to rigidbody.
!#zh
*/
maxForce: number;
/** !#en
The maximum torque can be applied to rigidbody.
!#zh
*/
maxTorque: number;
/** !#en
The position correction factor in the range [0,1].
!#zh
[0, 1] */
correctionFactor: number;
}
/** !#en
A mouse joint is used to make a point on a body track a
specified world point. This a soft constraint with a maximum
force. This allows the constraint to stretch and without
applying huge forces.
Mouse Joint will auto register the touch event with the mouse region node,
and move the choosed rigidbody in touch move event.
Note : generally mouse joint only used in test bed.
!#zh
使
使 mouse region
使 */
export class MouseJoint extends Joint {
/** !#en
The anchor of the rigidbody.
!#zh
*/
anchor: Vec2;
/** !#en
The anchor of the connected rigidbody.
!#zh
*/
connectedAnchor: Vec2;
/** !#en
The node used to register touch evnet.
If this is null, it will be the joint's node.
!#zh
使 */
mouseRegion: Node;
/** !#en
The target point.
The mouse joint will move choosed rigidbody to target point.
!#zh
*/
target: Vec2;
/** !#en
The spring frequency.
!#zh
*/
frequency: number;
/** !#en
The damping ratio.
!#zh
*/
0: number;
/** !#en
The maximum force
!#zh
*/
maxForce: number;
}
/** !#en
A prismatic joint. This joint provides one degree of freedom: translation
along an axis fixed in rigidbody. Relative rotation is prevented. You can
use a joint limit to restrict the range of motion and a joint motor to
drive the motion or to model joint friction.
!#zh
使 */
export class PrismaticJoint extends Joint {
/** !#en
The local joint axis relative to rigidbody.
!#zh
*/
localAxisA: Vec2;
/** !#en
The reference angle.
!#zh
*/
referenceAngle: number;
/** !#en
Enable joint distance limit?
!#zh
*/
enableLimit: boolean;
/** !#en
Enable joint motor?
!#zh
*/
enableMotor: boolean;
/** !#en
The lower joint limit.
!#zh
*/
lowerLimit: number;
/** !#en
The upper joint limit.
!#zh
*/
upperLimit: number;
/** !#en
The maxium force can be applied to rigidbody to rearch the target motor speed.
!#zh
*/
maxMotorForce: number;
/** !#en
The expected motor speed.
!#zh
*/
motorSpeed: number;
}
/** !#en
A revolute joint constrains two bodies to share a common point while they
are free to rotate about the point. The relative rotation about the shared
point is the joint angle. You can limit the relative rotation with
a joint limit that specifies a lower and upper angle. You can use a motor
to drive the relative rotation about the shared point. A maximum motor torque
is provided so that infinite forces are not generated.
!#zh
*/
export class RevoluteJoint extends Joint {
/** !#en
The reference angle.
An angle between bodies considered to be zero for the joint angle.
!#zh
*/
referenceAngle: number;
/** !#en
The lower angle.
!#zh
*/
lowerAngle: number;
/** !#en
The upper angle.
!#zh
*/
upperAngle: number;
/** !#en
The maxium torque can be applied to rigidbody to rearch the target motor speed.
!#zh
*/
maxMotorTorque: number;
/** !#en
The expected motor speed.
!#zh
*/
motorSpeed: number;
/** !#en
Enable joint limit?
!#zh
*/
enableLimit: boolean;
/** !#en
Enable joint motor?
!#zh
*/
enableMotor: boolean;
/**
!#en
Get the joint angle.
!#zh
*/
getJointAngle(): number;
}
/** !#en
A rope joint enforces a maximum distance between two points
on two bodies. It has no other effect.
Warning: if you attempt to change the maximum length during
the simulation you will get some non-physical behavior.
!#zh
*/
export class RopeJoint extends Joint {
/** !#en
The max length.
!#zh
*/
maxLength: number;
}
/** !#en
A weld joint essentially glues two bodies together. A weld joint may
distort somewhat because the island constraint solver is approximate.
!#zh
使西 */
export class WeldJoint extends Joint {
/** !#en
The reference angle.
!#zh
*/
referenceAngle: number;
/** !#en
The frequency.
!#zh
*/
frequency: number;
/** !#en
The damping ratio.
!#zh
*/
0: number;
}
/** !#en
A wheel joint. This joint provides two degrees of freedom: translation
along an axis fixed in bodyA and rotation in the plane. You can use a joint motor to drive
the rotation or to model rotational friction.
This joint is designed for vehicle suspensions.
!#zh
沿
使
*/
export class WheelJoint extends Joint {
/** !#en
The local joint axis relative to rigidbody.
!#zh
*/
localAxisA: Vec2;
/** !#en
The maxium torque can be applied to rigidbody to rearch the target motor speed.
!#zh
*/
maxMotorTorque: number;
/** !#en
The expected motor speed.
!#zh
*/
motorSpeed: number;
/** !#en
Enable joint motor?
!#zh
*/
enableMotor: boolean;
/** !#en
The spring frequency.
!#zh
*/
frequency: number;
/** !#en
The damping ratio.
!#zh
*/
dampingRatio: number;
}
/** !#en The rigid body type
!#zh */
export enum ERigidBodyType {
DYNAMIC = 0,
STATIC = 0,
KINEMATIC = 0,
}
/** !#en
Trigger event
!#zh
*/
export class ITriggerEvent {
/** !#en
The type of event fired
!#zh
*/
type: string;
/** !#en
Triggers its own collider in the event
!#zh
*/
selfCollider: Collider3D;
/** !#en
Triggers another collider in the event
!#zh
*/
otherCollider: Collider3D;
}
/** !#en
Collision information for collision events.
!#zh
*/
export class IContactEquation {
/** !#en
The collision point A in the collision information.
!#zh
A */
contactA: Vec3;
/** !#en
Collision point B in collision information.
!#zh
B */
contactB: Vec3;
/** !#en
Normals in collision information.
!#zh
线 */
normal: Vec3;
}
/** !#en
Collision events.
!#zh
*/
export class ICollisionEvent {
/** !#en
Event type of collision.
!#zh
*/
type: string;
/** !#en
Collider of its own in collision.
!#zh
*/
selfCollider: Collider3D;
/** !#en
Another collider in the collision.
!#zh
*/
otherCollider: Collider3D;
/** !#en
Information about all the points of impact in the collision.
!#zh
*/
contacts: IContactEquation[];
}
/** !#en
Physical systems manager.
!#zh
*/
export class Physics3DManager {
/** !#en
Whether to enable the physics system, default is false.
!#zh
*/
enabled: boolean;
/** !#en
Whether to allow the physics system to automatically hibernate, default is true.
!#zh
true */
allowSleep: boolean;
/** !#en
The maximum number of sub-steps a full step is permitted to be broken into, default is 2.
!#zh
2 */
maxSubStep: number;
/** !#en
Time spent in each simulation of physics, default is 1/60s.
!#zh
1/60 */
deltaTime: number;
/** !#en
Whether to use a fixed time step.
!#zh
使 */
useFixedTime: boolean;
/** !#en
Gravity value of the physics simulation, default is (0, -10, 0).
!#zh
(0, -10, 0) */
gravity: Vec3;
/** !#en
Gets the global default physical material. Note that builtin is null.
!#zh
builtin null */
defaultMaterial: PhysicsMaterial|void;
/**
!#en
A physical system simulation is performed once and will now be performed automatically once per frame.
!#zh
@param deltaTime The time difference from the last execution is currently elapsed per frame
*/
update(deltaTime: number): void;
/**
!#en Detect all collision boxes and return all detected results, or null if none is detected. Note that the return value is taken from the object pool, so do not save the result reference or modify the result.
!#zh
@param worldRay A ray in world space
@param groupIndexOrName Collision group index or group name
@param maxDistance Maximum detection distance
@param queryTrigger Detect trigger or not
*/
raycast(worldRay: geomUtils.Ray, groupIndexOrName: number|string, maxDistance: number, queryTrigger: boolean): PhysicsRayResult[];
/**
!#en Detect all collision boxes and return the detection result with the shortest ray distance. If not, return null value. Note that the return value is taken from the object pool, so do not save the result reference or modify the result.
!#zh 线
@param worldRay A ray in world space
@param groupIndexOrName Collision group index or group name
@param maxDistance Maximum detection distance
@param queryTrigger Detect trigger or not
*/
raycastClosest(worldRay: geomUtils.Ray, groupIndexOrName: number|string, maxDistance: number, queryTrigger: boolean): PhysicsRayResult;
}
/** !#en
Used to store physical ray detection results
!#zh
线 */
export class PhysicsRayResult {
/** !#en
Hit the point
!#zh
*/
hitPoint: Vec3;
/** !#en
Distance
!#zh
*/
distance: number;
/** !#en
Hit the collision box
!#zh
*/
collider: Collider3D;
/**
!#en
Set up ray. This method is used internally by the engine. Do not call it from an external script
!#zh
线使
@param hitPoint hitPoint
@param distance distance
@param collider collider
*/
_assign(hitPoint: Vec3, distance: number, collider: Collider3D): void;
/**
!#en
Clone
!#zh
*/
clone(): void;
}
/** !#en The shape module of 3d particle.
!#zh 3D */
export class ShapeModule {
/** !#en The enable of shapeModule.
!#zh */
enable: boolean;
/** !#en Particle emitter type.
!#zh */
shapeType: shapeModule.ShapeType;
/** !#en The emission site of the particle.
!#zh */
emitFrom: shapeModule.EmitLocation;
/** !#en Particle emitter radius.
!#zh */
radius: number;
/** !#en Particle emitter emission position (not valid for Box type emitters)<bg>
- 0 means emitted from the surface;
- 1 means launch from the center;
- 0 ~ 1 indicates emission from the center to the surface.
!#zh Box <bg>
- 0
- 1
- 0 ~ 1 */
radiusThickness: number;
/** !#en The angle between the axis of the cone and the generatrix<bg>
Determines the opening and closing of the cone launcher
!#zh 线<bg>
*/
angle: number;
/** !#en Particle emitters emit in a fan-shaped range.
!#zh */
arc: number;
/** !#en How particles are emitted in the sector range.
!#zh */
arcMode: shapeModule.ArcMode;
/** !#en Controls the discrete intervals around the arcs where particles might be generated.
!#zh */
arcSpread: number;
/** !#en The speed at which particles are emitted around the circumference.
!#zh 沿 */
arcSpeed: CurveRange;
/** !#en Axis length from top of cone to bottom of cone <bg>.
Determines the height of the cone emitter.
!#zh <bg>
*/
length: number;
/** !#en Particle emitter emission location (for box-type particle emitters).
!#zh Box */
boxThickness: Vec3;
/** !#en Particle Emitter Position
!#zh */
position: Vec3;
/** !#en Particle emitter rotation angle.
!#zh */
rotation: Vec3;
/** !#en Particle emitter scaling
!#zh */
scale: Vec3;
/** !#en The direction of particle movement is determined based on the initial direction of the particles.
!#zh */
alignToDirection: boolean;
/** !#en Set particle generation direction randomly.
!#zh */
randomDirectionAmount: number;
/** !#en Interpolation between the current emission direction and the direction from the current position to the center of the node.
!#zh 线 */
sphericalDirectionAmount: number;
}
/** !#en The color over time module of 3d particle.
!#zh 3D */
export class ColorOvertimeModule {
/** !#en The enable of ColorOvertimeModule.
!#zh */
enable: boolean;
}
/** !#en The curve range of target value.
!#zh 线 */
export class CurveRange {
/** !#en Curve type.
!#zh 线 */
mode: debug.DebugMode;
/** !#en The curve to use when mode is Curve.
!#zh mode Curve 使线 */
curve: AnimationCurve;
/** !#en The lower limit of the curve to use when mode is TwoCurves
!#zh mode TwoCurves 使线 */
curveMin: AnimationCurve;
/** !#en The upper limit of the curve to use when mode is TwoCurves
!#zh mode TwoCurves 使线 */
curveMax: AnimationCurve;
/** !#en When mode is Constant, the value of the curve.
!#zh mode Constant 线 */
constant: number;
/** !#en The lower limit of the curve to use when mode is TwoConstants
!#zh mode TwoConstants 线 */
constantMin: number;
/** !#en The upper limit of the curve to use when mode is TwoConstants
!#zh mode TwoConstants 线 */
constantMax: number;
/** !#en Coefficients applied to curve interpolation.
!#zh 线 */
multiplier: number;
}
/** !#en The force over time module of 3d particle.
!#zh 3D */
export class ForceOvertimeModule {
/** !#en The enable of ColorOvertimeModule.
!#zh */
enable: boolean;
/** !#en Coordinate system used in acceleration calculation.
!#zh */
space: ParticleSystem3DAssembler.Space;
/** !#en X-axis acceleration component.
!#zh X */
x: CurveRange;
/** !#en Y-axis acceleration component.
!#zh Y */
y: CurveRange;
/** !#en Z-axis acceleration component.
!#zh Z */
z: CurveRange;
}
/** !#en The gradient range of color.
!#zh */
export class GradientRange {
/** !#en Gradient type.
!#zh */
mode: debug.DebugMode;
/** !#en The color when mode is Color.
!#zh mode Color */
color: Color;
/** !#en Lower color limit when mode is TwoColors.
!#zh mode TwoColors */
colorMin: Color;
/** !#en Upper color limit when mode is TwoColors.
!#zh mode TwoColors */
colorMax: Color;
/** !#en Color gradient when mode is Gradient
!#zh mode Gradient */
gradient: Gradient;
/** !#en Lower color gradient limit when mode is TwoGradients.
!#zh mode TwoGradients */
gradientMin: Gradient;
/** !#en Upper color gradient limit when mode is TwoGradients.
!#zh mode TwoGradients */
gradientMax: Gradient;
}
/** !#en The color key of gradient.
!#zh color */
export class ColorKey {
/** !#en Color value.
!#zh */
color: Color;
/** !#en Time value.
!#zh */
time: number;
}
/** !#en The alpha key of gradient.
!#zh alpha */
export class AlphaKey {
/** !#en Alpha value.
!#zh */
alpha: number;
/** !#en Time.
!#zh */
time: number;
}
/** !#en The gradient data of color.
!#zh */
export class Gradient {
/** !#en Array of color key.
!#zh */
colorKeys: ColorKey[];
/** !#en Array of alpha key.
!#zh */
alphaKeys: AlphaKey[];
/** !#en Blend mode.
!#zh */
mode: debug.DebugMode;
}
/** !#en The limit velocity module of 3d particle.
!#zh 3D */
export class LimitVelocityOvertimeModule {
/** !#en The enable of LimitVelocityOvertimeModule.
!#zh */
enable: boolean;
/** !#en The coordinate system used when calculating the lower speed limit.
!#zh */
space: ParticleSystem3DAssembler.Space;
/** !#en Whether to limit the three axes separately.
!#zh */
separateAxes: boolean;
/** !#en Lower speed limit
!#zh */
limit: CurveRange;
/** !#en Lower speed limit in X direction.
!#zh X */
limitX: CurveRange;
/** !#en Lower speed limit in Y direction.
!#zh Y */
limitY: CurveRange;
/** !#en Lower speed limit in Z direction.
!#zh Z */
limitZ: CurveRange;
/** !#en Interpolation of current speed and lower speed limit.
!#zh */
dampen: number;
}
/** !#en The optimized curve.
!#zh 线 */
export class OptimizedCurve {
}
/** !#en The rotation module of 3d particle.
!#zh 3D */
export class RotationOvertimeModule {
/** !#en The enable of RotationOvertimeModule.
!#zh */
enable: boolean;
/** !#en Whether to set the rotation of three axes separately (not currently supported)
!#zh */
separateAxes: boolean;
/** !#en Set rotation around X axis.
!#zh X */
x: CurveRange;
/** !#en Set rotation around Y axis.
!#zh Y */
y: CurveRange;
/** !#en Set rotation around Z axis.
!#zh Z */
z: CurveRange;
}
/** !#en The size module of 3d particle.
!#zh 3D */
export class SizeOvertimeModule {
/** !#en The enable of SizeOvertimeModule.
!#zh */
enable: boolean;
/** !#en Decide whether to control particle size independently on each axis.
!#zh */
separateAxes: boolean;
/** !#en Define a curve to determine the size change of particles during their life cycle.
!#zh 线 */
size: CurveRange;
/** !#en Defines a curve to determine the size change of particles in the X-axis direction during their life cycle.
!#zh 线 X */
x: CurveRange;
/** !#en Defines a curve to determine the size change of particles in the Y-axis direction during their life cycle.
!#zh 线 Y */
y: CurveRange;
/** !#en Defines a curve to determine the size change of particles in the Z-axis direction during their life cycle.
!#zh 线 Z */
z: CurveRange;
}
/** !#en The texture animation module of 3d particle.
!#zh 3D */
export class TextureAnimationModule {
/** !#en The enable of TextureAnimationModule.
!#zh */
enable: boolean;
/** !#en Set the type of particle map animation (only supports Grid mode for the time being)
!#zh Grid */
mode: debug.DebugMode;
/** !#en Animation frames in X direction.
!#zh X */
numTilesX: number;
/** !#en Animation frames in Y direction.
!#zh Y */
numTilesY: number;
/** !#en The way of the animation plays.
!#zh */
animation: Animation;
/** !#en Randomly select a line from the animated map to generate the animation. <br>
This option only takes effect when the animation playback mode is SingleRow.
!#zh <br>
SingleRow */
randomRow: boolean;
/** !#en Select specific lines from the animation map to generate the animation. <br>
This option is only available when the animation playback mode is SingleRow and randomRow is disabled.
!#zh <br>
SingleRow randomRow */
rowIndex: number;
/** !#en Frame and time curve of animation playback in one cycle.
!#zh 线 */
frameOverTime: CurveRange;
/** !#en Play from which frames, the time is the life cycle of the entire particle system.
!#zh */
startFrame: CurveRange;
/** !#en Number of playback loops in a life cycle.
!#zh */
cycleCount: number;
}
/** !#en The velocity module of 3d particle.
!#zh 3D */
export class VelocityOvertimeModule {
/** !#en The enable of VelocityOvertimeModule.
!#zh */
enable: boolean;
/** !#en Coordinate system used in speed calculation.
!#zh */
space: ParticleSystem3DAssembler.Space;
/** !#en Velocity component in X axis direction
!#zh X */
x: CurveRange;
/** !#en Velocity component in Y axis direction
!#zh Y */
y: CurveRange;
/** !#en Velocity component in Z axis direction
!#zh Z */
z: CurveRange;
/** !#en Speed correction factor (only supports CPU particles).
!#zh CPU */
speedModifier: CurveRange;
}
/** Rigid body interface */
export class IRigidBody {
rigidBody: RigidBody3D;
mass: number;
linearDamping: number;
angularDamping: number;
isKinematic: boolean;
useGravity: boolean;
fixedRotation: boolean;
linearFactor: IVec3Like;
angularFactor: IVec3Like;
allowSleep: boolean;
isAwake: boolean;
isSleepy: boolean;
isSleeping: boolean;
wakeUp(): void;
sleep(): void;
/**
@param out out
*/
getLinearVelocity(out: IVec3Like): void;
/**
@param out out
*/
setLinearVelocity(out: IVec3Like): void;
/**
@param out out
*/
getAngularVelocity(out: IVec3Like): void;
/**
@param out out
*/
setAngularVelocity(out: IVec3Like): void;
/**
@param force force
@param relativePoint relativePoint
*/
applyForce(force: IVec3Like, relativePoint: IVec3Like): void;
/**
@param force force
@param relativePoint relativePoint
*/
applyLocalForce(force: IVec3Like, relativePoint: IVec3Like): void;
/**
@param force force
@param relativePoint relativePoint
*/
applyImpulse(force: IVec3Like, relativePoint: IVec3Like): void;
/**
@param force force
@param relativePoint relativePoint
*/
applyLocalImpulse(force: IVec3Like, relativePoint: IVec3Like): void;
/**
@param torque torque
*/
applyTorque(torque: IVec3Like): void;
/**
@param torque torque
*/
applyLocalTorque(torque: IVec3Like): void;
}
/** Class has x y z properties */
export class IVec3Like {
x: number;
y: number;
z: number;
}
/** Class has x y z w properties */
export class IQuatLike {
x: number;
y: number;
z: number;
w: number;
}
/** !#en Base shape interface. */
export class IBaseShape {
collider: Collider3D;
attachedRigidBody: RigidBody3D|void;
material: any;
isTrigger: boolean;
center: IVec3Like;
}
/** !#en box shape interface */
export class IBoxShape {
size: IVec3Like;
}
/** !#en Sphere shape interface */
export class ISphereShape {
radius: number;
}
/** Ray cast options */
export class IRaycastOptions {
groupIndex: number;
queryTrigger: boolean;
maxDistance: number;
}
/** Collision detect */
export class ICollisionDetect {
/**
Ray cast, and return information of the closest hit.
@param worldRay worldRay
@param options options
@param out out
*/
raycastClosest(worldRay: geomUtils.Ray, options: IRaycastOptions, out: PhysicsRayResult): boolean;
/**
Ray cast against all bodies. The provided callback will be executed for each hit with a RaycastResult as single argument.
@param worldRay worldRay
@param options options
@param pool pool
@param resultes resultes
*/
raycast(worldRay: geomUtils.Ray, options: IRaycastOptions, pool: RecyclePool, resultes: PhysicsRayResult[]): boolean;
}
/** Physics world interface */
export class IPhysicsWorld {
}
/** !#en The trail module of 3d particle.
!#zh 3D */
export class TrailModule {
/** !#en The enable of trailModule.
!#zh */
enable: boolean;
/** !#en Sets how particles generate trajectories.
!#zh */
mode: trailModule.TrailMode;
/** !#en Life cycle of trajectory.
!#zh */
lifeTime: CurveRange;
/** !#en Minimum spacing between each track particle
!#zh */
minParticleDistance: number;
/** !#en The coordinate system of trajectories.
!#zh */
space: ParticleSystem3DAssembler.Space;
/** !#en Whether the particle itself exists.
!#zh */
existWithParticles: boolean;
/** !#en Set the texture fill method
!#zh */
textureMode: trailModule.TextureMode;
/** !#en Whether to use particle width
!#zh 使 */
widthFromParticle: boolean;
/** !#en Curves that control track length
!#zh 线 */
widthRatio: CurveRange;
/** !#en Whether to use particle color
!#zh 使 */
colorFromParticle: boolean;
/** !#en The color of trajectories.
!#zh */
colorOverTrail: GradientRange;
/** !#en Trajectories color over time.
!#zh */
colorOvertime: GradientRange;
}
/** !#en Manage Dynamic Atlas Manager. Dynamic Atlas Manager is used for merging textures at runtime, see [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) for details.
!#zh [](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 */
export class DynamicAtlasManager {
/** !#en Enable or disable the dynamic atlas, see [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) for details.
!#zh [](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。 */
enabled: boolean;
/** !#en The maximum number of atlas that can be created.
!#zh */
maxAtlasCount: number;
/** !#en Get the current created atlas count.
!#zh */
atlasCount: number;
/** !#en Is enable textureBleeding.
!#zh textureBleeding */
textureBleeding: boolean;
/** !#en The size of the atlas that was created
!#zh */
textureSize: number;
/** !#en The maximum size of the picture that can be added to the atlas.
!#zh */
maxFrameSize: number;
/** !#en The minimum size of the picture that can be added to the atlas.
!#zh */
minFrameSize: number;
/**
!#en Append a sprite frame into the dynamic atlas.
!#zh
@param spriteFrame spriteFrame
*/
insertSpriteFrame(spriteFrame: SpriteFrame): void;
/**
!#en Resets all dynamic atlas, and the existing ones will be destroyed.
!#zh
*/
reset(): void;
/**
!#en Displays all the dynamic atlas in the current scene, which you can use to view the current atlas state.
!#zh
@param show show
*/
showDebug(show: boolean): Node;
}
/** !#en
Physics material.
!#zh
*/
export class PhysicsMaterial extends Asset {
/** !#en
Friction for this material.
!#zh
*/
friction: number;
/** !#en
Restitution for this material.
!#zh
*/
restitution: number;
}
/** !#en
Each frame applies a constant force to a rigid body, depending on the RigidBody3D
!#zh
RigidBody3D */
export class ConstantForce extends Component {
/** !#en
Set the force used in the world coordinate system, use `this.force = otherVec3`.
!#zh
使 `this.force = otherVec3` */
force: Vec3;
/** !#en
Set the force used in the local coordinate system, using `this.localforce = otherVec3`.
!#zh
使 `this.localForce = otherVec3` */
localForce: Vec3;
/** !#en
Torque applied to the world orientation
!#zh
*/
torque: Vec3;
/** !#en
Torque applied to local orientation, using `this.localtorque = otherVec3`.
!#zh
`this.localTorque = otherVec3` */
localTorque: Vec3;
}
/** !#en
RigidBody is the basic object that make up the physical world, and it can make a node physically affected and react.
!#zh
使 Builtin */
export class RigidBody3D extends Component {
/** !#en
Whether sleep is allowed.
!#zh
*/
allowSleep: boolean;
/** !#en
The mass of the rigidbody.
!#zh
*/
mass: number;
/** !#en
Used to reduce the linear rate of rigidbody. The larger the value, the slower the rigidbody moves.
!#zh
线线 */
linearDamping: number;
/** !#en
Used to reduce the rotation rate of rigidbody. The larger the value, the slower the rigidbody rotates.
!#zh
*/
angularDamping: number;
/** !#en
If enabled, the developer controls the displacement and rotation of the rigidbody, not the physics engine.
!#zh
*/
isKinematic: boolean;
/** !#en
If enabled, the rigidbody is affected by gravity.
!#zh
*/
useGravity: boolean;
/** !#en
If enabled, the rigidbody will be fixed without rotation during a collision.
!#zh
*/
fixedRotation: boolean;
/** !#en
It can affect the linear velocity change of the rigidbody in each axis. The larger the value, the faster the rigidbody moves.
!#zh
线线 */
linearFactor: Vec3;
/** !#en
It can affect the rotation speed change of the rigidbody in each axis. The larger the value, the faster the rigidbody rotates.
!#zh
*/
angularFactor: Vec3;
/** !#en
The rigidbody is awake.
!#zh
*/
isAwake: boolean;
/** !#en
The rigidbody can enter hibernation.
!#zh
*/
isSleepy: boolean;
/** !#en
The rigidbody is sleeping.
!#zh
*/
isSleeping: boolean;
/** !#en
Get the rigidbody object inside the physics engine.
!#zh
*/
rigidBody: IRigidBody;
/**
!#en
A force is applied to a rigid body at a point in world space.
!#zh
@param force force
@param relativePoint The point of action, relative to the center of the rigid body.
*/
applyForce(force: Vec3, relativePoint: Vec3): void;
/**
!#en
Apply a force on the rigid body at a point in local space.
!#zh
@param force force
@param localPoint Point of application
*/
applyLocalForce(force: Vec3, localPoint: Vec3): void;
/**
!#en
Apply an impulse to a rigid body at a point in world space.
!#zh
@param impulse impulse
@param relativePoint The point of action, relative to the center of the rigid body.
*/
applyImpulse(impulse: Vec3, relativePoint: Vec3): void;
/**
!#en
Apply an impulse to the rigid body at a point in local space.
!#zh
@param impulse impulse
@param localPoint Point of application
*/
applyLocalImpulse(impulse: Vec3, localPoint: Vec3): void;
/**
!#en
Apply a torque to the rigid body.
!#zh
@param torque torque
*/
applyTorque(torque: Vec3): void;
/**
!#en
Apply a local torque to the rigid body.
!#zh
@param torque torque
*/
applyLocalTorque(torque: Vec3): void;
/**
!#en
Awaken the rigid body.
!#zh
*/
wakeUp(): void;
/**
!#en
Dormant rigid body.
!#zh
*/
sleep(): void;
/**
!#en
Get linear velocity.
!#zh
线
@param out out
*/
getLinearVelocity(out: Vec3): void;
/**
!#en
Set linear speed.
!#zh
线
@param value value
*/
setLinearVelocity(value: Vec3): void;
/**
!#en
Gets the rotation speed.
!#zh
@param out out
*/
getAngularVelocity(out: Vec3): void;
/**
!#en
Set rotation speed.
!#zh
@param value value
*/
setAngularVelocity(value: Vec3): void;
}
/** !#en
Physics box collider
!#zh
*/
export class BoxCollider3D extends Collider3D {
/** !#en
Get or set the size of the box, in local space.
!#zh
*/
size: Vec3;
boxShape: IBoxShape;
}
/** !#en
The base class of the collider.
!#zh
*/
export class Collider3D extends Component implements EventTarget {
sharedMaterial: PhysicsMaterial;
/** !#en
get or set the collider is trigger, this will be always trigger if using builtin.
!#zh
*/
isTrigger: boolean;
/** !#en
get or set the center of the collider, in local space.
!#zh
*/
center: Vec3;
/** !#en
get the collider attached rigidbody, this may be null.
!#zh
null */
attachedRigidbody: RigidBody3D|void;
/** !#en
get collider shape.
!#zh
*/
shape: IBaseShape;
/**
!#en
Register an callback of a specific event type on the EventTarget.
This type of event should be triggered via `emit`.
!#zh
`emit`
@param type The type of collider event can be `trigger-enter`, `trigger-stay`, `trigger-exit` or `collision-enter`, `collision-stay`, `collision-exit`.
@param callback The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null.
@example
```js
eventTarget.on('fire', function (event) {
// event is ITriggerEvent or ICollisionEvent
}, node);
```
*/
on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T;
/**
!#en
Removes the listeners previously registered with the same type, callback, target and or useCapture,
if only type is passed as parameter, all listeners registered with that type will be removed.
!#zh
useCapture type type
@param type The type of collider event can be `trigger-enter`, `trigger-stay`, `trigger-exit` or `collision-enter`, `collision-stay`, `collision-exit`.
@param callback The callback to remove.
@param target The target (this object) to invoke the callback, if it's not given, only callback without target will be removed.
@example
```js
// register fire eventListener
var callback = eventTarget.on('fire', function () {
cc.log("fire in the hole");
}, target);
// remove fire event listener
eventTarget.off('fire', callback, target);
// remove all fire event listeners
eventTarget.off('fire');
```
*/
off(type: string, callback?: Function, target?: any): void;
/**
!#en
Register an callback of a specific event type on the EventTarget,
the callback will remove itself after the first time it is triggered.
!#zh
@param type The type of collider event can be `trigger-enter`, `trigger-stay`, `trigger-exit` or `collision-enter`, `collision-stay`, `collision-exit`.
@param callback The callback that will be invoked when the event is dispatched.
The callback is ignored if it is a duplicate (the callbacks are unique).
@param target The target (this object) to invoke the callback, can be null.
@example
```js
eventTarget.once('fire', function (event) {
// event is ITriggerEvent or ICollisionEvent
}, node);
```
*/
once(type: string, callback: (event: ITriggerEvent|ICollisionEvent) => void, target?: any): void;
/**
!#en Checks whether the EventTarget object has any callback registered for a specific type of event.
!#zh
@param type The type of event.
*/
hasEventListener(type: string): boolean;
/**
!#en Removes all callbacks previously registered with the same target (passed as parameter).
This is not for removing all listeners in the current event target,
and this is not for removing all listeners the target parameter have registered.
It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
!#zh EventTarget target
EventTarget target
target EventTarget
@param target The target to be searched for all related listeners
*/
targetOff(target: any): void;
/**
!#en
Send an event with the event object.
!#zh
@param event event
*/
dispatchEvent(event: Event): void;
/**
!#en
Destroy all callbackInfos.
!#zh
*/
clear(): void;
}
/** !#en
Physics sphere collider
!#zh
*/
export class SphereCollider3D extends Collider3D {
/** !#en
Get or set the radius of the sphere.
!#zh
*/
radius: number;
sphereShape: ISphereShape;
}
/****************************************************
* audioEngine
*****************************************************/
export namespace audioEngine {
/** !#en Audio state.
!#zh */
export enum AudioState {
ERROR = 0,
INITIALZING = 0,
PLAYING = 0,
PAUSED = 0,
STOPPED = 0,
}
}
/****************************************************
* debug
*****************************************************/
export namespace debug {
/** !#en Enum for debug modes.
!#zh */
export enum DebugMode {
NONE = 0,
INFO = 0,
WARN = 0,
ERROR = 0,
INFO_FOR_WEB_PAGE = 0,
WARN_FOR_WEB_PAGE = 0,
ERROR_FOR_WEB_PAGE = 0,
}
}
/****************************************************
* Node
*****************************************************/
export namespace Node {
/** !#en Node's local dirty properties flag
!#zh Node dirty */
export enum _LocalDirtyFlag {
POSITION = 0,
SCALE = 0,
ROTATION = 0,
SKEW = 0,
TRS = 0,
RS = 0,
TRS = 0,
PHYSICS_POSITION = 0,
PHYSICS_SCALE = 0,
PHYSICS_ROTATION = 0,
PHYSICS_TRS = 0,
PHYSICS_RS = 0,
ALL_POSITION = 0,
ALL_SCALE = 0,
ALL_ROTATION = 0,
ALL_TRS = 0,
ALL = 0,
}
}
/****************************************************
* Node
*****************************************************/
export namespace Node {
/** !#en The event type supported by Node
!#zh Node */
export class EventType {
/** !#en The event type for touch start event, you can use its value directly: 'touchstart'
!#zh */
static TOUCH_START: string;
/** !#en The event type for touch move event, you can use its value directly: 'touchmove'
!#zh */
static TOUCH_MOVE: string;
/** !#en The event type for touch end event, you can use its value directly: 'touchend'
!#zh */
static TOUCH_END: string;
/** !#en The event type for touch end event, you can use its value directly: 'touchcancel'
!#zh */
static TOUCH_CANCEL: string;
/** !#en The event type for mouse down events, you can use its value directly: 'mousedown'
!#zh */
static MOUSE_DOWN: string;
/** !#en The event type for mouse move events, you can use its value directly: 'mousemove'
!#zh */
static MOUSE_MOVE: string;
/** !#en The event type for mouse enter target events, you can use its value directly: 'mouseenter'
!#zh */
static MOUSE_ENTER: string;
/** !#en The event type for mouse leave target events, you can use its value directly: 'mouseleave'
!#zh */
static MOUSE_LEAVE: string;
/** !#en The event type for mouse up events, you can use its value directly: 'mouseup'
!#zh */
static MOUSE_UP: string;
/** !#en The event type for mouse wheel events, you can use its value directly: 'mousewheel'
!#zh */
static MOUSE_WHEEL: string;
/** !#en The event type for position change events.
Performance note, this event will be triggered every time corresponding properties being changed,
if the event callback have heavy logic it may have great performance impact, try to avoid such scenario.
!#zh
*/
static POSITION_CHANGED: string;
/** !#en The event type for rotation change events.
Performance note, this event will be triggered every time corresponding properties being changed,
if the event callback have heavy logic it may have great performance impact, try to avoid such scenario.
!#zh
*/
static ROTATION_CHANGED: string;
/** !#en The event type for scale change events.
Performance note, this event will be triggered every time corresponding properties being changed,
if the event callback have heavy logic it may have great performance impact, try to avoid such scenario.
!#zh
*/
static SCALE_CHANGED: string;
/** !#en The event type for size change events.
Performance note, this event will be triggered every time corresponding properties being changed,
if the event callback have heavy logic it may have great performance impact, try to avoid such scenario.
!#zh
*/
static SIZE_CHANGED: string;
/** !#en The event type for anchor point change events.
Performance note, this event will be triggered every time corresponding properties being changed,
if the event callback have heavy logic it may have great performance impact, try to avoid such scenario.
!#zh
*/
static ANCHOR_CHANGED: string;
/** !#en The event type for color change events.
Performance note, this event will be triggered every time corresponding properties being changed,
if the event callback have heavy logic it may have great performance impact, try to avoid such scenario.
!#zh
*/
static COLOR_CHANGED: string;
/** !#en The event type for new child added events.
!#zh */
static CHILD_ADDED: string;
/** !#en The event type for child removed events.
!#zh */
static CHILD_REMOVED: string;
/** !#en The event type for children reorder events.
!#zh */
static CHILD_REORDER: string;
/** !#en The event type for node group changed events.
!#zh */
static GROUP_CHANGED: string;
/** !#en The event type for node's sibling order changed.
!#zh */
static SIBLING_ORDER_CHANGED: string;
}
}
/****************************************************
* VideoPlayer
*****************************************************/
export namespace VideoPlayer {
/** !#en Video event type
!#zh */
export enum EventType {
PLAYING = 0,
PAUSED = 0,
STOPPED = 0,
COMPLETED = 0,
META_LOADED = 0,
CLICKED = 0,
READY_TO_PLAY = 0,
}
}
/****************************************************
* VideoPlayer
*****************************************************/
export namespace VideoPlayer {
/** !#en Enum for video resouce type type.
!#zh */
export enum ResourceType {
REMOTE = 0,
LOCAL = 0,
}
}
/****************************************************
* ParticleSystem
*****************************************************/
export namespace ParticleSystem {
/** !#en Enum for emitter modes
!#zh */
export enum EmitterMode {
GRAVITY = 0,
RADIUS = 0,
}
}
/****************************************************
* ParticleSystem
*****************************************************/
export namespace ParticleSystem {
/** !#en Enum for particles movement type.
!#zh */
export enum PositionType {
FREE = 0,
RELATIVE = 0,
GROUPED = 0,
}
}
/****************************************************
* TiledMap
*****************************************************/
export namespace TiledMap {
/** !#en The orientation of tiled map.
!#zh Tiled Map */
export enum Orientation {
ORTHO = 0,
HEX = 0,
ISO = 0,
}
}
/****************************************************
* TiledMap
*****************************************************/
export namespace TiledMap {
/** The property type of tiled map. */
export enum Property {
NONE = 0,
MAP = 0,
LAYER = 0,
OBJECTGROUP = 0,
OBJECT = 0,
TILE = 0,
}
}
/****************************************************
* TiledMap
*****************************************************/
export namespace TiledMap {
/** The tile flags of tiled map. */
export enum TileFlag {
HORIZONTAL = 0,
VERTICAL = 0,
DIAGONAL = 0,
FLIPPED_ALL = 0,
FLIPPED_MASK = 0,
}
}
/****************************************************
* TiledMap
*****************************************************/
export namespace TiledMap {
/** !#en The stagger axis of Hex tiled map.
!#zh stagger axis */
export enum StaggerAxis {
STAGGERAXIS_X = 0,
STAGGERAXIS_Y = 0,
}
}
/****************************************************
* TiledMap
*****************************************************/
export namespace TiledMap {
/** !#en The render order of tiled map.
!#zh */
export enum RenderOrder {
STAGGERINDEX_ODD = 0,
STAGGERINDEX_EVEN = 0,
RightDown = 0,
RightUp = 0,
LeftDown = 0,
LeftUp = 0,
}
}
/****************************************************
* TiledMap
*****************************************************/
export namespace TiledMap {
/** !#en TiledMap Object Type
!#zh */
export enum TMXObjectType {
RECT = 0,
ELLIPSE = 0,
POLYGON = 0,
POLYLINE = 0,
IMAGE = 0,
TEXT = 0,
}
}
/****************************************************
* WebView
*****************************************************/
export namespace WebView {
/** !#en WebView event type
!#zh */
export enum EventType {
LOADED = 0,
LOADING = 0,
ERROR = 0,
}
}
/****************************************************
* Camera
*****************************************************/
export namespace Camera {
/** !#en Values for Camera.clearFlags, determining what to clear when rendering a Camera.
!#zh */
export enum ClearFlags {
COLOR = 0,
DEPTH = 0,
STENCIL = 0,
}
}
/****************************************************
* Light
*****************************************************/
export namespace Light {
/** !#en The light source type
!#zh */
export enum Type {
DIRECTIONAL = 0,
POINT = 0,
SPOT = 0,
AMBIENT = 0,
}
}
/****************************************************
* Light
*****************************************************/
export namespace Light {
/** !#en The shadow type
!#zh */
export enum ShadowType {
NONE = 0,
HARD = 0,
SOFT_PCF3X3 = 0,
SOFT_PCF5X5 = 0,
}
}
/****************************************************
* Prefab
*****************************************************/
export namespace Prefab {
/** !#zh
Prefab {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}} 使
!#en
An enumeration used with the {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}}
to specify how to optimize the instantiate operation. */
export enum OptimizationPolicy {
AUTO = 0,
SINGLE_INSTANCE = 0,
MULTI_INSTANCE = 0,
}
}
/****************************************************
* RenderTexture
*****************************************************/
export namespace RenderTexture {
/** !#en The depth buffer and stencil buffer format for RenderTexture.
!#zh RenderTexture */
export enum DepthStencilFormat {
RB_FMT_D24S8 = 0,
RB_FMT_S8 = 0,
RB_FMT_D16 = 0,
}
}
/****************************************************
* Texture2D
*****************************************************/
export namespace Texture2D {
/** The texture pixel format, default value is RGBA8888,
you should note that textures loaded by normal image files (png, jpg) can only support RGBA8888 format,
other formats are supported by compressed file types or raw data. */
export enum PixelFormat {
RGB565 = 0,
RGB5A1 = 0,
RGBA4444 = 0,
RGB888 = 0,
RGBA8888 = 0,
RGBA32F = 0,
A8 = 0,
I8 = 0,
AI88 = 0,
RGB_PVRTC_2BPPV1 = 0,
RGBA_PVRTC_2BPPV1 = 0,
RGB_A_PVRTC_2BPPV1 = 0,
RGB_PVRTC_4BPPV1 = 0,
RGBA_PVRTC_4BPPV1 = 0,
RGB_A_PVRTC_4BPPV1 = 0,
RGB_ETC1 = 0,
RGBA_ETC1 = 0,
RGB_ETC2 = 0,
RGBA_ETC2 = 0,
}
}
/****************************************************
* Texture2D
*****************************************************/
export namespace Texture2D {
/** The texture wrap mode */
export enum WrapMode {
REPEAT = 0,
CLAMP_TO_EDGE = 0,
MIRRORED_REPEAT = 0,
}
}
/****************************************************
* Texture2D
*****************************************************/
export namespace Texture2D {
/** The texture filter mode */
export enum Filter {
LINEAR = 0,
NEAREST = 0,
}
}
/****************************************************
* Collider
*****************************************************/
export namespace Collider {
/** !#en Defines a Box Collider .
!#zh */
export class Box {
/** !#en Position offset
!#zh */
offset: Vec2;
/** !#en Box size
!#zh */
size: Size;
}
}
/****************************************************
* Collider
*****************************************************/
export namespace Collider {
/** !#en Defines a Circle Collider .
!#zh */
export class Circle {
/** !#en Position offset
!#zh */
offset: Vec2;
/** !#en Circle radius
!#zh */
radius: number;
}
}
/****************************************************
* Collider
*****************************************************/
export namespace Collider {
/** !#en Defines a Polygon Collider .
!#zh */
export class Polygon {
/** !#en Position offset
!#zh */
offset: Vec2;
/** !#en Polygon points
!#zh */
points: Vec2[];
}
}
/****************************************************
* Event
*****************************************************/
export namespace Event {
/** !#en The mouse event
!#zh */
export class EventMouse extends Event {
/**
!#en Sets scroll data.
!#zh
@param scrollX scrollX
@param scrollY scrollY
*/
setScrollData(scrollX: number, scrollY: number): void;
/**
!#en Returns the x axis scroll value.
!#zh X
*/
getScrollX(): number;
/**
!#en Returns the y axis scroll value.
!#zh Y
*/
getScrollY(): number;
/**
!#en Sets cursor location.
!#zh
@param x x
@param y y
*/
setLocation(x: number, y: number): void;
/**
!#en Returns cursor location.
!#zh x y
*/
getLocation(): Vec2;
/**
!#en Returns the current cursor location in screen coordinates.
!#zh x y
*/
getLocationInView(): Vec2;
/**
!#en Returns the previous touch location.
!#zh x y
*/
getPreviousLocation(): Vec2;
/**
!#en Returns the delta distance from the previous location to current location.
!#zh x y
*/
getDelta(): Vec2;
/**
!#en Returns the X axis delta distance from the previous location to current location.
!#zh X
*/
getDeltaX(): number;
/**
!#en Returns the Y axis delta distance from the previous location to current location.
!#zh Y
*/
getDeltaY(): number;
/**
!#en Sets mouse button.
!#zh
@param button button
*/
setButton(button: number): void;
/**
!#en Returns mouse button.
!#zh
*/
getButton(): number;
/**
!#en Returns location X axis data.
!#zh X
*/
getLocationX(): number;
/**
!#en Returns location Y axis data.
!#zh Y
*/
getLocationY(): number;
/** !#en The none event code of mouse event.
!#zh */
static NONE: number;
/** !#en The event type code of mouse down event.
!#zh */
static DOWN: number;
/** !#en The event type code of mouse up event.
!#zh */
static UP: number;
/** !#en The event type code of mouse move event.
!#zh */
static MOVE: number;
/** !#en The event type code of mouse scroll event.
!#zh */
static SCROLL: number;
/** !#en The tag of Mouse left button.
!#zh */
static BUTTON_LEFT: number;
/** !#en The tag of Mouse right button (The right button number is 2 on browser).
!#zh */
static BUTTON_RIGHT: number;
/** !#en The tag of Mouse middle button (The right button number is 1 on browser).
!#zh */
static BUTTON_MIDDLE: number;
/** !#en The tag of Mouse button 4.
!#zh 4 */
static BUTTON_4: number;
/** !#en The tag of Mouse button 5.
!#zh 5 */
static BUTTON_5: number;
/** !#en The tag of Mouse button 6.
!#zh 6 */
static BUTTON_6: number;
/** !#en The tag of Mouse button 7.
!#zh 7 */
static BUTTON_7: number;
/** !#en The tag of Mouse button 8.
!#zh 8 */
static BUTTON_8: number;
}
}
/****************************************************
* Event
*****************************************************/
export namespace Event {
/** !#en The touch event
!#zh */
export class EventTouch extends Event {
/**
@param touchArr The array of the touches
@param bubbles A boolean indicating whether the event bubbles up through the tree or not
*/
constructor(touchArr: any[], bubbles: boolean);
/** !#en The current touch object
!#zh */
touch: Touch;
/**
!#en Returns event code.
!#zh
*/
getEventCode(): number;
/**
!#en Returns touches of event.
!#zh
*/
getTouches(): any[];
/**
!#en Sets touch location.
!#zh
@param x x
@param y y
*/
setLocation(x: number, y: number): void;
/**
!#en Returns touch location.
!#zh
*/
getLocation(): Vec2;
/**
!#en Returns the current touch location in screen coordinates.
!#zh
*/
getLocationInView(): Vec2;
/**
!#en Returns the previous touch location.
!#zh x y
*/
getPreviousLocation(): Vec2;
/**
!#en Returns the start touch location.
!#zh x y
*/
getStartLocation(): Vec2;
/**
!#en Returns the id of cc.Touch.
!#zh ID
*/
getID(): number;
/**
!#en Returns the delta distance from the previous location to current location.
!#zh x y
*/
getDelta(): Vec2;
/**
!#en Returns the X axis delta distance from the previous location to current location.
!#zh x
*/
getDeltaX(): number;
/**
!#en Returns the Y axis delta distance from the previous location to current location.
!#zh y
*/
getDeltaY(): number;
/**
!#en Returns location X axis data.
!#zh X
*/
getLocationX(): number;
/**
!#en Returns location Y axis data.
!#zh Y
*/
getLocationY(): number;
}
}
/****************************************************
* Event
*****************************************************/
export namespace Event {
/** !#en The acceleration event
!#zh */
export class EventAcceleration extends Event {
}
}
/****************************************************
* Event
*****************************************************/
export namespace Event {
/** !#en The keyboard event
!#zh */
export class EventKeyboard extends Event {
/** !#en
The keyCode read-only property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key.
This is usually the decimal ASCII (RFC 20) or Windows 1252 code corresponding to the key.
If the key can't be identified, this value is 0.
!#zh
keyCode
ASCII (RFC20) Windows 1252
0 */
keyCode: number;
}
}
/****************************************************
* Event
*****************************************************/
export namespace Event {
/** !#en The Custom event
!#zh */
export class EventCustom extends Event {
/**
@param type The name of the event (case-sensitive), e.g. "click", "fire", or "submit"
@param bubbles A boolean indicating whether the event bubbles up through the tree or not
*/
constructor(type: string, bubbles: boolean);
/** !#en A reference to the detailed data of the event
!#zh */
detail: any;
/**
!#en Sets user data
!#zh
@param data data
*/
setUserData(data: any): void;
/**
!#en Gets user data
!#zh
*/
getUserData(): any;
/**
!#en Gets event name
!#zh
*/
getEventName(): string;
}
}
/****************************************************
* SystemEvent
*****************************************************/
export namespace SystemEvent {
/** !#en The event type supported by SystemEvent
!#zh SystemEvent */
export class EventType {
/** !#en The event type for press the key down event, you can use its value directly: 'keydown'
!#zh */
static KEY_DOWN: string;
/** !#en The event type for press the key up event, you can use its value directly: 'keyup'
!#zh */
static KEY_UP: string;
/** !#en The event type for press the devicemotion event, you can use its value directly: 'devicemotion'
!#zh */
static DEVICEMOTION: string;
}
}
/****************************************************
* Animation
*****************************************************/
export namespace Animation {
/** !#en The event type supported by Animation
!#zh Animation */
export class EventType {
/** !#en Emit when begin playing animation
!#zh */
static PLAY: string;
/** !#en Emit when stop playing animation
!#zh */
static STOP: string;
/** !#en Emit when pause animation
!#zh */
static PAUSE: string;
/** !#en Emit when resume animation
!#zh */
static RESUME: string;
/** !#en If animation repeat count is larger than 1, emit when animation play to the last frame
!#zh 1 */
static LASTFRAME: string;
/** !#en Emit when finish playing animation
!#zh */
static FINISHED: string;
}
}
/****************************************************
* Button
*****************************************************/
export namespace Button {
/** !#en Enum for transition type.
!#zh */
export enum Transition {
NONE = 0,
COLOR = 0,
SPRITE = 0,
SCALE = 0,
}
}
/****************************************************
* Component
*****************************************************/
export namespace Component {
/** !#en
Component will register a event to target component's handler.
And it will trigger the handler when a certain event occurs.
!@zh
EventHandler
emit */
export class EventHandler {
/** !#en the node that contains target callback, such as the node example script belongs to
!#zh */
target: Node;
/** !#en name of the component(script) that contains target callback, such as the name 'MainMenu' of script in example
!#zh , 'MainMenu' */
component: string;
/** !#en Event handler, such as function's name 'onClick' in example
!#zh 'onClick' */
handler: string;
/** !#en Custom Event Data, such as 'eventType' in example
!#zh eventType */
customEventData: string;
/**
@param events events
@param params params
*/
static emitEvents(events: EventHandler[], ...params: any[]): void;
/**
!#en Emit event with params
!#zh handler
@param params params
@example
```js
// Call Function
var eventHandler = new cc.Component.EventHandler();
eventHandler.target = newTarget;
eventHandler.component = "MainMenu";
eventHandler.handler = "OnClick"
eventHandler.emit(["param1", "param2", ....]);
```
*/
emit(params: any[]): void;
}
}
/****************************************************
* Label
*****************************************************/
export namespace Label {
/** !#en Enum for text alignment.
!#zh */
export enum HorizontalAlign {
LEFT = 0,
CENTER = 0,
RIGHT = 0,
}
}
/****************************************************
* Label
*****************************************************/
export namespace Label {
/** !#en Enum for vertical text alignment.
!#zh */
export enum VerticalAlign {
TOP = 0,
CENTER = 0,
BOTTOM = 0,
}
}
/****************************************************
* Label
*****************************************************/
export namespace Label {
/** !#en Enum for Overflow.
!#zh Overflow */
export enum Overflow {
NONE = 0,
CLAMP = 0,
SHRINK = 0,
RESIZE_HEIGHT = 0,
}
}
/****************************************************
* Label
*****************************************************/
export namespace Label {
/** !#en Enum for font type.
!#zh Type */
export enum Type {
TTF = 0,
BMFont = 0,
SystemFont = 0,
}
}
/****************************************************
* Label
*****************************************************/
export namespace Label {
/** !#en Enum for cache mode.
!#zh CacheMode */
export enum CacheMode {
NONE = 0,
BITMAP = 0,
CHAR = 0,
}
}
/****************************************************
* Layout
*****************************************************/
export namespace Layout {
/** !#en Enum for Layout type
!#zh */
export enum Type {
NONE = 0,
HORIZONTAL = 0,
VERTICAL = 0,
GRID = 0,
}
}
/****************************************************
* Layout
*****************************************************/
export namespace Layout {
/** !#en Enum for Layout Resize Mode
!#zh */
export enum ResizeMode {
NONE = 0,
CONTAINER = 0,
CHILDREN = 0,
}
}
/****************************************************
* Layout
*****************************************************/
export namespace Layout {
/** !#en Enum for Grid Layout start axis direction.
The items in grid layout will be arranged in each axis at first.;
!#zh GRID */
export enum AxisDirection {
HORIZONTAL = 0,
VERTICAL = 0,
}
}
/****************************************************
* Layout
*****************************************************/
export namespace Layout {
/** !#en Enum for vertical layout direction.
Used in Grid Layout together with AxisDirection is VERTICAL
!#zh */
export enum VerticalDirection {
BOTTOM_TO_TOP = 0,
TOP_TO_BOTTOM = 0,
}
}
/****************************************************
* Layout
*****************************************************/
export namespace Layout {
/** !#en Enum for horizontal layout direction.
Used in Grid Layout together with AxisDirection is HORIZONTAL
!#zh */
export enum HorizontalDirection {
LEFT_TO_RIGHT = 0,
RIGHT_TO_LEFT = 0,
}
}
/****************************************************
* Mask
*****************************************************/
export namespace Mask {
/** !#en the type for mask.
!#zh */
export enum Type {
RECT = 0,
ELLIPSE = 0,
IMAGE_STENCIL = 0,
}
}
/****************************************************
* PageView
*****************************************************/
export namespace PageView {
/** !#en The Page View Size Mode
!#zh */
export enum SizeMode {
Unified = 0,
Free = 0,
}
}
/****************************************************
* PageView
*****************************************************/
export namespace PageView {
/** !#en The Page View Direction
!#zh */
export enum Direction {
Horizontal = 0,
Vertical = 0,
}
}
/****************************************************
* PageView
*****************************************************/
export namespace PageView {
/** !#en Enum for ScrollView event type.
!#zh */
export enum EventType {
PAGE_TURNING = 0,
}
}
/****************************************************
* PageViewIndicator
*****************************************************/
export namespace PageViewIndicator {
/** !#en Enum for PageView Indicator direction
!#zh */
export enum Direction {
HORIZONTAL = 0,
VERTICAL = 0,
}
}
/****************************************************
* ProgressBar
*****************************************************/
export namespace ProgressBar {
/** !#en Enum for ProgressBar mode
!#zh */
export enum Mode {
HORIZONTAL = 0,
VERTICAL = 0,
FILLED = 0,
}
}
/****************************************************
* Scrollbar
*****************************************************/
export namespace Scrollbar {
/** Enum for Scrollbar direction */
export enum Direction {
HORIZONTAL = 0,
VERTICAL = 0,
}
}
/****************************************************
* ScrollView
*****************************************************/
export namespace ScrollView {
/** !#en Enum for ScrollView event type.
!#zh */
export enum EventType {
SCROLL_TO_TOP = 0,
SCROLL_TO_BOTTOM = 0,
SCROLL_TO_LEFT = 0,
SCROLL_TO_RIGHT = 0,
SCROLLING = 0,
BOUNCE_TOP = 0,
BOUNCE_BOTTOM = 0,
BOUNCE_LEFT = 0,
BOUNCE_RIGHT = 0,
SCROLL_ENDED = 0,
TOUCH_UP = 0,
AUTOSCROLL_ENDED_WITH_THRESHOLD = 0,
SCROLL_BEGAN = 0,
}
}
/****************************************************
* Slider
*****************************************************/
export namespace Slider {
/** !#en The Slider Direction
!#zh */
export enum Direction {
Horizontal = 0,
Vertical = 0,
}
}
/****************************************************
* Sprite
*****************************************************/
export namespace Sprite {
/** !#en Enum for sprite type.
!#zh Sprite */
export enum Type {
SIMPLE = 0,
SLICED = 0,
TILED = 0,
FILLED = 0,
MESH = 0,
}
}
/****************************************************
* Sprite
*****************************************************/
export namespace Sprite {
/** !#en Enum for fill type.
!#zh */
export enum FillType {
HORIZONTAL = 0,
VERTICAL = 0,
RADIAL = 0,
}
}
/****************************************************
* Sprite
*****************************************************/
export namespace Sprite {
/** !#en Sprite Size can track trimmed size, raw size or none.
!#zh */
export enum SizeMode {
CUSTOM = 0,
TRIMMED = 0,
RAW = 0,
}
}
/****************************************************
* Sprite
*****************************************************/
export namespace Sprite {
/** !#en Sprite state can choice the normal or grayscale.
!#zh */
export enum State {
NORMAL = 0,
GRAY = 0,
}
}
/****************************************************
* Widget
*****************************************************/
export namespace Widget {
/** !#en Enum for Widget's alignment mode, indicating when the widget should refresh.
!#zh Widget Widget */
export enum AlignMode {
ONCE = 0,
ON_WINDOW_RESIZE = 0,
ALWAYS = 0,
}
}
/****************************************************
* geomUtils
*****************************************************/
export namespace geomUtils {
/** Aabb */
export class Aabb {
/**
create a new aabb
@param px X coordinates for aabb's original point
@param py Y coordinates for aabb's original point
@param pz Z coordinates for aabb's original point
@param w the half of aabb width
@param h the half of aabb height
@param l the half of aabb length
*/
create(px: number, py: number, pz: number, w: number, h: number, l: number): Aabb;
/**
clone a new aabb
@param a the source aabb
*/
clone(a: Aabb): Aabb;
/**
copy the values from one aabb to another
@param out the receiving aabb
@param a the source aabb
*/
copy(out: Aabb, a: Aabb): Aabb;
/**
create a new aabb from two corner points
@param out the receiving aabb
@param minPos lower corner position of the aabb
@param maxPos upper corner position of the aabb
*/
fromPoints(out: Aabb, minPos: Vec3, maxPos: Vec3): Aabb;
/**
Set the components of a aabb to the given values
@param out the receiving aabb
@param px X coordinates for aabb's original point
@param py Y coordinates for aabb's original point
@param pz Z coordinates for aabb's original point
@param w the half of aabb width
@param h the half of aabb height
@param l the half of aabb length
*/
set(out: Aabb, px: number, py: number, pz: number, w: number, h: number, l: number): Aabb;
center: Vec3;
halfExtents: Vec3;
_type: number;
/**
Get the bounding points of this shape
@param minPos minPos
@param maxPos maxPos
*/
getBoundary(minPos: Vec3, maxPos: Vec3): void;
/**
Transform this shape
@param m the transform matrix
@param pos the position part of the transform
@param rot the rotation part of the transform
@param scale the scale part of the transform
@param out the target shape
*/
transform(m: Mat4, pos: Vec3, rot: Quat, scale: Vec3, out?: Aabb): void;
}
}
/****************************************************
* geomUtils
*****************************************************/
export namespace geomUtils {
/** !#en Shape type. */
export enum enums {
SHAPE_RAY = 0,
SHAPE_LINE = 0,
SHAPE_SPHERE = 0,
SHAPE_AABB = 0,
SHAPE_OBB = 0,
SHAPE_PLANE = 0,
SHAPE_TRIANGLE = 0,
SHAPE_FRUSTUM = 0,
SHAPE_FRUSTUM_ACCURATE = 0,
}
}
/****************************************************
* geomUtils
*****************************************************/
export namespace geomUtils {
/** !#en frustum
!#zh */
export class Frustum {
/** Set whether to use accurate intersection testing function on this frustum */
accurate: boolean;
/**
create a new frustum
*/
static create(): Frustum;
/**
Clone a frustum
@param f f
*/
static clone(f: Frustum): Frustum;
/**
Copy the values from one frustum to another
@param out out
@param f f
*/
copy(out: Frustum, f: Frustum): Frustum;
planes: geomUtils.Plane[];
planes: Vec3[];
/**
!#en Update the frustum information according to the given transform matrix.
Note that the resulting planes are not normalized under normal mode.
@param m the view-projection matrix
@param inv the inverse view-projection matrix
*/
update(m: Mat4, inv: Mat4): void;
/**
!#en transform by matrix
@param mat mat
*/
transform(mat: Mat4): void;
}
}
/****************************************************
* geomUtils
*****************************************************/
export namespace geomUtils {
/** undefined */
export class intersect {
/**
!#en
Check whether ray intersect with nodes
!#zh
线
@param root If root is null, then traversal nodes from scene node
@param worldRay worldRay
@param handler handler
@param filter filter
*/
static ray_cast(root: Node, worldRay: geomUtils.Ray, handler: Function, filter: Function): any[];
/**
!#en ray-plane intersect<br/>
!#zh 线
@param ray ray
@param plane plane
*/
static ray_plane(ray: geomUtils.Ray, plane: geomUtils.Plane): number;
/**
!#en line-plane intersect<br/>
!#zh 线
@param line line
@param plane plane
*/
static line_plane(line: geomUtils.Line, plane: geomUtils.Plane): number;
/**
!#en ray-triangle intersect<br/>
!#zh 线
@param ray ray
@param triangle triangle
@param doubleSided doubleSided
*/
static ray_triangle(ray: geomUtils.Ray, triangle: geomUtils.Triangle, doubleSided: boolean): number;
/**
!#en line-triangle intersect<br/>
!#zh 线
@param line line
@param triangle triangle
@param outPt optional, The intersection point
*/
static line_triangle(line: geomUtils.Line, triangle: geomUtils.Triangle, outPt: Vec3): number;
/**
!#en line-quad intersect<br/>
!#zh 线
@param p A point on a line segment
@param q Another point on the line segment
@param a Quadrilateral point a
@param b Quadrilateral point b
@param c Quadrilateral point c
@param d Quadrilateral point d
@param outPt optional, The intersection point
*/
static line_quad(p: Vec3, q: Vec3, a: Vec3, b: Vec3, c: Vec3, d: Vec3, outPt: Vec3): number;
/**
!#en ray-sphere intersect<br/>
!#zh 线
@param ray ray
@param sphere sphere
*/
static ray_sphere(ray: geomUtils.Ray, sphere: geomUtils.Sphere): number;
/**
!#en ray-aabb intersect<br/>
!#zh 线
@param ray ray
@param aabb Align the axis around the box
*/
static ray_aabb(ray: geomUtils.Ray, aabb: Aabb): number;
/**
!#en ray-obb intersect<br/>
!#zh 线
@param ray ray
@param obb Direction box
*/
static ray_obb(ray: geomUtils.Ray, obb: geomUtils.Obb): number;
/**
!#en aabb-aabb intersect<br/>
!#zh
@param aabb1 Axis alignment surrounds box 1
@param aabb2 Axis alignment surrounds box 2
*/
static aabb_aabb(aabb1: Aabb, aabb2: Aabb): number;
/**
!#en aabb-obb intersect<br/>
!#zh
@param aabb Align the axis around the box
@param obb Direction box
*/
static aabb_obb(aabb: Aabb, obb: geomUtils.Obb): number;
/**
!#en aabb-plane intersect<br/>
!#zh
@param aabb Align the axis around the box
@param plane plane
*/
static aabb_plane(aabb: Aabb, plane: geomUtils.Plane): number;
/**
!#en aabb-frustum intersect, faster but has false positive corner cases<br/>
!#zh
@param aabb Align the axis around the box
@param frustum frustum
*/
static aabb_frustum(aabb: Aabb, frustum: Frustum): number;
/**
!#en aabb-frustum intersect, handles most of the false positives correctly<br/>
!#zh
@param aabb Align the axis around the box
@param frustum frustum
*/
static aabb_frustum_accurate(aabb: Aabb, frustum: Frustum): number;
/**
!#en obb-point intersect<br/>
!#zh
@param obb Direction box
@param point point
*/
static obb_point(obb: geomUtils.Obb, point: geomUtils.Vec3): boolean;
/**
!#en obb-plane intersect<br/>
!#zh
@param obb Direction box
@param plane plane
*/
static obb_plane(obb: geomUtils.Obb, plane: geomUtils.Plane): number;
/**
!#en obb-frustum intersect, faster but has false positive corner cases<br/>
!#zh
@param obb Direction box
@param frustum frustum
*/
static obb_frustum(obb: geomUtils.Obb, frustum: Frustum): number;
/**
!#en obb-frustum intersect, handles most of the false positives correctly<br/>
!#zh
@param obb Direction box
@param frustum frustum
*/
static obb_frustum_accurate(obb: geomUtils.Obb, frustum: Frustum): number;
/**
!#en obb-obb intersect<br/>
!#zh
@param obb1 Direction box1
@param obb2 Direction box2
*/
static obb_obb(obb1: geomUtils.Obb, obb2: geomUtils.Obb): number;
/**
!#en phere-plane intersect, not necessarily faster than obb-plane<br/>
due to the length calculation of the plane normal to factor out<br/>
the unnomalized plane distance<br/>
!#zh
@param sphere sphere
@param plane plane
*/
static sphere_plane(sphere: geomUtils.Sphere, plane: geomUtils.Plane): number;
/**
!#en sphere-frustum intersect, faster but has false positive corner cases<br/>
!#zh
@param sphere sphere
@param frustum frustum
*/
static sphere_frustum(sphere: geomUtils.Sphere, frustum: Frustum): number;
/**
!#en sphere-frustum intersect, handles the false positives correctly<br/>
!#zh
@param sphere sphere
@param frustum frustum
*/
static sphere_frustum_accurate(sphere: geomUtils.Sphere, frustum: Frustum): number;
/**
!#en sphere-sphere intersect<br/>
!#zh
@param sphere0 sphere0
@param sphere1 sphere1
*/
static sphere_sphere(sphere0: geomUtils.Sphere, sphere1: geomUtils.Sphere): boolean;
/**
!#en sphere-aabb intersect<br/>
!#zh
@param sphere sphere
@param aabb aabb
*/
static sphere_aabb(sphere: geomUtils.Sphere, aabb: Aabb): boolean;
/**
!#en sphere-obb intersect<br/>
!#zh
@param sphere sphere
@param obb obb
*/
static sphere_obb(sphere: geomUtils.Sphere, obb: geomUtils.Obb): boolean;
/**
!#en
The intersection detection of g1 and g2 can fill in the shape in the basic geometry.
!#zh
g1 g2
@param g1 Geometry 1
@param g2 Geometry 2
@param outPt optional, Intersection point. (note: only partial shape detection with this return value)
*/
static resolve(g1: any, g2: any, outPt: any): void;
}
}
/****************************************************
* geomUtils
*****************************************************/
export namespace geomUtils {
/** !#en
line
!#zh
线 */
export class Line {
/**
!#en
create a new line
!#zh
line
@param sx The x part of the starting point.
@param sy The y part of the starting point.
@param sz The z part of the starting point.
@param ex The x part of the end point.
@param ey The y part of the end point.
@param ez The z part of the end point.
*/
create(sx: number, sy: number, sz: number, ex: number, ey: number, ez: number): Line;
/**
!#en
Creates a new line initialized with values from an existing line
!#zh
line
@param a The source of cloning.
*/
clone(a: Line): Line;
/**
!#en
Copy the values from one line to another
!#zh
线
@param out The object that accepts the action.
@param a The source of the copy.
*/
copy(out: Line, a: Line): Line;
/**
!#en
create a line from two points
!#zh
线
@param out The object that accepts the action.
@param start The starting point.
@param end At the end.
*/
fromPoints(out: Line, start: Vec3, end: Vec3): Line;
/**
!#en
Set the components of a Vec3 to the given values
!#zh
线
@param out The object that accepts the action.
@param sx The x part of the starting point.
@param sy The y part of the starting point.
@param sz The z part of the starting point.
@param ex The x part of the end point.
@param ey The y part of the end point.
@param ez The z part of the end point.
*/
set(out: Line, sx: number, sy: number, sz: number, ex: number, ey: number, ez: number): Line;
/**
!#en
Calculate the length of the line.
!#zh
线
@param a The line to calculate.
*/
len(a: Line): number;
/** !#en
Start points.
!#zh
*/
s: Vec3;
/** !#en
End points.
!#zh
*/
e: Vec3;
/**
!#en
Calculate the length of the line.
!#zh
线
*/
length(): number;
}
}
/****************************************************
* geomUtils
*****************************************************/
export namespace geomUtils {
/** !#en obb
!#zh
*/
export class Obb {
/** !#zh
*/
type: number;
/**
!#en
create a new obb
!#zh
obb
@param cx X coordinates of the shape relative to the origin.
@param cy Y coordinates of the shape relative to the origin.
@param cz Z coordinates of the shape relative to the origin.
@param hw Obb is half the width.
@param hh Obb is half the height.
@param hl Obb is half the Length.
@param ox_1 Direction matrix parameter.
@param ox_2 Direction matrix parameter.
@param ox_3 Direction matrix parameter.
@param oy_1 Direction matrix parameter.
@param oy_2 Direction matrix parameter.
@param oy_3 Direction matrix parameter.
@param oz_1 Direction matrix parameter.
@param oz_2 Direction matrix parameter.
@param oz_3 Direction matrix parameter.
*/
create(cx: number, cy: number, cz: number, hw: number, hh: number, hl: number, ox_1: number, ox_2: number, ox_3: number, oy_1: number, oy_2: number, oy_3: number, oz_1: number, oz_2: number, oz_3: number): Obb;
/**
!#en
clone a new obb
!#zh
obb
@param a The target of cloning.
*/
clone(a: Obb): Obb;
/**
!#en
copy the values from one obb to another
!#zh
obb obb
@param out Obb that accepts the operation.
@param a Obb being copied.
*/
copy(out: Obb, a: Obb): Obb;
/**
!#en
create a new obb from two corner points
!#zh
obb
@param out Obb that accepts the operation.
@param minPos The smallest point of obb.
@param maxPos Obb's maximum point.
*/
fromPoints(out: Obb, minPos: Vec3, maxPos: Vec3): Obb;
/**
!#en
Set the components of a obb to the given values
!#zh
obb
@param cx X coordinates of the shape relative to the origin.
@param cy Y coordinates of the shape relative to the origin.
@param cz Z coordinates of the shape relative to the origin.
@param hw Obb is half the width.
@param hh Obb is half the height.
@param hl Obb is half the Length.
@param ox_1 Direction matrix parameter.
@param ox_2 Direction matrix parameter.
@param ox_3 Direction matrix parameter.
@param oy_1 Direction matrix parameter.
@param oy_2 Direction matrix parameter.
@param oy_3 Direction matrix parameter.
@param oz_1 Direction matrix parameter.
@param oz_2 Direction matrix parameter.
@param oz_3 Direction matrix parameter.
*/
set(cx: number, cy: number, cz: number, hw: number, hh: number, hl: number, ox_1: number, ox_2: number, ox_3: number, oy_1: number, oy_2: number, oy_3: number, oz_1: number, oz_2: number, oz_3: number): Obb;
/** !#en
The center of the local coordinate.
!#zh
*/
center: Vec3;
/** !#en
Half the length, width, and height.
!#zh
*/
halfExtents: Vec3;
/** !#en
Direction matrix.
!#zh
*/
orientation: Mat3;
/**
!#en
Get the bounding points of this shape
!#zh
obb
@param minPos minPos
@param maxPos maxPos
*/
getBoundary(minPos: Vec3, maxPos: Vec3): void;
/**
!#en Transform this shape
!#zh
out obb
@param m The transformation matrix.
@param pos The position part of the transformation.
@param rot The rotating part of the transformation.
@param scale The scaling part of the transformation.
@param out Target of transformation.
*/
transform(m: Mat4, pos: Vec3, rot: Quat, scale: Vec3, out: Obb): void;
/**
!#en
Transform out based on this obb data.
!#zh
out obb
@param m The transformation matrix.
@param rot The rotating part of the transformation.
@param out Target of transformation.
*/
translateAndRotate(m: Mat4, rot: Quat, out: Obb): void;
/**
!#en
Scale out based on this obb data.
!#zh
out obb
@param scale Scale value.
@param out Scaled target.
*/
setScale(scale: Vec3, out: Obb): void;
}
}
/****************************************************
* geomUtils
*****************************************************/
export namespace geomUtils {
/** !#en
plane
!#zh
*/
export class Plane {
/**
!#en
create a new plane
!#zh
plane
@param nx The x part of the normal component.
@param ny The y part of the normal component.
@param nz The z part of the normal component.
@param d Distance from the origin.
*/
create(nx: number, ny: number, nz: number, d: number): Plane;
/**
!#en
clone a new plane
!#zh
plane
@param p The source of cloning.
*/
clone(p: Plane): Plane;
/**
!#en
copy the values from one plane to another
!#zh
@param out The object that accepts the action.
@param p The source of the copy.
*/
copy(out: Plane, p: Plane): Plane;
/**
!#en
create a plane from three points
!#zh
@param out The object that accepts the action.
@param a Point a
@param b Point b
@param c Point c
*/
fromPoints(out: Plane, a: Vec3, b: Vec3, c: Vec3): Plane;
/**
!#en
Set the components of a plane to the given values
!#zh
@param out The object that accepts the action.
@param nx The x part of the normal component.
@param ny The y part of the normal component.
@param nz The z part of the normal component.
@param d Distance from the origin.
*/
set(out: Plane, nx: number, ny: number, nz: number, d: number): Plane;
/**
!#en
create plane from normal and point
!#zh
线
@param out The object that accepts the action.
@param normal The normal of a plane.
@param point A point on the plane.
*/
fromNormalAndPoint(out: Plane, normal: Vec3, point: Vec3): Plane;
/**
!#en
normalize a plane
!#zh
@param out The object that accepts the action.
@param a Source data for operations.
*/
normalize(out: Plane, a: Plane): Plane;
/** !#en
A normal vector.
!#zh
线 */
n: Vec3;
/** !#en
The distance from the origin to the plane.
!#zh
*/
d: number;
/**
!#en
Transform a plane.
!#zh
@param mat mat
*/
transform(mat: Mat4): void;
}
}
/****************************************************
* geomUtils
*****************************************************/
export namespace geomUtils {
/** !#en
ray
!#zh
线 */
export class Ray {
/**
!#en
create a new ray
!#zh
线
@param ox The x part of the starting point.
@param oy The y part of the starting point.
@param oz The z part of the starting point.
@param dx X in the direction.
@param dy Y in the direction.
@param dz Z in the direction.
*/
create(ox: number, oy: number, oz: number, dx: number, dy: number, dz: number): Ray;
/**
!#en
Creates a new ray initialized with values from an existing ray
!#zh
线线
@param a Clone target
*/
clone(a: Ray): Ray;
/**
!#en
Copy the values from one ray to another
!#zh
ray ray
@param out Accept the ray of the operation.
@param a Copied ray.
*/
copy(out: Ray, a: Ray): Ray;
/**
!#en
create a ray from two points
!#zh
线
@param out Receive the operating ray.
@param origin Origin of ray
@param target A point on a ray.
*/
fromPoints(out: Ray, origin: Vec3, target: Vec3): Ray;
/**
!#en
Set the components of a ray to the given values
!#zh
线
@param out Receive the operating ray.
@param ox The x part of the starting point.
@param oy The y part of the starting point.
@param oz The z part of the starting point.
@param dx X in the direction.
@param dy Y in the direction.
@param dz Z in the direction.
*/
set(out: Ray, ox: number, oy: number, oz: number, dx: number, dy: number, dz: number): Ray;
/** !#en
Start point.
!#zh
*/
o: Vec3;
/** !#e
Direction
!#zh
*/
d: Vec3;
/**
!#en Compute hit.
@param out out
@param distance distance
*/
computeHit(out: IVec3Like, distance: number): void;
}
}
/****************************************************
* geomUtils
*****************************************************/
export namespace geomUtils {
/** !#en
Sphere.
!#zh
*/
export class Sphere {
/**
!#en
create a new sphere
!#zh
sphere
@param cx X coordinates of the shape relative to the origin.
@param cy Y coordinates of the shape relative to the origin.
@param cz Z coordinates of the shape relative to the origin.
@param r Radius of sphere
*/
create(cx: any, cy: any, cz: any, r: any): Sphere;
/**
!#en
clone a new sphere
!#zh
sphere
@param p The target of cloning.
*/
clone(p: Sphere): Sphere;
/**
!#en
copy the values from one sphere to another
!#zh
sphere sphere
@param out Accept the sphere of operations.
@param a Sphere being copied.
*/
copy(out: Sphere, a: Sphere): Sphere;
/**
!#en
create a new bounding sphere from two corner points
!#zh
sphere
@param out Accept the sphere of operations.
@param minPos The smallest point of sphere.
@param maxPos The maximum point of sphere.
*/
fromPoints(out: any, minPos: any, maxPos: any): Sphere;
/**
!#en Set the components of a sphere to the given values
!#zh
@param out Accept the sphere of operations.
@param cx X coordinates of the shape relative to the origin.
@param cy Y coordinates of the shape relative to the origin.
@param cz Z coordinates of the shape relative to the origin.
@param r Radius.
*/
set(out: Sphere, cx: any, cy: any, cz: any, r: number): Sphere;
/** !#en
The center of the local coordinate.
!#zh
*/
center: Vec3;
/** !#zh
*/
radius: number;
/**
!#en
Clone.
!#zh
*/
clone(): void;
/**
!#en
Copy sphere
!#zh
@param a Copy target.
*/
copy(a: any): void;
/**
!#en
Get the bounding points of this shape
!#zh
@param minPos minPos
@param maxPos maxPos
*/
getBoundary(minPos: Vec3, maxPos: Vec3): void;
/**
!#en
Transform this shape
!#zh
out sphere
@param m The transformation matrix.
@param pos The position part of the transformation.
@param rot The rotating part of the transformation.
@param scale The scaling part of the transformation.
@param out The target of the transformation.
*/
transform(m: any, pos: any, rot: any, scale: any, out: any): void;
/**
!#en
Scale out based on the sphere data.
!#zh
out sphere
@param scale Scale value
@param out Scale target
*/
setScale(scale: any, out: any): void;
}
}
/****************************************************
* geomUtils
*****************************************************/
export namespace geomUtils {
/** Triangle */
export class Triangle {
/**
create a new triangle
@param ax ax
@param ay ay
@param az az
@param bx bx
@param by by
@param bz bz
@param cx cx
@param cy cy
@param cz cz
*/
create(ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): Triangle;
/**
clone a new triangle
@param t the source plane
*/
clone(t: Triangle): Triangle;
/**
copy the values from one triangle to another
@param out the receiving triangle
@param t the source triangle
*/
copy(out: Triangle, t: Triangle): Triangle;
/**
Create a triangle from three points
@param out the receiving triangle
@param a a
@param b b
@param c c
*/
fromPoints(out: Triangle, a: Vec3, b: Vec3, c: Vec3): Triangle;
/**
Set the components of a triangle to the given values
@param out the receiving plane
@param ax X component of a
@param ay Y component of a
@param az Z component of a
@param bx X component of b
@param by Y component of b
@param bz Z component of b
@param cx X component of c
@param cy Y component of c
@param cz Z component of c
*/
set(out: Triangle, ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): Plane;
a: Vec3;
b: Vec3;
c: Vec3;
}
}
/****************************************************
* MeshRenderer
*****************************************************/
export namespace MeshRenderer {
/** !#en Shadow projection mode
!#ch */
export enum ShadowCastingMode {
OFF = 0,
ON = 0,
}
}
/****************************************************
* Graphics
*****************************************************/
export namespace Graphics {
/** !#en Enum for LineCap.
!#zh 线 */
export enum LineCap {
BUTT = 0,
ROUND = 0,
SQUARE = 0,
}
}
/****************************************************
* Graphics
*****************************************************/
export namespace Graphics {
/** !#en Enum for LineJoin.
!#zh 线 */
export enum LineJoin {
BEVEL = 0,
ROUND = 0,
MITER = 0,
}
}
/****************************************************
* macro
*****************************************************/
export namespace macro {
/** !#en Key map for keyboard event
!#zh */
export enum KEY {
none = 0,
back = 0,
menu = 0,
backspace = 0,
tab = 0,
enter = 0,
shift = 0,
ctrl = 0,
alt = 0,
pause = 0,
capslock = 0,
escape = 0,
space = 0,
pageup = 0,
pagedown = 0,
end = 0,
home = 0,
left = 0,
up = 0,
right = 0,
down = 0,
select = 0,
insert = 0,
Delete = 0,
a = 0,
b = 0,
c = 0,
d = 0,
e = 0,
f = 0,
g = 0,
h = 0,
i = 0,
j = 0,
k = 0,
l = 0,
m = 0,
n = 0,
o = 0,
p = 0,
q = 0,
r = 0,
s = 0,
t = 0,
u = 0,
v = 0,
w = 0,
x = 0,
y = 0,
z = 0,
num0 = 0,
num1 = 0,
num2 = 0,
num3 = 0,
num4 = 0,
num5 = 0,
num6 = 0,
num7 = 0,
num8 = 0,
num9 = 0,
'*' = 0,
'+' = 0,
'-' = 0,
numdel = 0,
'/' = 0,
f1 = 0,
f2 = 0,
f3 = 0,
f4 = 0,
f5 = 0,
f6 = 0,
f7 = 0,
f8 = 0,
f9 = 0,
f10 = 0,
f11 = 0,
f12 = 0,
numlock = 0,
scrolllock = 0,
';' = 0,
semicolon = 0,
equal = 0,
'=' = 0,
',' = 0,
comma = 0,
dash = 0,
'.' = 0,
period = 0,
forwardslash = 0,
grave = 0,
'[' = 0,
openbracket = 0,
backslash = 0,
']' = 0,
closebracket = 0,
quote = 0,
dpadLeft = 0,
dpadRight = 0,
dpadUp = 0,
dpadDown = 0,
dpadCenter = 0,
}
}
/****************************************************
* macro
*****************************************************/
export namespace macro {
/** Image formats */
export enum ImageFormat {
JPG = 0,
PNG = 0,
TIFF = 0,
WEBP = 0,
PVR = 0,
ETC = 0,
S3TC = 0,
ATITC = 0,
TGA = 0,
RAWDATA = 0,
UNKNOWN = 0,
}
}
/****************************************************
* macro
*****************************************************/
export namespace macro {
/** !#en
Enum for blend factor
Refer to: http://www.andersriggelsen.dk/glblendfunc.php
!#zh
: http://www.andersriggelsen.dk/glblendfunc.php */
export enum BlendFactor {
ONE = 0,
ZERO = 0,
SRC_ALPHA = 0,
SRC_COLOR = 0,
DST_ALPHA = 0,
DST_COLOR = 0,
ONE_MINUS_SRC_ALPHA = 0,
ONE_MINUS_SRC_COLOR = 0,
ONE_MINUS_DST_ALPHA = 0,
ONE_MINUS_DST_COLOR = 0,
}
}
/****************************************************
* macro
*****************************************************/
export namespace macro {
/** undefined */
export enum TextAlignment {
LEFT = 0,
CENTER = 0,
RIGHT = 0,
}
}
/****************************************************
* sys
*****************************************************/
export namespace sys {
/** !#en
Network type enumeration
!#zh
*/
export enum NetworkType {
NONE = 0,
LAN = 0,
WWAN = 0,
}
}
/****************************************************
* PhysicsManager
*****************************************************/
export namespace PhysicsManager {
/** !#en
The draw bits for drawing physics debug information.<br>
example:<br>
```js
cc.director.getPhysicsManager().debugDrawFlags =
// cc.PhysicsManager.DrawBits.e_aabbBit |
// cc.PhysicsManager.DrawBits.e_pairBit |
// cc.PhysicsManager.DrawBits.e_centerOfMassBit |
cc.PhysicsManager.DrawBits.e_jointBit |
cc.PhysicsManager.DrawBits.e_shapeBit;
```
!#zh
<br>
example:<br>
```js
cc.director.getPhysicsManager().debugDrawFlags =
// cc.PhysicsManager.DrawBits.e_aabbBit |
// cc.PhysicsManager.DrawBits.e_pairBit |
// cc.PhysicsManager.DrawBits.e_centerOfMassBit |
cc.PhysicsManager.DrawBits.e_jointBit |
cc.PhysicsManager.DrawBits.e_shapeBit;
``` */
export enum DrawBits {
e_aabbBit = 0,
e_jointBit = 0,
e_shapeBit = 0,
}
}
/****************************************************
* AnimationCurve
*****************************************************/
export namespace AnimationCurve {
/** !#en The wrap mode
!#zh */
export enum WrapMode {
Default = 0,
Once = 0,
Loop = 0,
PingPong = 0,
ClampForever = 0,
time = 0,
value = 0,
inTangent = 0,
outTangent = 0,
}
}
/****************************************************
* ParticleSystem3DAssembler
*****************************************************/
export namespace ParticleSystem3DAssembler {
/** undefined */
export enum Space {
}
}
/****************************************************
* ParticleSystem3DAssembler
*****************************************************/
export namespace ParticleSystem3DAssembler {
/** 粒子的生成模式 */
export enum RenderMode {
}
}
/****************************************************
* shapeModule
*****************************************************/
export namespace shapeModule {
/** 粒子发射器类型 */
export enum ShapeType {
Box = 0,
Circle = 0,
Cone = 0,
Sphere = 0,
Hemisphere = 0,
}
}
/****************************************************
* shapeModule
*****************************************************/
export namespace shapeModule {
/** 粒子从发射器的哪个部位发射 */
export enum EmitLocation {
Base = 0,
Edge = 0,
Shell = 0,
Volume = 0,
}
}
/****************************************************
* shapeModule
*****************************************************/
export namespace shapeModule {
/** 粒子在扇形区域的发射方式 */
export enum ArcMode {
Random = 0,
Loop = 0,
PingPong = 0,
}
}
/****************************************************
* trailModule
*****************************************************/
export namespace trailModule {
/** 选择如何为粒子系统生成轨迹 */
export enum TrailMode {
}
}
/****************************************************
* trailModule
*****************************************************/
export namespace trailModule {
/** 纹理填充模式 */
export enum TextureMode {
}
}
/****************************************************
* primitive
*****************************************************/
export namespace primitive {
/** undefined */
export enum PolyhedronType {
Tetrahedron = 0,
Octahedron = 0,
Dodecahedron = 0,
Icosahedron = 0,
Rhombicuboctahedron = 0,
TriangularPrism = 0,
PentagonalPrism = 0,
HexagonalPrism = 0,
SquarePyramid = 0,
PentagonalPyramid = 0,
TriangularDipyramid = 0,
PentagonalDipyramid = 0,
ElongatedSquareDipyramid = 0,
ElongatedPentagonalDipyramid = 0,
ElongatedPentagonalCupola = 0,
}
}
/****************************************************
* primitive
*****************************************************/
export namespace primitive {
/** undefined */
export class VertexData {
positions: number[];
normals: number[];
uvs: number[];
indices: number[];
minPos: Vec3;
maxPos: Vec3;
boundingRadius: number;
}
}
/****************************************************
* Material
*****************************************************/
export namespace Material {
/** !#en Material builtin name
!#zh */
export enum BUILTIN_NAME {
SPRITE = 0,
GRAY_SPRITE = 0,
UNLIT = 0,
}
}
/****************************************************
* EditBox
*****************************************************/
export namespace EditBox {
/** !#en Enum for keyboard return types
!#zh */
export enum KeyboardReturnType {
DEFAULT = 0,
DONE = 0,
SEND = 0,
SEARCH = 0,
GO = 0,
NEXT = 0,
}
}
/****************************************************
* EditBox
*****************************************************/
export namespace EditBox {
/** !#en The EditBox's InputMode defines the type of text that the user is allowed to enter.
!#zh */
export enum InputMode {
ANY = 0,
EMAIL_ADDR = 0,
NUMERIC = 0,
PHONE_NUMBER = 0,
URL = 0,
DECIMAL = 0,
SINGLE_LINE = 0,
}
}
/****************************************************
* EditBox
*****************************************************/
export namespace EditBox {
/** !#en Enum for the EditBox's input flags
!#zh */
export enum InputFlag {
PASSWORD = 0,
SENSITIVE = 0,
INITIAL_CAPS_WORD = 0,
INITIAL_CAPS_SENTENCE = 0,
INITIAL_CAPS_ALL_CHARACTERS = 0,
DEFAULT = 0,
}
}
/****************************************************
* textureAnimationModule
*****************************************************/
export namespace textureAnimationModule {
/** 粒子贴图动画类型 */
export enum Mode {
}
}
/****************************************************
* textureAnimationModule
*****************************************************/
export namespace textureAnimationModule {
/** 贴图动画的播放方式 */
export enum Animation {
}
}
}
/** !#en
The global main namespace of Spine, all classes, functions,
properties and constants of Spine are defined in this namespace
!#zh
Spine
Spine */
declare namespace sp {
/** !#en
The skeleton of Spine <br/>
<br/>
(Skeleton has a reference to a SkeletonData and stores the state for skeleton instance,
which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible. <br/>
Multiple skeletons can use the same SkeletonData which includes all animations, skins, and attachments.) <br/>
!#zh
Spine <br/>
<br/>
(Skeleton
slot slot attachments <br/>
Skeleton 使 attachments */
export class Skeleton extends cc.RenderComponent {
/** !#en The skeletal animation is paused?
!#zh */
paused: boolean;
/** !#en
The skeleton data contains the skeleton information (bind pose bones, slots, draw order,
attachments, skins, etc) and animations but does not hold any state.<br/>
Multiple skeletons can share the same skeleton data.
!#zh
slots
attachments<br/>
Skeleton */
skeletonData: SkeletonData;
/** !#en The name of default skin.
!#zh */
defaultSkin: string;
/** !#en The name of default animation.
!#zh */
defaultAnimation: string;
/** !#en The name of current playing animation.
!#zh */
animation: string;
_defaultSkinIndex: number;
/** !#en TODO
!#zh */
loop: boolean;
/** !#en Indicates whether to enable premultiplied alpha.
You should disable this option when image's transparent area appears to have opaque pixels,
or enable this option when image's half transparent area appears to be darken.
!#zh
*/
premultipliedAlpha: boolean;
/** !#en The time scale of this skeleton.
!#zh */
timeScale: number;
/** !#en Indicates whether open debug slots.
!#zh slot debug */
debugSlots: boolean;
/** !#en Indicates whether open debug bones.
!#zh bone debug */
debugBones: boolean;
/** !#en Indicates whether open debug mesh.
!#zh mesh debug */
debugMesh: boolean;
/** !#en Enabled two color tint.
!#zh */
useTint: boolean;
/** !#en Enabled batch model, if skeleton is complex, do not enable batch, or will lower performance.
!#zh drawcallcpu */
enableBatch: boolean;
/**
!#en
Sets runtime skeleton data to sp.Skeleton.<br>
This method is different from the `skeletonData` property. This method is passed in the raw data provided by the Spine runtime, and the skeletonData type is the asset type provided by Creator.
!#zh
SkeletonData<br>
`skeletonData` Spine runtime skeletonData Creator
@param skeletonData skeletonData
*/
setSkeletonData(skeletonData: sp.spine.SkeletonData): void;
/**
!#en Sets slots visible range.
!#zh
@param startSlotIndex startSlotIndex
@param endSlotIndex endSlotIndex
*/
setSlotsRange(startSlotIndex: number, endSlotIndex: number): void;
/**
!#en Sets animation state data.<br>
The parameter type is {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData.
!#zh <br>
{{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.AnimationStateData
@param stateData stateData
*/
setAnimationStateData(stateData: sp.spine.AnimationStateData): void;
/**
!#en
It's best to set cache mode before set property 'dragonAsset', or will waste some cpu time.
If set the mode in editor, then no need to worry about order problem.
!#zh
'dragonAsset'
@param cacheMode cacheMode
@example
```js
skeleton.setAnimationCacheMode(sp.Skeleton.AnimationCacheMode.SHARED_CACHE);
```
*/
setAnimationCacheMode(cacheMode: Skeleton.AnimationCacheMode): void;
/**
!#en Whether in cached mode.
!#zh
*/
isAnimationCached(): boolean;
/**
!#en Sets vertex effect delegate.
!#zh
@param effectDelegate effectDelegate
*/
setVertexEffectDelegate(effectDelegate: VertexEffectDelegate): void;
/**
!#en Computes the world SRT from the local SRT for each bone.
!#zh Transform
bone 使
@example
```js
var bone = spine.findBone('head');
cc.log(bone.worldX); // return 0;
spine.updateWorldTransform();
bone = spine.findBone('head');
cc.log(bone.worldX); // return -23.12;
```
*/
updateWorldTransform(): void;
/**
!#en Sets the bones and slots to the setup pose.
!#zh
*/
setToSetupPose(): void;
/**
!#en
Sets the bones to the setup pose,
using the values from the `BoneData` list in the `SkeletonData`.
!#zh
bone
使 SkeletonData BoneData
*/
setBonesToSetupPose(): void;
/**
!#en
Sets the slots to the setup pose,
using the values from the `SlotData` list in the `SkeletonData`.
!#zh
slot
使 SkeletonData SlotData
*/
setSlotsToSetupPose(): void;
/**
!#en
Updating an animation cache to calculate all frame data in the animation is a cost in
performance due to calculating all data in a single frame.
To update the cache, use the invalidAnimationCache method with high performance.
!#zh
,
使 invalidAnimationCache
@param animName animName
*/
updateAnimationCache(animName: string): void;
/**
!#en
Invalidates the animation cache, which is then recomputed on each frame..
!#zh
使
*/
invalidAnimationCache(): void;
/**
!#en
Finds a bone by name.
This does a string comparison for every bone.<br>
Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone object.
!#zh
bone
bone <br>
{{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Bone
@param boneName boneName
*/
findBone(boneName: string): sp.spine.Bone;
/**
!#en
Finds a slot by name. This does a string comparison for every slot.<br>
Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot object.
!#zh
slot slot <br>
{{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Slot
@param slotName slotName
*/
findSlot(slotName: string): sp.spine.Slot;
/**
!#en
Finds a skin by name and makes it the active skin.
This does a string comparison for every skin.<br>
Note that setting the skin does not change which attachments are visible.<br>
Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin object.
!#zh
<br>
attachment <br>
{{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Skin
@param skinName skinName
*/
setSkin(skinName: string): void;
/**
!#en
Returns the attachment for the slot and attachment name.
The skeleton looks first in its skin, then in the skeleton datas default skin.<br>
Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment object.
!#zh
slot attachment attachmentSkeleton Skeleton Data <br>
{{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.Attachment
@param slotName slotName
@param attachmentName attachmentName
*/
getAttachment(slotName: string, attachmentName: string): sp.spine.Attachment;
/**
!#en
Sets the attachment for the slot and attachment name.
The skeleton looks first in its skin, then in the skeleton datas default skin.
!#zh
slot attachment attachment
Skeleton Skeleton Data
@param slotName slotName
@param attachmentName attachmentName
*/
setAttachment(slotName: string, attachmentName: string): void;
/**
Return the renderer of attachment.
@param regionAttachment regionAttachment
*/
getTextureAtlas(regionAttachment: sp.spine.RegionAttachment|spine.BoundingBoxAttachment): sp.spine.TextureAtlasRegion;
/**
!#en
Mix applies all keyframe values,
interpolated for the specified time and mixed with the current values.
!#zh
@param fromAnimation fromAnimation
@param toAnimation toAnimation
@param duration duration
*/
setMix(fromAnimation: string, toAnimation: string, duration: number): void;
/**
!#en Set the current animation. Any queued animations are cleared.<br>
Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
!#zh <br>
{{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry
@param trackIndex trackIndex
@param name name
@param loop loop
*/
setAnimation(trackIndex: number, name: string, loop: boolean): sp.spine.TrackEntry;
/**
!#en Adds an animation to be played delay seconds after the current or last queued animation.<br>
Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
!#zh <br>
{{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry
@param trackIndex trackIndex
@param name name
@param loop loop
@param delay delay
*/
addAnimation(trackIndex: number, name: string, loop: boolean, delay?: number): sp.spine.TrackEntry;
/**
!#en Find animation with specified name.
!#zh
@param name name
*/
findAnimation(name: string): sp.spine.Animation;
/**
!#en Returns track entry by trackIndex.<br>
Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
!#zh track TrackEntry<br>
{{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry
@param trackIndex trackIndex
*/
getCurrent(trackIndex: any): sp.spine.TrackEntry;
/**
!#en Clears all tracks of animation state.
!#zh track
*/
clearTracks(): void;
/**
!#en Clears track of animation state by trackIndex.
!#zh track
@param trackIndex trackIndex
*/
clearTrack(trackIndex: number): void;
/**
!#en Set the start event listener.
!#zh
@param listener listener
*/
setStartListener(listener: Function): void;
/**
!#en Set the interrupt event listener.
!#zh
@param listener listener
*/
setInterruptListener(listener: Function): void;
/**
!#en Set the end event listener.
!#zh
@param listener listener
*/
setEndListener(listener: Function): void;
/**
!#en Set the dispose event listener.
!#zh
@param listener listener
*/
setDisposeListener(listener: Function): void;
/**
!#en Set the complete event listener.
!#zh
@param listener listener
*/
setCompleteListener(listener: Function): void;
/**
!#en Set the animation event listener.
!#zh
@param listener listener
*/
setEventListener(listener: Function): void;
/**
!#en Set the start event listener for specified TrackEntry.
!#zh TrackEntry
@param entry entry
@param listener listener
*/
setTrackStartListener(entry: sp.spine.TrackEntry, listener: Function): void;
/**
!#en Set the interrupt event listener for specified TrackEntry.
!#zh TrackEntry
@param entry entry
@param listener listener
*/
setTrackInterruptListener(entry: sp.spine.TrackEntry, listener: Function): void;
/**
!#en Set the end event listener for specified TrackEntry.
!#zh TrackEntry
@param entry entry
@param listener listener
*/
setTrackEndListener(entry: sp.spine.TrackEntry, listener: Function): void;
/**
!#en Set the dispose event listener for specified TrackEntry.
!#zh TrackEntry
@param entry entry
@param listener listener
*/
setTrackDisposeListener(entry: sp.spine.TrackEntry, listener: Function): void;
/**
!#en Set the complete event listener for specified TrackEntry.
!#zh TrackEntry
@param entry entry
@param listener listener
*/
setTrackCompleteListener(entry: sp.spine.TrackEntry, listener: (entry: sp.spine.TrackEntry, loopCount: number) => void): void;
/**
!#en Set the event listener for specified TrackEntry.
!#zh TrackEntry
@param entry entry
@param listener listener
*/
setTrackEventListener(entry: sp.spine.TrackEntry, listener: Function): void;
/**
!#en Get the animation state object
!#zh
*/
getState(): sp.spine.AnimationState;
}
/** !#en The skeleton data of spine.
!#zh Spine */
export class SkeletonData extends cc.Asset {
/** !#en See http://en.esotericsoftware.com/spine-json-format
!#zh Spine http://zh.esotericsoftware.com/spine-json-format */
skeletonJson: any;
atlasText: string;
textures: cc.Texture2D[];
/** !#en
A scale can be specified on the JSON or binary loader which will scale the bone positions,
image sizes, and animation translations.
This can be useful when using different sized images than were used when designing the skeleton
in Spine. For example, if using images that are half the size than were used in Spine,
a scale of 0.5 can be used. This is commonly used for games that can run with either low or high
resolution texture atlases.
see http://en.esotericsoftware.com/spine-using-runtimes#Scaling
!#zh Spine http://zh.esotericsoftware.com/spine-using-runtimes#Scaling */
scale: number;
/**
!#en Get the included SkeletonData used in spine runtime.<br>
Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData object.
!#zh Spine Runtime 使 SkeletonData<br>
{{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.SkeletonData
@param quiet quiet
*/
getRuntimeData(quiet?: boolean): sp.spine.SkeletonData;
}
/** !#en The event type of spine skeleton animation.
!#zh */
export enum AnimationEventType {
START = 0,
END = 0,
COMPLETE = 0,
EVENT = 0,
}
/** !#en
The delegate of spine vertex effect
!#zh
Spine */
export class VertexEffectDelegate {
/**
!#en Clears vertex effect.
!#zh
*/
clear(): void;
/**
!#en Inits delegate with jitter effect
!#zh
@param jitterX jitterX
@param jitterY jitterY
*/
initJitter(jitterX: number, jitterY: number): void;
/**
!#en Inits delegate with swirl effect
!#zh
@param radius radius
@param power power
*/
initSwirlWithPow(radius: number, power: number): sp.spine.JitterEffect;
/**
!#en Inits delegate with swirl effect
!#zh
@param radius radius
@param power power
*/
initSwirlWithPowOut(radius: number, power: number): sp.spine.SwirlEffect;
/**
!#en Gets jitter vertex effect
!#zh
*/
getJitterVertexEffect(): sp.spine.JitterEffect;
/**
!#en Gets swirl vertex effect
!#zh
*/
getSwirlVertexEffect(): sp.spine.SwirlEffect;
/**
!#en Gets vertex effect
!#zh
*/
getVertexEffect(): sp.spine.JitterEffect;
/**
!#en Gets effect type
!#zh
*/
getEffectType(): string;
}
/****************************************************
* sp
*****************************************************/
export namespace sp {
/** !#en Attach node tool
!#zh */
export class AttachUtil {
/**
!#en Gets attached root node.
!#zh
*/
getAttachedRootNode(): cc.Node;
/**
!#en Gets attached node which you want.
!#zh
@param boneName boneName
*/
getAttachedNodes(boneName: string): cc.Node[];
/**
!#en Destroy attached node which you want.
!#zh
@param boneName boneName
*/
destroyAttachedNodes(boneName: string): void;
/**
!#en Traverse all bones to generate the minimum node tree containing the given bone names, NOTE that make sure the skeleton has initialized before calling this interface.
!#zh
@param boneName boneName
*/
generateAttachedNodes(boneName: string): cc.Node[];
/**
!#en Destroy all attached node.
!#zh
*/
destroyAllAttachedNodes(): void;
/**
!#en Traverse all bones to generate a tree containing all bones nodes, NOTE that make sure the skeleton has initialized before calling this interface.
!#zh
*/
generateAllAttachedNodes(): cc.Node;
}
}
/****************************************************
* Skeleton
*****************************************************/
export namespace Skeleton {
/** !#en Enum for animation cache mode type.
!#zh Spine */
export enum AnimationCacheMode {
REALTIME = 0,
SHARED_CACHE = 0,
PRIVATE_CACHE = 0,
}
}
}
/** !#en
`sp.spine` is the namespace for official Spine Runtime, which officially implemented and maintained by Spine.<br>
Please refer to the official documentation for its detailed usage: [http://en.esotericsoftware.com/spine-using-runtimes](http://en.esotericsoftware.com/spine-using-runtimes)
!#zh
sp.spine Spine API Spine [http://zh.esotericsoftware.com/spine-using-runtimes](http://zh.esotericsoftware.com/spine-using-runtimes) */
declare namespace sp.spine {
}
/** !#en
The global main namespace of DragonBones, all classes, functions,
properties and constants of DragonBones are defined in this namespace
!#zh
DragonBones
DragonBones */
declare namespace dragonBones {
/** !#en
The Armature Display of DragonBones <br/>
<br/>
Armature Display has a reference to a DragonBonesAsset and stores the state for ArmatureDisplay instance,
which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible. <br/>
Multiple Armature Display can use the same DragonBonesAsset which includes all animations, skins, and attachments. <br/>
!#zh
DragonBones <br/>
<br/>
Armature Display
slot slot attachments <br/>
Armature Display 使 attachments<br/> */
export class ArmatureDisplay extends cc.RenderComponent {
/** !#en
The DragonBones data contains the armatures information (bind pose bones, slots, draw order,
attachments, skins, etc) and animations but does not hold any state.<br/>
Multiple ArmatureDisplay can share the same DragonBones data.
!#zh
slots
attachments<br/>
ArmatureDisplay */
dragonAsset: DragonBonesAsset;
/** !#en
The atlas asset for the DragonBones.
!#zh
Atlas Texture */
dragonAtlasAsset: DragonBonesAtlasAsset;
/** !#en The name of current armature.
!#zh Armature */
armatureName: string;
/** !#en The name of current playing animation.
!#zh */
animationName: string;
_defaultArmatureIndex: number;
/** !#en The time scale of this armature.
!#zh */
timeScale: number;
/** !#en The play times of the default animation.
-1 means using the value of config file;
0 means repeat for ever
>0 means repeat times
!#zh
-1 使;
0
>0 */
playTimes: number;
/** !#en Indicates whether to enable premultiplied alpha.
You should disable this option when image's transparent area appears to have opaque pixels,
or enable this option when image's half transparent area appears to be darken.
!#zh
*/
premultipliedAlpha: boolean;
/** !#en Indicates whether open debug bones.
!#zh bone debug */
debugBones: boolean;
/** !#en Enabled batch model, if skeleton is complex, do not enable batch, or will lower performance.
!#zh drawcallcpu */
enableBatch: boolean;
/**
!#en
The key of dragonbones cache data, which is regard as 'dragonbonesName', when you want to change dragonbones cloth.
!#zh
key使dragonbonesName使
@example
```js
let factory = dragonBones.CCFactory.getInstance();
let needChangeSlot = needChangeArmature.armature().getSlot("changeSlotName");
factory.replaceSlotDisplay(toChangeArmature.getArmatureKey(), "armatureName", "slotName", "displayName", needChangeSlot);
```
*/
getArmatureKey(): string;
/**
!#en
It's best to set cache mode before set property 'dragonAsset', or will waste some cpu time.
If set the mode in editor, then no need to worry about order problem.
!#zh
'dragonAsset'
@param cacheMode cacheMode
@example
```js
armatureDisplay.setAnimationCacheMode(dragonBones.ArmatureDisplay.AnimationCacheMode.SHARED_CACHE);
```
*/
setAnimationCacheMode(cacheMode: ArmatureDisplay.AnimationCacheMode): void;
/**
!#en Whether in cached mode.
!#zh
*/
isAnimationCached(): boolean;
/**
!#en
Play the specified animation.
Parameter animName specify the animation name.
Parameter playTimes specify the repeat times of the animation.
-1 means use the value of the config file.
0 means play the animation for ever.
>0 means repeat times.
!#zh
.
animName
playTimes
-1 使
0
>0
@param animName animName
@param playTimes playTimes
*/
playAnimation(animName: string, playTimes: number): dragonBones.AnimationState;
/**
!#en
Updating an animation cache to calculate all frame data in the animation is a cost in
performance due to calculating all data in a single frame.
To update the cache, use the invalidAnimationCache method with high performance.
!#zh
,
使 invalidAnimationCache
@param animName animName
*/
updateAnimationCache(animName: string): void;
/**
!#en
Invalidates the animation cache, which is then recomputed on each frame..
!#zh
使
*/
invalidAnimationCache(): void;
/**
!#en
Get the all armature names in the DragonBones Data.
!#zh
DragonBones armature
*/
getArmatureNames(): any[];
/**
!#en
Get the all animation names of specified armature.
!#zh
armature
@param armatureName armatureName
*/
getAnimationNames(armatureName: string): any[];
/**
!#en
Add event listener for the DragonBones Event, the same to addEventListener.
!#zh
DragonBones addEventListener
@param type A string representing the event type to listen for.
@param listener The callback that will be invoked when the event is dispatched.
@param target The target (this object) to invoke the callback, can be null
*/
on(type: string, listener: (event: cc.Event) => void, target?: any): void;
/**
!#en
Remove the event listener for the DragonBones Event, the same to removeEventListener.
!#zh
DragonBones removeEventListener
@param type A string representing the event type to listen for.
@param listener listener
@param target target
*/
off(type: string, listener?: Function, target?: any): void;
/**
!#en
Add DragonBones one-time event listener, the callback will remove itself after the first time it is triggered.
!#zh
DragonBones
@param type A string representing the event type to listen for.
@param listener The callback that will be invoked when the event is dispatched.
@param target The target (this object) to invoke the callback, can be null
*/
once(type: string, listener: (event: cc.Event) => void, target?: any): void;
/**
!#en
Add event listener for the DragonBones Event.
!#zh
DragonBones
@param type A string representing the event type to listen for.
@param listener The callback that will be invoked when the event is dispatched.
@param target The target (this object) to invoke the callback, can be null
*/
addEventListener(type: string, listener: (event: cc.Event) => void, target?: any): void;
/**
!#en
Remove the event listener for the DragonBones Event.
!#zh
DragonBones
@param type A string representing the event type to listen for.
@param listener listener
@param target target
*/
removeEventListener(type: string, listener?: Function, target?: any): void;
/**
!#en
Build the armature for specified name.
!#zh
armature
@param armatureName armatureName
@param node node
*/
buildArmature(armatureName: string, node: cc.Node): ArmatureDisplay;
/**
!#en
Get the current armature object of the ArmatureDisplay.
!#zh
ArmatureDisplay 使 Armature
*/
armature(): any;
}
/** DragonBones factory */
export class CCFactory extends BaseFactory {
/**
@example
```js
let factory = dragonBones.CCFactory.getInstance();
```
*/
static getInstance(): CCFactory;
}
/** !#en The skeleton data of dragonBones.
!#zh dragonBones */
export class DragonBonesAsset extends cc.Asset {
/** !#en See http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html
!#zh DragonBones http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/dataFormat/index.html */
dragonBonesJson: string;
}
/** !#en The skeleton atlas data of dragonBones.
!#zh dragonBones */
export class DragonBonesAtlasAsset extends cc.Asset {
atlasJson: string;
texture: cc.Texture2D;
}
/****************************************************
* ArmatureDisplay
*****************************************************/
export namespace ArmatureDisplay {
/** !#en Enum for cache mode type.
!#zh Dragonbones */
export enum AnimationCacheMode {
REALTIME = 0,
SHARED_CACHE = 0,
PRIVATE_CACHE = 0,
}
}
/****************************************************
* dragonBones
*****************************************************/
export namespace dragonBones {
/** !#en Attach node tool
!#zh */
export class AttachUtil {
/**
!#en Gets attached root node.
!#zh
*/
getAttachedRootNode(): cc.Node;
/**
!#en Gets attached node which you want.
!#zh
@param boneName boneName
*/
getAttachedNodes(boneName: string): cc.Node[];
/**
!#en Destroy attached node which you want.
!#zh
@param boneName boneName
*/
destroyAttachedNodes(boneName: string): void;
/**
!#en Traverse all bones to generate the minimum node tree containing the given bone names, NOTE that make sure the skeleton has initialized before calling this interface.
!#zh
@param boneName boneName
*/
generateAttachedNodes(boneName: string): cc.Node[];
/**
!#en Destroy all attached node.
!#zh
*/
destroyAllAttachedNodes(): void;
/**
!#en Traverse all bones to generate a tree containing all bones nodes, NOTE that make sure the skeleton has initialized before calling this interface.
!#zh
*/
generateAllAttachedNodes(): cc.Node;
}
}
}
/** !#en
This module controls asset's behaviors and information, include loading, releasing etc.
All member can be accessed with `cc.assetManager`. All class or enum can be accessed with `cc.AssetManager`
!#zh
`cc.assetManager` . `cc.AssetManager` 访 */
declare namespace cc.AssetManager {
/** !#en
This module contains the builtin asset, it's a singleton, all member can be accessed with `cc.assetManager.builtins`
!#zh
`cc.assetManager.builtins` 访 */
export class Builtins {
/**
!#en
Initialize
!#zh
@param cb Callback when finish loading built-in assets
*/
init (cb: () => void): void;
/**
!#en
Get the built-in asset using specific type and name.
!#zh
@param type The type of asset, such as `effect`
@param name The name of asset, such as `phong`
@example
```js
cc.assetManaer.builtins.getBuiltin('effect', 'phone');
```
*/
getBuiltin(type?: string, name?: string): cc.Asset | Cache<cc.Asset>;
/**
!#en
Clear all builtin assets
!#zh
*/
clear(): void;
}
/** !#en
A bundle contains an amount of assets(includes scene), you can load, preload, release asset which is in this bundle
!#zh
*/
export class Bundle {
/**
!#en
Create a bundle
!#zh
bundle
*/
constructor();
/** !#en
The name of this bundle
!#zh
bundle */
name: string;
/** !#en
The dependency of this bundle
!#zh
bundle */
deps: string[];
/** !#en
The root path of this bundle, such like 'http://example.com/bundle1'
!#zh
bundle , 'http://example.com/bundle1' */
base: string;
/**
!#en
Get asset's info using path, only valid when asset is in bundle folder.
!#zh
使 path
@param path The relative path of asset, such as 'images/a'
@param type The constructor of asset, such as `cc.Texture2D`
@example
```js
var info = bundle.getInfoWithPath('image/a', cc.Texture2D);
```
*/
getInfoWithPath (path: string, type?: typeof cc.Asset): Record<string, any>;
/**
!#en
Get all asset's info within specific folder
!#zh
@param path The relative path of folder, such as 'images'
@param type The constructor should be used to filter paths
@param out The output array
@example
```js
var infos = [];
bundle.getDirWithPath('images', cc.Texture2D, infos);
```
*/
getDirWithPath (path: string, type: typeof cc.Asset, out: Array<Record<string, any>>): Array<Record<string, any>>;
getDirWithPath (path: string, type: typeof cc.Asset): Array<Record<string, any>>;
getDirWithPath (path: string): Array<Record<string, any>>;
/**
!#en
Get asset's info with uuid
!#zh
uuid
@param uuid The asset's uuid
@example
```js
var info = bundle.getAssetInfo('fcmR3XADNLgJ1ByKhqcC5Z');
```
*/
getAssetInfo (uuid: string): Record<string, any>;
/**
!#en
Get scene'info with name
!#zh
@param name The name of scene
@example
```js
var info = bundle.getSceneInfo('first.fire');
```
*/
getSceneInfo(name: string): Record<string, any>;
/**
!#en
Initialize this bundle with options
!#zh
bundle
@param options options
*/
init(options: Record<string, any>): void;
/**
!#en
Load the asset within this bundle by the path which is relative to bundle's path
!#zh
@param paths Paths of the target assets.The path is relative to the bundle's folder, extensions must be omitted.
@param type Only asset of type will be loaded if this argument is supplied.
@param onProgress Callback invoked when progression change.
@param onComplete Callback invoked when all assets loaded.
@example
```js
// load the texture (${project}/assets/resources/textures/background.jpg) from resources
cc.resources.load('textures/background', cc.Texture2D, (err, texture) => console.log(err));
// load the audio (${project}/assets/resources/music/hit.mp3) from resources
cc.resources.load('music/hit', cc.AudioClip, (err, audio) => console.log(err));
// load the prefab (${project}/assets/bundle1/misc/character/cocos) from bundle1 folder
bundle1.load('misc/character/cocos', cc.Prefab, (err, prefab) => console.log(err));
// load the sprite frame (${project}/assets/some/xxx/bundle2/imgs/cocos.png) from bundle2 folder
bundle2.load('imgs/cocos', cc.SpriteFrame, null, (err, spriteFrame) => console.log(err));
```
*/
load<T extends cc.Asset>(paths: string, type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: T) => void): void;
load<T extends cc.Asset>(paths: string[], type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array<T>) => void): void;
load<T extends cc.Asset>(paths: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: T) => void): void;
load<T extends cc.Asset>(paths: string[], onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array<T>) => void): void;
load<T extends cc.Asset>(paths: string, type: typeof cc.Asset, onComplete?: (error: Error, assets: T) => void): void;
load<T extends cc.Asset>(paths: string[], type: typeof cc.Asset, onComplete?: (error: Error, assets: Array<T>) => void): void;
load<T extends cc.Asset>(paths: string, onComplete?: (error: Error, assets: T) => void): void;
load<T extends cc.Asset>(paths: string[], onComplete?: (error: Error, assets: Array<T>) => void): void;
/**
!#en
Preload the asset within this bundle by the path which is relative to bundle's path.
After calling this method, you still need to finish loading by calling `Bundle.load`.
It will be totally fine to call `Bundle.load` at any time even if the preloading is not
yet finished
!#zh
`Bundle.load`
`Bundle.load`
@param paths Paths of the target asset.The path is relative to bundle folder, extensions must be omitted.
@param type Only asset of type will be loaded if this argument is supplied.
@param onProgress Callback invoked when progression change.
@param onComplete Callback invoked when the resource loaded.
@example
```js
// preload the texture (${project}/assets/resources/textures/background.jpg) from resources
cc.resources.preload('textures/background', cc.Texture2D);
// preload the audio (${project}/assets/resources/music/hit.mp3) from resources
cc.resources.preload('music/hit', cc.AudioClip);
// wait for while
cc.resources.load('music/hit', cc.AudioClip, (err, audioClip) => {});
* // preload the prefab (${project}/assets/bundle1/misc/character/cocos) from bundle1 folder
bundle1.preload('misc/character/cocos', cc.Prefab);
// load the sprite frame of (${project}/assets/bundle2/imgs/cocos.png) from bundle2 folder
bundle2.preload('imgs/cocos', cc.SpriteFrame);
// wait for while
bundle2.load('imgs/cocos', cc.SpriteFrame, (err, spriteFrame) => {});
```
*/
preload(paths: string|string[], type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void;
preload(paths: string|string[], onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void;
preload(paths: string|string[], type: typeof cc.Asset, onComplete: (error: Error, items: RequestItem[]) => void): void;
preload(paths: string|string[], type: typeof cc.Asset): void;
preload(paths: string|string[], onComplete: (error: Error, items: RequestItem[]) => void): void;
preload(paths: string|string[]): void;
/**
!#en
Load all assets under a folder inside the bundle folder.<br>
<br>
Note: All asset paths in Creator use forward slashes, paths using backslashes will not work.
!#zh
, 使
@param dir path of the target folder.The path is relative to the bundle folder, extensions must be omitted.
@param type Only asset of type will be loaded if this argument is supplied.
@param onProgress Callback invoked when progression change.
@param onComplete A callback which is called when all assets have been loaded, or an error occurs.
@example
```js
// load all audios (resources/audios/)
cc.resources.loadDir('audios', cc.AudioClip, (err, audios) => {});
// load all textures in "resources/imgs/"
cc.resources.loadDir('imgs', cc.Texture2D, null, function (err, textures) {
var texture1 = textures[0];
var texture2 = textures[1];
});
// load all prefabs (${project}/assets/bundle1/misc/characters/) from bundle1 folder
bundle1.loadDir('misc/characters', cc.Prefab, (err, prefabs) => console.log(err));
// load all sprite frame (${project}/assets/some/xxx/bundle2/skills/) from bundle2 folder
bundle2.loadDir('skills', cc.SpriteFrame, null, (err, spriteFrames) => console.log(err));
```
*/
loadDir<T extends cc.Asset>(dir: string, type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array<T>) => void): void;
loadDir<T extends cc.Asset>(dir: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, assets: Array<T>) => void): void;
loadDir<T extends cc.Asset>(dir: string, type: typeof cc.Asset, onComplete: (error: Error, assets: Array<T>) => void): void;
loadDir<T extends cc.Asset>(dir: string, type: typeof cc.Asset): void;
loadDir<T extends cc.Asset>(dir: string, onComplete: (error: Error, assets: Array<T>) => void): void;
loadDir<T extends cc.Asset>(dir: string): void;
/**
!#en
Preload all assets under a folder inside the bundle folder.<br> After calling this method, you still need to finish loading by calling `Bundle.loadDir`.
It will be totally fine to call `Bundle.loadDir` at any time even if the preloading is not yet finished
!#zh
`Bundle.loadDir`
`Bundle.loadDir`
@param dir path of the target folder.The path is relative to the bundle folder, extensions must be omitted.
@param type Only asset of type will be preloaded if this argument is supplied.
@param onProgress Callback invoked when progression change.
@param onComplete A callback which is called when all assets have been loaded, or an error occurs.
@example
```js
// preload all audios (resources/audios/)
cc.resources.preloadDir('audios', cc.AudioClip);
// preload all textures in "resources/imgs/"
cc.resources.preloadDir('imgs', cc.Texture2D);
// wait for while
cc.resources.loadDir('imgs', cc.Texture2D, (err, textures) => {});
// preload all prefabs (${project}/assets/bundle1/misc/characters/) from bundle1 folder
bundle1.preloadDir('misc/characters', cc.Prefab);
// preload all sprite frame (${project}/assets/some/xxx/bundle2/skills/) from bundle2 folder
bundle2.preloadDir('skills', cc.SpriteFrame);
// wait for while
bundle2.loadDir('skills', cc.SpriteFrame, (err, spriteFrames) => {});
```
*/
preloadDir(dir: string, type: typeof cc.Asset, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void;
preloadDir(dir: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, items: RequestItem[]) => void): void;
preloadDir(dir: string, type: typeof cc.Asset, onComplete: (error: Error, items: RequestItem[]) => void): void;
preloadDir(dir: string, type: typeof cc.Asset): void;
preloadDir(dir: string, onComplete: (error: Error, items: RequestItem[]) => void): void;
preloadDir(dir: string): void;
/**
!#en
Loads the scene within this bundle by its name.
!#zh
@param sceneName The name of the scene to load.
@param options Some optional parameters
@param onProgress Callback invoked when progression change.
@param onComplete callback, will be called after scene launched.
@example
```js
bundle1.loadScene('first', (err, sceneAsset) => cc.director.runScene(sceneAsset));
```
*/
loadScene(sceneName: string, options: Record<string, any>, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void;
loadScene(sceneName: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void;
loadScene(sceneName: string, options: Record<string, any>, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void;
loadScene(sceneName: string, onComplete: (error: Error, sceneAsset: cc.SceneAsset) => void): void;
loadScene(sceneName: string, options: Record<string, any>): void;
loadScene(sceneName: string): void;
/**
!#en
Preloads the scene within this bundle by its name. After calling this method, you still need to finish loading by calling `Bundle.loadScene` or `cc.director.loadScene`.
It will be totally fine to call `Bundle.loadDir` at any time even if the preloading is not yet finished
!#zh
. `Bundle.loadScene` `cc.director.loadScene`
`Bundle.loadScene` `cc.director.loadScene`
@param sceneName The name of the scene to preload.
@param options Some optional parameters
@param onProgress callback, will be called when the load progression change.
@param onComplete callback, will be called after scene loaded.
@example
```js
bundle1.preloadScene('first');
// wait for a while
bundle1.loadScene('first', (err, scene) => cc.director.runScene(scene));
```
*/
preloadScene(sceneName: string, options: Record<string, any>, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error) => void): void;
preloadScene(sceneName: string, onProgress: (finish: number, total: number, item: RequestItem) => void, onComplete: (error: Error) => void): void;
preloadScene(sceneName: string, options: Record<string, any>, onComplete: (error: Error) => void): void;
preloadScene(sceneName: string, onComplete: (error: Error) => void): void;
preloadScene(sceneName: string, options: Record<string, any>): void;
preloadScene(sceneName: string): void;
/**
!#en
Get asset within this bundle by path and type. <br>
After you load asset with {{#crossLink "Bundle/load:method"}}{{/crossLink}} or {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}},
you can acquire them by passing the path to this API.
!#zh
使 {{#crossLink "Bundle/load:method"}}{{/crossLink}} {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}}
API
@param path The path of asset
@param type Only asset of type will be returned if this argument is supplied.
@example
```js
bundle1.get('music/hit', cc.AudioClip);
```
*/
get<T extends cc.Asset> (path: string, type?: typeof cc.Asset): T;
/**
!#en
Release the asset loaded by {{#crossLink "Bundle/load:method"}}{{/crossLink}} or {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} and it's dependencies.
Refer to {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}} for detailed informations.
!#zh
{{#crossLink "Bundle/load:method"}}{{/crossLink}} {{#crossLink "Bundle/loadDir:method"}}{{/crossLink}} {{#crossLink "AssetManager/releaseAsset:method"}}{{/crossLink}}
@param path The path of asset
@param type Only asset of type will be released if this argument is supplied.
@example
```js
// release a texture which is no longer need
bundle1.release('misc/character/cocos');
```
*/
release(path: string, type: typeof cc.Asset): void;
release(path: string): void;
/**
!#en
Release all assets within this bundle. Refer to {{#crossLink "AssetManager/releaseAll:method"}}{{/crossLink}} for detailed informations.
!#zh
{{#crossLink "AssetManager/releaseAll:method"}}{{/crossLink}}
@example
```js
// release all asset within bundle1
bundle1.releaseAll();
```
*/
releaseAll(): void;
}
/** !#en
Cache manager is a module which controls all caches downloaded from server in non-web platform, it is a singleton
All member can be accessed with `cc.assetManager.cacheManager`.
!#zh
WEB `cc.assetManager.cacheManager` 访 */
export class CacheManager {
/** !#en
The name of cacheDir
!#zh
*/
cacheDir: string;
/** !#en
Whether or not cache asset into user's storage space, this property only works on mini-game platforms
!#zh
*/
cacheEnabled: boolean;
/** !#en
Whether or not auto clear cache when storage ran out, this property only works on mini-game platforms
!#zh
*/
autoClear: boolean;
/** !#en
The interval between caching resources, this property only works on mini-game platforms, unit: ms
!#zh
ms */
cacheInterval: number;
/** !#en
The interval between deleting resources, when you use `cleanLRU`, the resources will be deleted as this interval, unit: ms
!#zh
使 `cleanLRU` ms */
deleteInterval: number;
/** !#en
List of all cached files
!#zh
*/
cachedFiles: Cache<{ bundle: string, url: string, lastTime: number }>;
/**
!#en
Get cached path with origin url
!#zh
url
@param originUrl originUrl
*/
getCache(originUrl: string): string;
/**
!#en
Get temporary path with origin url, this method only works on mini-game platforms
!#zh
url
@param originUrl originUrl
*/
getTemp(originUrl: string): string;
/**
!#en
Clear all caches, please use with caution, If necessary, we recommend using it before the game is launched
!#zh
使使
*/
clearCache(): void;
/**
!#en
Clear part of caches with LRU strategy
!#zh
使 LRU
*/
clearLRU(): void;
/**
!#en
Remove cache with origin url
!#zh
url
*/
removeCache(): void;
}
/** !#en
use to cache something
!#zh
*/
export class Cache<T = any> {
/**
!#en
Create a cache
!#zh
cache
@param map An object used to initialize
*/
constructor(map?: Record<string, T>);
/**
!#en
Add Key-Value to cache
!#zh
@param key The key
@param val The value
@example
```js
var cache = new Cache();
cache.add('test', null);
```
*/
add(key: string, val: T): T;
/**
!#en
Get the cached content by key
!#zh
key value
@param key The key
@example
```js
var cache = new Cache();
var test = cache.get('test');
```
*/
get(key: string): T;
/**
!#en
Check whether or not content exists by key
!#zh
Key
@param key The key
@example
```js
var cache = new Cache();
var exist = cache.has('test');
```
*/
has(key: string): boolean;
/**
!#en
Remove the cached content by key
!#zh
Key
@param key The key
@example
```js
var cache = new Cache();
var content = cache.remove('test');
```
*/
remove(key: string): T;
/**
!#en
Clear all content
!#zh
@example
```js
var cache = new Cache();
cache.clear();
```
*/
clear():void;
/**
!#en
Enumerate all content and invoke function
!#zh
@param func Function to be invoked
@example
```js
var cache = new Cache();
cache.forEach((val, key) => console.log(key));
```
*/
forEach(func: (val: T, key: string) => void): void;
/**
!#en
Enumerate all content to find one element which can fulfill condition
!#zh
@param predicate The condition
@example
```js
var cache = new Cache();
var val = cache.find((val, key) => key === 'test');
```
*/
find(predicate: (val: T, key: string) => boolean): T;
/** !#en
The count of cached content
!#zh
*/
count: number;
/**
!#en
Destroy this cache
!#zh
cache
*/
destroy(): void;
}
/** !#en
Control asset's dependency list, it is a singleton. All member can be accessed with `cc.assetManager.dependUtil`
!#zh
, `cc.assetManager.dependUtil` 访 */
export class DependUtil {
/**
!#en
Get asset's native dependency. For example, Texture's native dependency is image.
!#zh
Texture
@param uuid asset's uuid
@example
```js
var dep = dependUtil.getNativeDep('fcmR3XADNLgJ1ByKhqcC5Z');
```
*/
getNativeDep(uuid: string): Record<string, any>;
/**
!#en
Get asset's direct referencing non-native dependency list. For example, Material's non-native dependencies are Texture.
!#zh
Texture
@param uuid asset's uuid
@example
```js
var deps = dependUtil.getDeps('fcmR3XADNLgJ1ByKhqcC5Z');
```
*/
getDeps(uuid: string): string[];
/**
!#en
Get non-native dependency list of the loaded asset, include indirect reference.
The returned array stores the dependencies with their uuid, after retrieve dependencies,
!#zh
uuid
@param uuid The asset's uuid
@example
```js
var deps = dependUtil.getDepsRecursively('fcmR3XADNLgJ1ByKhqcC5Z');
```
*/
getDepsRecursively(uuid: string): string[];
}
/** !#en
Control all download process, it is a singleton. All member can be accessed with `cc.assetManager.downloader` , it can download several types of files:
1. Text
2. Image
3. Audio
4. Assets
5. Scripts
!#zh
downloader `cc.assetManager.downloader` 访
1.
2.
3.
4.
5. */
export class Downloader {
/** !#en
The address of remote server
!#zh
*/
remoteServerAddress: string;
/** !#en
The maximum number of concurrent when downloading
!#zh
*/
maxConcurrency: number;
/** !#en
The maximum number of request can be launched per frame when downloading
!#zh
*/
maxRequestsPerFrame: number;
/** !#en
The max number of retries when fail
!#zh
*/
maxRetryCount: number;
/** !#en
Wait for while before another retry, unit: ms
!#zh
*/
retryInterval: number;
/**
!#en
Register custom handler if you want to change default behavior or extend downloader to download other format file
!#zh
downloader handler
@param type Extension likes '.jpg' or map likes {'.jpg': jpgHandler, '.png': pngHandler}
@param handler handler
@example
```js
downloader.register('.tga', (url, options, onComplete) => onComplete(null, null));
downloader.register({'.tga': (url, options, onComplete) => onComplete(null, null), '.ext': (url, options, onComplete) => onComplete(null, null)});
```
*/
register(type: string, handler: (url: string, options: Record<string, any>, onComplete: (err: Error, content: any) => void) => void): void;
register(map: Record<string, (url: string, options: Record<string, any>, onComplete: (err: Error, content: any) => void) => void>): void;
/**
!#en
Use corresponding handler to download file under limitation
!#zh
使 handler
@param url The url should be downloaded
@param type The type indicates that which handler should be used to download, such as '.jpg'
@param options some optional paramters will be transferred to the corresponding handler.
@param onComplete callback when finishing downloading
@example
```js
download('http://example.com/test.tga', '.tga', {onFileProgress: (loaded, total) => console.lgo(loaded/total)}, onComplete: (err) => console.log(err));
```
*/
download(id: string, url: string, type: string, options: Record<string, any>, onComplete: (err: Error, content: any) => void): void;
}
/** !#en
Provide some helpful function, it is a singleton. All member can be accessed with `cc.assetManager.utils`
!#zh
helper , `cc.assetManager.utils` 访 */
export class Helper {
/**
!#en
Decode uuid, returns the original uuid
!#zh
uuid uuid
@param base64 the encoded uuid
@example
```js
var uuid = 'fcmR3XADNLgJ1ByKhqcC5Z';
var originalUuid = decodeUuid(uuid); // fc991dd7-0033-4b80-9d41-c8a86a702e59
```
*/
decodeUuid(base64: string): string;
/**
!#en
Extract uuid from url
!#zh
url uuid
@param url url
@example
```js
var url = 'assets/main/import/fc/fc991dd7-0033-4b80-9d41-c8a86a702e59.json';
var uuid = getUuidFromURL(url); // fc991dd7-0033-4b80-9d41-c8a86a702e59
```
*/
getUuidFromURL(url: string): string;
/**
!#en
Transform uuid to url
!#zh
uuid url
@param uuid The uuid of asset
@param options Some optional parameters
@example
```js
// json path, 'assets/main/import/fc/fc991dd7-0033-4b80-9d41-c8a86a702e59.json';
var url = getUrlWithUuid('fcmR3XADNLgJ1ByKhqcC5Z', {isNative: false});
// png path, 'assets/main/native/fc/fc991dd7-0033-4b80-9d41-c8a86a702e59.png';
var url = getUrlWithUuid('fcmR3XADNLgJ1ByKhqcC5Z', {isNative: true, nativeExt: '.png'});
```
*/
getUrlWithUuid(uuid: string, options?: Record<string, any>): string;
/**
!#en
Check if the type of asset is scene
!#zh
@param asset asset
*/
isScene(asset: any): boolean;
/**
!#en
Normalize url, strip './' and '/'
!#zh
url './' '/'
@param url url
*/
normalize(url: string): string;
}
/** !#en
Handle the packed asset, include unpacking, loading, cache and so on. It is a singleton. All member can be accessed with `cc.assetManager.packManager`
!#zh
, `cc.assetManager.packManager` 访 */
export class PackManager {
/**
!#en
Unpack the json, revert to what it was before packing
!#zh
json
@param pack The pack
@param json The content of pack
@param options Some optional parameters
@param onComplete Callback when finish unpacking
@example
```js
downloader.downloadFile('pack.json', {responseType: 'json'}, null, (err, file) => {
packManager.unpackJson(['a', 'b'], file, null, (err, data) => console.log(err));
});
```
*/
unpackJson(pack: string[], json: any, options: Record<string, any>, onComplete?: (err: Error, content: any) => void): void;
/**
!#en
Register custom handler if you want to change default behavior or extend packManager to unpack other format pack
!#zh
packManager handler
@param type Extension likes '.bin' or map likes {'.bin': binHandler, '.ab': abHandler}
@param handler handler
@example
```js
packManager.register('.bin', (packUuid, file, options, onComplete) => onComplete(null, null));
packManager.register({'.bin': (packUuid, file, options, onComplete) => onComplete(null, null), '.ab': (packUuid, file, options, onComplete) => onComplete(null, null)});
```
*/
register(type: string, handler: (packUuid: string, data: any, options: Record<string, any>, onComplete: (err: Error, content: any) => void) => void): void;
register(map: Record<string, (packUuid: string, data: any, options: Record<string, any>, onComplete: (err: Error, content: any) => void) => void>): void;
/**
!#en
Use corresponding handler to unpack package
!#zh
handler
@param pack The uuid of packed assets
@param data The packed data
@param type The type indicates that which handler should be used to download, such as '.jpg'
@param options Some optional parameter
@param onComplete callback when finishing unpacking
@example
```js
downloader.downloadFile('pack.json', {responseType: 'json'}, null, (err, file) => {
packManager.unpack(['2fawq123d', '1zsweq23f'], file, '.json', null, (err, data) => console.log(err));
});
```
*/
unpack(pack: string[], data: any, type: string, options: Record<string, any>, onComplete?: (err: Error, data: any) => void): void;
/**
!#en
Download request item, If item is not in any package, download as usual. Otherwise, download the corresponding package and unpack it.
And then retrieve the corresponding content form it.
!#zh
package
@param item Some item you want to download
@param options Some optional parameters
@param onComplete Callback when finished
@example
```js
var requestItem = cc.AssetManager.RequestItem.create();
requestItem.uuid = 'fcmR3XADNLgJ1ByKhqcC5Z';
requestItem.info = config.getAssetInfo('fcmR3XADNLgJ1ByKhqcC5Z');
packManager.load(requestItem, null, (err, data) => console.log(err));
```
*/
load(item: RequestItem, options: Record<string, any>, onComplete: (err: Error, data: any) => void): void;
}
/** !#en
Parse the downloaded file, it's a singleton, all member can be accessed with `cc.assetManager.parser`
!#zh
parser , `cc.assetManaager.parser` 访 */
export class Parser {
/**
!#en
Register custom handler if you want to change default behavior or extend parser to parse other format file
!#zh
parser handler
@param type Extension likes '.jpg' or map likes {'.jpg': jpgHandler, '.png': pngHandler}
@param handler The corresponding handler
@example
```js
parser.register('.tga', (file, options, onComplete) => onComplete(null, null));
parser.register({'.tga': (file, options, onComplete) => onComplete(null, null), '.ext': (file, options, onComplete) => onComplete(null, null)});
```
*/
register(type: string, handler: (file: any, options: Record<string, any>, onComplete: (err: Error, data: any) => void) => void): void;
register(map: Record<string, (file: any, options: Record<string, any>, onComplete: (err: Error, data: any) => void) => void>): void;
/**
!#en
Use corresponding handler to parse file
!#zh
使handler
@param id The id of file
@param file File
@param type The corresponding type of file, likes '.jpg'.
@param options Some optional paramters will be transferred to the corresponding handler.
@param onComplete callback when finishing downloading
@example
```js
downloader.downloadFile('test.jpg', {responseType: 'blob'}, null, (err, file) => {
parser.parse('test.jpg', file, '.jpg', null, (err, img) => console.log(err));
});
```
*/
parse(id: string, file: any, type: string, options: Record<string, any>, onComplete: (err: Error, content: any) => void): void;
}
/** !#en
Pipeline can execute the task for some effect.
!#zh
线 */
export class Pipeline {
/** !#en
The id of pipeline
!#zh
线 id */
id: number;
/** !#en
The name of pipeline
!#zh
线 */
name: string;
/** !#en
All pipes of pipeline
!#zh
*/
pipes: Function[];
/**
!#en
Create a new pipeline
!#zh
线
@param name The name of pipeline
@param funcs The array of pipe, every pipe must be function which take two parameters, the first is a `Task` flowed in pipeline, the second is complete callback
@example
```js
var pipeline = new Pipeline('download', [
(task, done) => {
var url = task.input;
cc.assetManager.downloader.downloadFile(url, null, null, (err, result) => {
task.output = result;
done(err);
});
},
(task, done) => {
var text = task.input;
var json = JSON.stringify(text);
task.output = json;
done();
}
]);
```
*/
constructor(name: string, funcs: Array<(task: Task, done?: (err: Error) => void) => void>);
/**
!#en
At specific point insert a new pipe to pipeline
!#zh
线 pipe
@param func The new pipe
@param index The specific point you want to insert at.
@example
```js
var pipeline = new Pipeline('test', []);
pipeline.insert((task, done) => {
// do something
done();
}, 0);
```
*/
insert(func: (task: Task, callback?: (err: Error) => void) => void, index: number): Pipeline;
/**
!#en
Append a new pipe to the pipeline
!#zh
线
@param func The new pipe
@example
```js
var pipeline = new Pipeline('test', []);
pipeline.append((task, done) => {
// do something
done();
});
```
*/
append(func: (task: Task, callback?: (err: Error) => void) => void): Pipeline;
/**
!#en
Remove pipe which at specific point
!#zh
@param index The specific point
@example
```js
var pipeline = new Pipeline('test', (task, done) => {
// do something
done();
});
pipeline.remove(0);
```
*/
remove(index: number): Pipeline;
/**
!#en
Execute task synchronously
!#zh
@param task The task will be executed
@example
```js
var pipeline = new Pipeline('sync', [(task) => {
let input = task.input;
task.output = doSomething(task.input);
}]);
var task = new Task({input: 'test'});
console.log(pipeline.sync(task));
```
*/
sync(task: Task): any;
/**
!#en
Execute task asynchronously
!#zh
@param task The task will be executed
@example
```js
var pipeline = new Pipeline('sync', [(task, done) => {
let input = task.input;
task.output = doSomething(task.input);
done();
}]);
var task = new Task({input: 'test', onComplete: (err, result) => console.log(result)});
pipeline.async(task);
```
*/
async(task: Task): void;
}
/** !#en
A collection of information about a request
!#zh
*/
export class RequestItem {
/** !#en
The uuid of request
!#zh
uuid */
uuid: string;
/** !#en
The final url of request
!#zh
url */
url: string;
/** !#en
The extension name of asset
!#zh
*/
ext: string;
/** !#en
The content of asset
!#zh
*/
content: any;
/** !#en
The file of asset
!#zh
*/
file: any;
/** !#en
The information of asset
!#zh
*/
info: any;
/** !#en
Whether or not it is native asset
!#zh
*/
isNative: boolean;
/** !#en
Custom options
!#zh
*/
options: any;
/**
!#en
Create a request item
!#zh
request item
*/
constructor();
/** !#en
The id of request, combined from uuid and isNative
!#zh
id, uuid isNative */
id: string;
/**
!#en
Recycle this for reuse
!#zh
requestItem
*/
recycle(): void;
/**
!#en
Create a new request item from pool
!#zh
requestItem
*/
static create(): RequestItem;
}
/** !#en
The builtin bundles
!#zh
bundle */
export enum BuiltinBundleName {
RESOURCES = 0,
INTERNAL = 0,
MAIN = 0,
START_SCENE = 0,
}
/** !#en
Task is used to run in the pipeline for some effect
!#zh
线 */
export class Task {
/** !#en
The id of task
!#zh
id */
id: number;
/** !#en
The callback when task is completed
!#zh
*/
onComplete: Function;
/** !#en
The callback of progression
!#zh
*/
onProgress: Function;
/** !#en
The callback when something goes wrong
!#zh
*/
onError: Function;
/** !#en
The source of task
!#zh
*/
source: any;
/** !#en
The output of task
!#zh
*/
output: any;
/** !#en
The input of task
!#zh
*/
input: any;
/** !#en
The progression of task
!#zh
*/
progress: any;
/** !#en
Custom options
!#zh
*/
options: any;
/**
!#en
Create a new Task
!#zh
@param options Some optional paramters
*/
constructor(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record<string, any>});
/**
!#en
Set paramters of this task
!#zh
@param options Some optional paramters
@example
```js
var task = new Task();
task.set({input: ['test'], onComplete: (err, result) => console.log(err), onProgress: (finish, total) => console.log(finish / total)});
```
*/
set(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record<string, any>}): void;
/**
!#en
Dispatch event
!#zh
@param event The event name
@param param1 Parameter 1
@param param2 Parameter 2
@param param3 Parameter 3
@param param4 Parameter 4
@example
```js
var task = Task.create();
Task.onComplete = (msg) => console.log(msg);
Task.dispatch('complete', 'hello world');
```
*/
dispatch(event: string, param1?: any, param2?: any, param3?: any, param4?: any): void;
/**
!#en
Recycle this for reuse
!#zh
task
*/
recycle(): void;
/** !#en
Whether or not this task is completed
!#zh
*/
isFinish: boolean;
/**
!#en
Create a new task from pool
!#zh
task
@param options Some optional paramters
*/
static create(options?: {onComplete?: (err: Error, result: any) => void, onError?: () => void, onProgress?: Function, input: any, progress?: any, options?: Record<string, any>}): Task;
}
}
/** Some helpful utilities */
declare namespace cc.geomUtils {
/**
!#en
the distance between a point and a plane
!#zh
@param point point
@param plane plane
*/
export function point_plane(point: cc.Vec3, plane: cc.Plane): number;
/**
!#en
the closest point on plane to a given point
!#zh
@param out Closest point
@param point Given point
@param plane plane
*/
export function pt_point_plane(out: cc.Vec3, point: cc.Vec3, plane: cc.Plane): cc.Vec3;
/**
!#en
the closest point on aabb to a given point
!#zh
aabb
@param out Closest point.
@param point Given point.
@param aabb Align the axis around the box.
*/
export function pt_point_aabb(out: cc.Vec3, point: cc.Vec3, aabb: cc.Aabb): cc.Vec3;
/**
!#en
the closest point on obb to a given point
!#zh
obb
@param out Closest point
@param point Given point
@param obb Direction box
*/
export function pt_point_obb(out: cc.Vec3, point: cc.Vec3, obb: cc.Obb): cc.Vec3;
}
/** !#en Some JavaScript decorators which can be accessed with "cc._decorator".
!#zh JavaScript "cc._decorator" 访
API JavaScript */
declare namespace cc._decorator {
/**
!#en
Declare the standard [ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes)
as CCClass, please see [Class](../../../manual/en/scripting/class.html) for details.
!#zh
[ES6 Class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) 声明为 CCClass具体用法请参阅[类型定义](../../../manual/zh/scripting/class.html)。
@param name The class name used for serialization.
@example
```js
const {ccclass} = cc._decorator;
// define a CCClass, omit the name
&#64;ccclass
class NewScript extends cc.Component {
// ...
}
// define a CCClass with a name
&#64;ccclass('LoginData')
class LoginData {
// ...
}
```
*/
export function ccclass(name?: string): Function;
export function ccclass(_class?: Function): void;
/**
!#en
Declare property for [CCClass](../../../manual/en/scripting/reference/attributes.html).
!#zh
[CCClass](../../../manual/zh/scripting/reference/attributes.html)
@param options an object with some property attributes
@example
```js
const {ccclass, property} = cc._decorator;
&#64;ccclass
class NewScript extends cc.Component {
&#64;property({
type: cc.Node
})
targetNode1 = null;
&#64;property(cc.Node)
targetNode2 = null;
&#64;property(cc.Button)
targetButton = null;
&#64;property
_width = 100;
&#64;property
get width () {
return this._width;
}
&#64;property
set width (value) {
this._width = value;
}
&#64;property
offset = new cc.Vec2(100, 100);
&#64;property(cc.Vec2)
offsets = [];
&#64;property(cc.SpriteFrame)
frame = null;
}
// above is equivalent to (上面的代码相当于):
var NewScript = cc.Class({
properties: {
targetNode1: {
default: null,
type: cc.Node
},
targetNode2: {
default: null,
type: cc.Node
},
targetButton: {
default: null,
type: cc.Button
},
_width: 100,
width: {
get () {
return this._width;
},
set (value) {
this._width = value;
}
},
offset: new cc.Vec2(100, 100)
offsets: {
default: [],
type: cc.Vec2
}
frame: {
default: null,
type: cc.SpriteFrame
},
}
});
```
*/
export function property(options?: {type?: any; visible?: boolean|(() => boolean); displayName?: string; tooltip?: string; multiline?: boolean; readonly?: boolean; min?: number; max?: number; step?: number; range?: number[]; slide?: boolean; serializable?: boolean; formerlySerializedAs?: string; editorOnly?: boolean; override?: boolean; animatable?: boolean} | any[]|Function|cc.ValueType|number|string|boolean): Function;
export function property(_target: Object, _key: any, _desc?: any): void;
/**
!#en
Makes a CCClass that inherit from component execute in edit mode.<br>
By default, all components are only executed in play mode,
which means they will not have their callback functions executed while the Editor is in edit mode.
!#zh
Component CCClass <br>
Component
@example
```js
const {ccclass, executeInEditMode} = cc._decorator;
&#64;ccclass
&#64;executeInEditMode
class NewScript extends cc.Component {
// ...
}
```
*/
export function executeInEditMode(): Function;
export function executeInEditMode(_class: Function): void;
/**
!#en
Automatically add required component as a dependency for the CCClass that inherit from component.
!#zh
CCClass
@param requiredComponent requiredComponent
@example
```js
const {ccclass, requireComponent} = cc._decorator;
&#64;ccclass
&#64;requireComponent(cc.Sprite)
class SpriteCtrl extends cc.Component {
// ...
}
```
*/
export function requireComponent(requiredComponent: typeof cc.Component): Function;
/**
!#en
The menu path to register a component to the editors "Component" menu. Eg. "Rendering/CameraCtrl".
!#zh
便 "Rendering/CameraCtrl"
@param path The path is the menu represented like a pathname.
For example the menu could be "Rendering/CameraCtrl".
@example
```js
const {ccclass, menu} = cc._decorator;
&#64;ccclass
&#64;menu("Rendering/CameraCtrl")
class NewScript extends cc.Component {
// ...
}
```
*/
export function menu(path: string): Function;
/**
!#en
The execution order of lifecycle methods for Component.
Those less than 0 will execute before while those greater than 0 will execute after.
The order will only affect onLoad, onEnable, start, update and lateUpdate while onDisable and onDestroy will not be affected.
!#zh
0 0 onLoad, onEnable, start, update lateUpdate onDisable onDestroy
@param order The execution order of lifecycle methods for Component. Those less than 0 will execute before while those greater than 0 will execute after.
@example
```js
const {ccclass, executionOrder} = cc._decorator;
&#64;ccclass
&#64;executionOrder(1)
class CameraCtrl extends cc.Component {
// ...
}
```
*/
export function executionOrder(order: number): Function;
/**
!#en
Prevents Component of the same type (or subtype) to be added more than once to a Node.
!#zh
@example
```js
const {ccclass, disallowMultiple} = cc._decorator;
&#64;ccclass
&#64;disallowMultiple
class CameraCtrl extends cc.Component {
// ...
}
```
*/
export function disallowMultiple(): Function;
export function disallowMultiple(_class: Function): void;
/**
!#en
If specified, the editor's scene view will keep updating this node in 60 fps when it is selected, otherwise, it will update only if necessary.<br>
This property is only available if executeInEditMode is true.
!#zh
"executeInEditMode" playOnFocus 60 FPS
@example
```js
const {ccclass, playOnFocus, executeInEditMode} = cc._decorator;
&#64;ccclass
&#64;executeInEditMode
&#64;playOnFocus
class CameraCtrl extends cc.Component {
// ...
}
```
*/
export function playOnFocus(): Function;
export function playOnFocus(_class: Function): void;
/**
!#en
Specifying the url of the custom html to draw the component in **Properties**.
!#zh
**** url
@param url url
@example
```js
const {ccclass, inspector} = cc._decorator;
&#64;ccclass
&#64;inspector("packages://inspector/inspectors/comps/camera-ctrl.js")
class NewScript extends cc.Component {
// ...
}
```
*/
export function inspector(path: string): Function;
/**
!#en
The custom documentation URL.
!#zh
url ****
@param url url
@example
```js
const {ccclass, help} = cc._decorator;
&#64;ccclass
&#64;help("app://docs/html/components/spine.html")
class NewScript extends cc.Component {
// ...
}
```
*/
export function help(path: string): Function;
/**
NOTE:<br>
The old mixins implemented in cc.Class(ES5) behaves exact the same as multiple inheritance.
But since ES6, class constructor can't be function-called and class methods become non-enumerable,
so we can not mix in ES6 Classes.<br>
See:<br>
[https://esdiscuss.org/topic/traits-are-now-impossible-in-es6-until-es7-since-rev32](https://esdiscuss.org/topic/traits-are-now-impossible-in-es6-until-es7-since-rev32)<br>
One possible solution (but IDE unfriendly):<br>
[http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes](http://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/)<br>
<br>
NOTE:<br>
You must manually call mixins constructor, this is different from cc.Class(ES5).
@param ctor constructors to mix, only support ES5 constructors or classes defined by using `cc.Class`,
not support ES6 Classes.
@example
```js
const {ccclass, mixins} = cc._decorator;
class Animal { ... }
const Fly = cc.Class({
constructor () { ... }
});
&#64;ccclass
&#64;mixins(cc.EventTarget, Fly)
class Bird extends Animal {
constructor () {
super();
// You must manually call mixins constructor, this is different from cc.Class(ES5)
cc.EventTarget.call(this);
Fly.call(this);
}
// ...
}
```
*/
export function mixins(ctor: Function, ...rest: Function[]): Function;
}
/** !#en This module provides some JavaScript utilities. All members can be accessed with `cc.js`.
!#zh JavaScript `cc.js` 访 */
declare namespace cc.js {
/**
Check the obj whether is number or not
If a number is created by using 'new Number(10086)', the typeof it will be "object"...
Then you can use this function if you care about this case.
@param obj obj
*/
export function isNumber(obj: any): boolean;
/**
Check the obj whether is string or not.
If a string is created by using 'new String("blabla")', the typeof it will be "object"...
Then you can use this function if you care about this case.
@param obj obj
*/
export function isString(obj: any): boolean;
/**
Copy all properties not defined in obj from arguments[1...n]
@param obj object to extend its properties
@param sourceObj source object to copy properties from
*/
export function addon(obj: any, ...sourceObj: any[]): any;
/**
copy all properties from arguments[1...n] to obj
@param obj obj
@param sourceObj sourceObj
*/
export function mixin(obj: any, ...sourceObj: any[]): any;
/**
Derive the class from the supplied base class.
Both classes are just native javascript constructors, not created by cc.Class, so
usually you will want to inherit using {{#crossLink "cc/Class:method"}}cc.Class {{/crossLink}} instead.
@param cls cls
@param base the baseclass to inherit
*/
export function extend(cls: Function, base: Function): Function;
/**
Get super class
@param ctor the constructor of subclass
*/
export function getSuper(ctor: Function): Function;
/**
Checks whether subclass is child of superclass or equals to superclass
@param subclass subclass
@param superclass superclass
*/
export function isChildClassOf(subclass: Function, superclass: Function): boolean;
/**
Removes all enumerable properties from object
@param obj obj
*/
export function clear(obj: any): void;
/**
Checks whether obj is an empty object
@param obj obj
*/
export function isEmptyObject(obj: any): boolean;
/**
Get property descriptor in object and all its ancestors
@param obj obj
@param name name
*/
export function getPropertyDescriptor(obj: any, name: string): any;
/**
Define value, just help to call Object.defineProperty.<br>
The configurable will be true.
@param obj obj
@param prop prop
@param value value
@param writable writable
@param enumerable enumerable
*/
export function value(obj: any, prop: string, value: any, writable?: boolean, enumerable?: boolean): void;
/**
Define get set accessor, just help to call Object.defineProperty(...)
@param obj obj
@param prop prop
@param getter getter
@param setter setter
@param enumerable enumerable
@param configurable configurable
*/
export function getset(obj: any, prop: string, getter: Function, setter?: Function, enumerable?: boolean, configurable?: boolean): void;
/**
Define get accessor, just help to call Object.defineProperty(...)
@param obj obj
@param prop prop
@param getter getter
@param enumerable enumerable
@param configurable configurable
*/
export function get(obj: any, prop: string, getter: Function, enumerable?: boolean, configurable?: boolean): void;
/**
Define set accessor, just help to call Object.defineProperty(...)
@param obj obj
@param prop prop
@param setter setter
@param enumerable enumerable
@param configurable configurable
*/
export function set(obj: any, prop: string, setter: Function, enumerable?: boolean, configurable?: boolean): void;
/**
Get class name of the object, if object is just a {} (and which class named 'Object'), it will return "".
(modified from <a href="http://stackoverflow.com/questions/1249531/how-to-get-a-javascript-objects-class">the code from this stackoverflow post</a>)
@param objOrCtor instance or constructor
*/
export function getClassName(objOrCtor: any|Function): string;
/** !#en All classes registered in the engine, indexed by ID.
!#zh ID */
export var _registeredClassIds: any;
/** !#en All classes registered in the engine, indexed by name.
!#zh */
export var _registeredClassNames: any;
/**
Register the class by specified name manually
@param className className
@param constructor constructor
*/
export function setClassName(className: string, constructor: Function): void;
/**
Unregister a class from fireball.
If you dont need a registered class anymore, you should unregister the class so that Fireball will not keep its reference anymore.
Please note that its still your responsibility to free other references to the class.
@param constructor the class you will want to unregister, any number of classes can be added
*/
export function unregisterClass(...constructor: Function[]): void;
/**
Get the registered class by name
@param classname classname
*/
export function getClassByName(classname: string): Function;
/**
Defines a polyfill field for deprecated codes.
@param obj YourObject or YourClass.prototype
@param obsoleted "OldParam" or "YourClass.OldParam"
@param newExpr "NewParam" or "YourClass.NewParam"
@param writable writable
*/
export function obsolete(obj: any, obsoleted: string, newExpr: string, writable?: boolean): void;
/**
Defines all polyfill fields for obsoleted codes corresponding to the enumerable properties of props.
@param obj YourObject or YourClass.prototype
@param objName "YourObject" or "YourClass"
@param props props
@param writable writable
*/
export function obsoletes(obj: any, objName: any, props: any, writable?: boolean): void;
/**
A string tool to construct a string with format string.
@param msg A JavaScript string containing zero or more substitution strings (%s).
@param subst JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
@example
```js
cc.js.formatStr("a: %s, b: %s", a, b);
cc.js.formatStr(a, b, c);
```
*/
export function formatStr(msg: string|any, ...subst: any[]): string;
/**
!#en
A simple wrapper of `Object.create(null)` which ensures the return object have no prototype (and thus no inherited members). So we can skip `hasOwnProperty` calls on property lookups. It is a worthwhile optimization than the `{}` literal when `hasOwnProperty` calls are necessary.
!#zh
`Object.create(null)` `Object.create(null)` prototype `hasOwnProperty` `hasOwnProperty` 使 `{}`
@param forceDictMode Apply the delete operator to newly created map object. This causes V8 to put the object in "dictionary mode" and disables creation of hidden classes which are very expensive for objects that are constantly changing shape.
*/
export function createMap(forceDictMode?: boolean): any;
/** undefined */
export class array {
/**
Removes the array item at the specified index.
@param array array
@param index index
*/
static removeAt(array: any[], index: number): void;
/**
Removes the array item at the specified index.
It's faster but the order of the array will be changed.
@param array array
@param index index
*/
static fastRemoveAt(array: any[], index: number): void;
/**
Removes the first occurrence of a specific object from the array.
@param array array
@param value value
*/
static remove(array: any[], value: any): boolean;
/**
Removes the first occurrence of a specific object from the array.
It's faster but the order of the array will be changed.
@param array array
@param value value
*/
static fastRemove(array: any[], value: number): void;
/**
Verify array's Type
@param array array
@param type type
*/
static verifyType(array: any[], type: Function): boolean;
/**
Removes from array all values in minusArr. For each Value in minusArr, the first matching instance in array will be removed.
@param array Source Array
@param minusArr minus Array
*/
static removeArray(array: any[], minusArr: any[]): void;
/**
Inserts some objects at index
@param array array
@param addObjs addObjs
@param index index
*/
static appendObjectsAt(array: any[], addObjs: any[], index: number): any[];
/**
Determines whether the array contains a specific value.
@param array array
@param value value
*/
static contains(array: any[], value: any): boolean;
/**
Copy an array's item to a new array (its performance is better than Array.slice)
@param array array
*/
static copy(array: any[]): any[];
}
/** !#en
A fixed-length object pool designed for general type.<br>
The implementation of this object pool is very simple,
it can helps you to improve your game performance for objects which need frequent release and recreate operations<br/>
!#zh
<br/>
*/
export class Pool {
/**
!#en
Constructor for creating an object pool for the specific object type.
You can pass a callback argument for process the cleanup logic when the object is recycled.
!#zh
使
@param cleanupFunc the callback method used to process the cleanup logic when the object is recycled.
@param size initializes the length of the array
*/
constructor(cleanupFunc: (obj: any) => void, size: number);
constructor(size: number);
/**
!#en
Get and initialize an object from pool. This method defaults to null and requires the user to implement it.
!#zh
@param params parameters to used to initialize the object
*/
get(...params: any[]): any;
/** !#en
The current number of available objects, the default is 0, it will gradually increase with the recycle of the object,
the maximum will not exceed the size specified when the constructor is called.
!#zh
0 size */
count: number;
/**
!#en
Get an object from pool, if no available object in the pool, null will be returned.
!#zh
*/
_get(): any;
/**
!#en Put an object into the pool.
!#zh
*/
put(): void;
/**
!#en Resize the pool.
!#zh
*/
resize(): void;
}
}
/** !#en A basic module for creating vertex data for 3D objects. You can access this module by `cc.primitive`.
!#zh 3D `cc.primitive` 访 */
declare namespace cc.primitive {
/**
!#en Create box vertex data
!#zh
@param width width
@param height height
@param length length
@param opts opts
*/
export function box(width: number, height: number, length: number, opts: {widthSegments: number; heightSegments: number; lengthSegments: number; }): cc.VertexData;
/**
!#en Create cone vertex data
!#zh
@param radius radius
@param height height
@param opts opts
*/
export function cone(radius: number, height: number, opts: {radialSegments: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData;
/**
!#en Create cylinder vertex data
!#zh
@param radiusTop radiusTop
@param radiusBottom radiusBottom
@param height height
@param opts opts
*/
export function cylinder(radiusTop: number, radiusBottom: number, height: number, opts: {radialSegments: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData;
/**
!#en Create plane vertex data
!#zh
@param width width
@param length length
@param opts opts
*/
export function plane(width: number, length: number, opts: {widthSegments: number; lengthSegments: number; }): cc.VertexData;
/**
!#en Create quad vertex data
!#zh
*/
export function quad(): cc.VertexData;
/**
!#en Create sphere vertex data
!#zh
@param radius radius
@param opts opts
*/
export function sphere(radius: number, opts: {segments: number; }): cc.VertexData;
/**
!#en Create torus vertex data
!#zh
@param radius radius
@param tube tube
@param opts opts
*/
export function torus(radius: number, tube: number, opts: {radialSegments: number; tubularSegments: number; arc: number; }): cc.VertexData;
/**
!#en Create capsule vertex data
!#zh
@param radiusTop radiusTop
@param radiusBottom radiusBottom
@param height height
@param opts opts
*/
export function capsule(radiusTop: number, radiusBottom: number, height: number, opts: {sides: number; heightSegments: number; capped: boolean; arc: number; }): cc.VertexData;
/**
!#en Create polyhedron vertex data
!#zh
@param type type
@param Size Size
@param opts opts
*/
export function polyhedron(type: cc.primitive.PolyhedronType, Size: number, opts: {sizeX: number; sizeY: number; sizeZ: number; }): cc.VertexData;
}
declare let CC_JSB: boolean
declare let CC_NATIVERENDERER: boolean
declare let CC_EDITOR: boolean
declare let CC_PREVIEW: boolean
declare let CC_TEST: boolean
declare let CC_DEBUG: boolean
declare let cc: {
// polyfills: {
// destroyObject? (object: any): void;
// };
[x: string]: any;
}
declare let Editor: any;
// https://medium.com/dailyjs/typescript-create-a-condition-based-subset-types-9d902cea5b8c
type FlagExcludedType<Base, Type> = { [Key in keyof Base]: Base[Key] extends Type ? never : Key };
type AllowedNames<Base, Type> = FlagExcludedType<Base, Type>[keyof Base];
type KeyPartial<T, K extends keyof T> = { [P in K]?: T[P] };
type OmitType<Base, Type> = KeyPartial<Base, AllowedNames<Base, Type>>;
type ConstructorType<T> = OmitType<T, Function>;
declare interface IWritableArrayLike<T> {
readonly length: number;
[index: number]: T;
}
declare let module: {
exports: object
}
declare interface Math {
sign(v: number);
}
declare interface Object {
assign(target: {}, source: {});
}
type FloatArray = Float64Array | Float32Array;
interface IColorLike {
r: number;
g: number;
b: number;
a: number;
_val: number;
}
interface IMat3Like {
m: FloatArray
}
interface IMat4Like {
m: FloatArray
}
interface IQuatLike {
x: number;
y: number;
z: number;
w: number;
}
interface IRectLike {
x: number;
y: number;
width: number;
height: number;
}
interface ISizeLike {
width: number;
height: number;
}
interface IVec2Like {
x: number;
y: number;
}
interface IVec3Like {
x: number;
y: number;
z: number;
}
interface IVec4Like {
x: number;
y: number;
z: number;
w: number;
}
declare namespace dragonBones {
/**
* @internal
* @private
*/
const webAssemblyModule: {
HEAP16: Int16Array;
_malloc(byteSize: number): number;
_free(pointer: number): void;
setDataBinary(data: DragonBonesData, binaryPointer: number, intBytesLength: number, floatBytesLength: number, frameIntBytesLength: number, frameFloatBytesLength: number, frameBytesLength: number, timelineBytesLength: number): void;
};
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* @internal
* @private
*/
const enum BinaryOffset {
WeigthBoneCount = 0,
WeigthFloatOffset = 1,
WeigthBoneIndices = 2,
MeshVertexCount = 0,
MeshTriangleCount = 1,
MeshFloatOffset = 2,
MeshWeightOffset = 3,
MeshVertexIndices = 4,
TimelineScale = 0,
TimelineOffset = 1,
TimelineKeyFrameCount = 2,
TimelineFrameValueCount = 3,
TimelineFrameValueOffset = 4,
TimelineFrameOffset = 5,
FramePosition = 0,
FrameTweenType = 1,
FrameTweenEasingOrCurveSampleCount = 2,
FrameCurveSamples = 3,
DeformMeshOffset = 0,
DeformCount = 1,
DeformValueCount = 2,
DeformValueOffset = 3,
DeformFloatOffset = 4,
}
/**
* @internal
* @private
*/
const enum ArmatureType {
Armature = 0,
MovieClip = 1,
Stage = 2,
}
/**
* @internal
* @private
*/
const enum BoneType {
Bone = 0,
Surface = 1,
}
/**
* @private
*/
const enum DisplayType {
Image = 0,
Armature = 1,
Mesh = 2,
BoundingBox = 3,
}
/**
* - Bounding box type.
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* @version DragonBones 5.0
* @language zh_CN
*/
const enum BoundingBoxType {
Rectangle = 0,
Ellipse = 1,
Polygon = 2,
}
/**
* @internal
* @private
*/
const enum ActionType {
Play = 0,
Frame = 10,
Sound = 11,
}
/**
* @internal
* @private
*/
const enum BlendMode {
Normal = 0,
Add = 1,
Alpha = 2,
Darken = 3,
Difference = 4,
Erase = 5,
HardLight = 6,
Invert = 7,
Layer = 8,
Lighten = 9,
Multiply = 10,
Overlay = 11,
Screen = 12,
Subtract = 13,
}
/**
* @internal
* @private
*/
const enum TweenType {
None = 0,
Line = 1,
Curve = 2,
QuadIn = 3,
QuadOut = 4,
QuadInOut = 5,
}
/**
* @internal
* @private
*/
const enum TimelineType {
Action = 0,
ZOrder = 1,
BoneAll = 10,
BoneTranslate = 11,
BoneRotate = 12,
BoneScale = 13,
Surface = 50,
SlotDisplay = 20,
SlotColor = 21,
SlotFFD = 22,
IKConstraint = 30,
AnimationTime = 40,
AnimationWeight = 41,
}
/**
* - Offset mode.
* @version DragonBones 5.5
* @language en_US
*/
/**
* -
* @version DragonBones 5.5
* @language zh_CN
*/
const enum OffsetMode {
None = 0,
Additive = 1,
Override = 2,
}
/**
* - Animation fade out mode.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @version DragonBones 4.5
* @language zh_CN
*/
const enum AnimationFadeOutMode {
/**
* - Do not fade out of any animation states.
* @language en_US
*/
/**
* -
* @language zh_CN
*/
None = 0,
/**
* - Fade out the animation states of the same layer.
* @language en_US
*/
/**
* -
* @language zh_CN
*/
SameLayer = 1,
/**
* - Fade out the animation states of the same group.
* @language en_US
*/
/**
* -
* @language zh_CN
*/
SameGroup = 2,
/**
* - Fade out the animation states of the same layer and group.
* @language en_US
*/
/**
* -
* @language zh_CN
*/
SameLayerAndGroup = 3,
/**
* - Fade out of all animation states.
* @language en_US
*/
/**
* -
* @language zh_CN
*/
All = 4,
/**
* - Does not replace the animation state with the same name.
* @language en_US
*/
/**
* -
* @language zh_CN
*/
Single = 5,
}
/**
* @private
*/
interface Map<T> {
[key: string]: T;
}
/**
* @private
*/
class DragonBones {
static readonly VERSION: string;
static yDown: boolean;
static debug: boolean;
static debugDraw: boolean;
static webAssembly: boolean;
private readonly _clock;
private readonly _events;
private readonly _objects;
private _eventManager;
constructor(eventManager: IEventDispatcher);
advanceTime(passedTime: number): void;
bufferEvent(value: EventObject): void;
bufferObject(object: BaseObject): void;
readonly clock: WorldClock;
readonly eventManager: IEventDispatcher;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - The BaseObject is the base class for all objects in the DragonBones framework.
* All BaseObject instances are cached to the object pool to reduce the performance consumption of frequent requests for memory or memory recovery.
* @version DragonBones 4.5
* @language en_US
*/
/**
* - DragonBones
*
* @version DragonBones 4.5
* @language zh_CN
*/
abstract class BaseObject {
private static _hashCode;
private static _defaultMaxCount;
private static readonly _maxCountMap;
private static readonly _poolsMap;
private static _returnObject(object);
static toString(): string;
/**
* - Set the maximum cache count of the specify object pool.
* @param objectConstructor - The specify class. (Set all object pools max cache count if not set)
* @param maxCount - Max count.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @param objectConstructor - ()
* @param maxCount -
* @version DragonBones 4.5
* @language zh_CN
*/
static setMaxCount(objectConstructor: (typeof BaseObject) | null, maxCount: number): void;
/**
* - Clear the cached instances of a specify object pool.
* @param objectConstructor - Specify class. (Clear all cached instances if not set)
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @param objectConstructor - ()
* @version DragonBones 4.5
* @language zh_CN
*/
static clearPool(objectConstructor?: (typeof BaseObject) | null): void;
/**
* - Get an instance of the specify class from object pool.
* @param objectConstructor - The specify class.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @param objectConstructor -
* @version DragonBones 4.5
* @language zh_CN
*/
static borrowObject<T extends BaseObject>(objectConstructor: {
new (): T;
}): T;
/**
* - A unique identification number assigned to the object.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @version DragonBones 4.5
* @language zh_CN
*/
readonly hashCode: number;
private _isInPool;
/**
* @private
*/
protected abstract _onClear(): void;
/**
* - Clear the object and return it back to object pool
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @version DragonBones 4.5
* @language zh_CN
*/
returnToPool(): void;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - 2D Transform matrix.
* @version DragonBones 3.0
* @language en_US
*/
/**
* - 2D
* @version DragonBones 3.0
* @language zh_CN
*/
class Matrix {
/**
* - The value that affects the positioning of pixels along the x axis when scaling or rotating an image.
* @default 1.0
* @version DragonBones 3.0
* @language en_US
*/
/**
* - 沿 x
* @default 1.0
* @version DragonBones 3.0
* @language zh_CN
*/
a: number;
/**
* - The value that affects the positioning of pixels along the y axis when rotating or skewing an image.
* @default 0.0
* @version DragonBones 3.0
* @language en_US
*/
/**
* - 沿 y
* @default 0.0
* @version DragonBones 3.0
* @language zh_CN
*/
b: number;
/**
* - The value that affects the positioning of pixels along the x axis when rotating or skewing an image.
* @default 0.0
* @version DragonBones 3.0
* @language en_US
*/
/**
* - 沿 x
* @default 0.0
* @version DragonBones 3.0
* @language zh_CN
*/
c: number;
/**
* - The value that affects the positioning of pixels along the y axis when scaling or rotating an image.
* @default 1.0
* @version DragonBones 3.0
* @language en_US
*/
/**
* - 沿 y
* @default 1.0
* @version DragonBones 3.0
* @language zh_CN
*/
d: number;
/**
* - The distance by which to translate each point along the x axis.
* @default 0.0
* @version DragonBones 3.0
* @language en_US
*/
/**
* - 沿 x
* @default 0.0
* @version DragonBones 3.0
* @language zh_CN
*/
tx: number;
/**
* - The distance by which to translate each point along the y axis.
* @default 0.0
* @version DragonBones 3.0
* @language en_US
*/
/**
* - 沿 y
* @default 0.0
* @version DragonBones 3.0
* @language zh_CN
*/
ty: number;
/**
* @private
*/
constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number);
toString(): string;
/**
* @private
*/
copyFrom(value: Matrix): Matrix;
/**
* @private
*/
copyFromArray(value: Array<number>, offset?: number): Matrix;
/**
* - Convert to unit matrix.
* The resulting matrix has the following properties: a=1, b=0, c=0, d=1, tx=0, ty=0.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* a=1b=0c=0d=1tx=0ty=0
* @version DragonBones 3.0
* @language zh_CN
*/
identity(): Matrix;
/**
* - Multiplies the current matrix with another matrix.
* @param value - The matrix that needs to be multiplied.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @param value -
* @version DragonBones 3.0
* @language zh_CN
*/
concat(value: Matrix): Matrix;
/**
* - Convert to inverse matrix.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
invert(): Matrix;
/**
* - Apply a matrix transformation to a specific point.
* @param x - X coordinate.
* @param y - Y coordinate.
* @param result - The point after the transformation is applied.
* @param delta - Whether to ignore tx, ty's conversion to point.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @param x -
* @param y -
* @param result -
* @param delta - txty
* @version DragonBones 3.0
* @language zh_CN
*/
transformPoint(x: number, y: number, result: {
x: number;
y: number;
}, delta?: boolean): void;
/**
* @private
*/
transformRectangle(rectangle: {
x: number;
y: number;
width: number;
height: number;
}, delta?: boolean): void;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - 2D Transform.
* @version DragonBones 3.0
* @language en_US
*/
/**
* - 2D
* @version DragonBones 3.0
* @language zh_CN
*/
class Transform {
/**
* @private
*/
static readonly PI: number;
/**
* @private
*/
static readonly PI_D: number;
/**
* @private
*/
static readonly PI_H: number;
/**
* @private
*/
static readonly PI_Q: number;
/**
* @private
*/
static readonly RAD_DEG: number;
/**
* @private
*/
static readonly DEG_RAD: number;
/**
* @private
*/
static normalizeRadian(value: number): number;
/**
* - Horizontal translate.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
x: number;
/**
* - Vertical translate.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
y: number;
/**
* - Skew. (In radians)
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
skew: number;
/**
* - rotation. (In radians)
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
rotation: number;
/**
* - Horizontal Scaling.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
scaleX: number;
/**
* - Vertical scaling.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
scaleY: number;
/**
* @private
*/
constructor(x?: number, y?: number, skew?: number, rotation?: number, scaleX?: number, scaleY?: number);
toString(): string;
/**
* @private
*/
copyFrom(value: Transform): Transform;
/**
* @private
*/
identity(): Transform;
/**
* @private
*/
add(value: Transform): Transform;
/**
* @private
*/
minus(value: Transform): Transform;
/**
* @private
*/
fromMatrix(matrix: Matrix): Transform;
/**
* @private
*/
toMatrix(matrix: Matrix): Transform;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* @internal
* @private
*/
class ColorTransform {
alphaMultiplier: number;
redMultiplier: number;
greenMultiplier: number;
blueMultiplier: number;
alphaOffset: number;
redOffset: number;
greenOffset: number;
blueOffset: number;
constructor(alphaMultiplier?: number, redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaOffset?: number, redOffset?: number, greenOffset?: number, blueOffset?: number);
copyFrom(value: ColorTransform): void;
identity(): void;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - The Point object represents a location in a two-dimensional coordinate system.
* @version DragonBones 3.0
* @language en_US
*/
/**
* - Point
* @version DragonBones 3.0
* @language zh_CN
*/
class Point {
/**
* - The horizontal coordinate.
* @default 0.0
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @default 0.0
* @version DragonBones 3.0
* @language zh_CN
*/
x: number;
/**
* - The vertical coordinate.
* @default 0.0
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @default 0.0
* @version DragonBones 3.0
* @language zh_CN
*/
y: number;
/**
* - Creates a new point. If you pass no parameters to this method, a point is created at (0,0).
* @param x - The horizontal coordinate.
* @param y - The vertical coordinate.
* @version DragonBones 3.0
* @language en_US
*/
/**
* - egret.Point .00
* @param x - x 0.0
* @param y - y 0.0
* @version DragonBones 3.0
* @language zh_CN
*/
constructor(x?: number, y?: number);
/**
* @private
*/
copyFrom(value: Point): void;
/**
* @private
*/
clear(): void;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its
* width and its height.<br/>
* The x, y, width, and height properties of the Rectangle class are independent of each other; changing the value of
* one property has no effect on the others. However, the right and bottom properties are integrally related to those
* four properties. For example, if you change the value of the right property, the value of the width property changes;
* if you change the bottom property, the value of the height property changes.
* @version DragonBones 3.0
* @language en_US
*/
/**
* - Rectangle (x, y) <br/>
* Rectangle xywidth height
* right bottom right width
* bottom height
* @version DragonBones 3.0
* @language zh_CN
*/
class Rectangle {
/**
* - The x coordinate of the top-left corner of the rectangle.
* @default 0.0
* @version DragonBones 3.0
* @language en_US
*/
/**
* - x
* @default 0.0
* @version DragonBones 3.0
* @language zh_CN
*/
x: number;
/**
* - The y coordinate of the top-left corner of the rectangle.
* @default 0.0
* @version DragonBones 3.0
* @language en_US
*/
/**
* - y
* @default 0.0
* @version DragonBones 3.0
* @language zh_CN
*/
y: number;
/**
* - The width of the rectangle, in pixels.
* @default 0.0
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @default 0.0
* @version DragonBones 3.0
* @language zh_CN
*/
width: number;
/**
* -
* @default 0.0
* @version DragonBones 3.0
* @language en_US
*/
/**
* - The height of the rectangle, in pixels.
* @default 0.0
* @version DragonBones 3.0
* @language zh_CN
*/
height: number;
/**
* @private
*/
constructor(x?: number, y?: number, width?: number, height?: number);
/**
* @private
*/
copyFrom(value: Rectangle): void;
/**
* @private
*/
clear(): void;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - The user custom data.
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* @version DragonBones 5.0
* @language zh_CN
*/
class UserData extends BaseObject {
static toString(): string;
/**
* - The custom int numbers.
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* @version DragonBones 5.0
* @language zh_CN
*/
readonly ints: Array<number>;
/**
* - The custom float numbers.
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* @version DragonBones 5.0
* @language zh_CN
*/
readonly floats: Array<number>;
/**
* - The custom strings.
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* @version DragonBones 5.0
* @language zh_CN
*/
readonly strings: Array<string>;
/**
* @inheritDoc
*/
protected _onClear(): void;
/**
* @internal
* @private
*/
addInt(value: number): void;
/**
* @internal
* @private
*/
addFloat(value: number): void;
/**
* @internal
* @private
*/
addString(value: string): void;
/**
* - Get the custom int number.
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* @version DragonBones 5.0
* @language zh_CN
*/
getInt(index?: number): number;
/**
* - Get the custom float number.
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* @version DragonBones 5.0
* @language zh_CN
*/
getFloat(index?: number): number;
/**
* - Get the custom string.
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* @version DragonBones 5.0
* @language zh_CN
*/
getString(index?: number): string;
}
/**
* @internal
* @private
*/
class ActionData extends BaseObject {
static toString(): string;
type: ActionType;
name: string;
bone: BoneData | null;
slot: SlotData | null;
data: UserData | null;
protected _onClear(): void;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - The DragonBones data.
* A DragonBones data contains multiple armature data.
* @see dragonBones.ArmatureData
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
*
* @see dragonBones.ArmatureData
* @version DragonBones 3.0
* @language zh_CN
*/
class DragonBonesData extends BaseObject {
static toString(): string;
/**
* @private
*/
autoSearch: boolean;
/**
* - The animation frame rate.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
frameRate: number;
/**
* - The data version.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
version: string;
/**
* - The DragonBones data name.
* The name is consistent with the DragonBones project name.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
*
* @version DragonBones 3.0
* @language zh_CN
*/
name: string;
/**
* @private
*/
stage: ArmatureData | null;
/**
* @internal
* @private
*/
readonly frameIndices: Array<number>;
/**
* @internal
* @private
*/
readonly cachedFrames: Array<number>;
/**
* - All armature data names.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
readonly armatureNames: Array<string>;
/**
* @private
*/
readonly armatures: Map<ArmatureData>;
/**
* @internal
* @private
*/
binary: ArrayBuffer;
/**
* @internal
* @private
*/
intArray: Int16Array;
/**
* @internal
* @private
*/
floatArray: Float32Array;
/**
* @internal
* @private
*/
frameIntArray: Int16Array;
/**
* @internal
* @private
*/
frameFloatArray: Float32Array;
/**
* @internal
* @private
*/
frameArray: Int16Array;
/**
* @internal
* @private
*/
timelineArray: Uint16Array;
/**
* @private
*/
userData: UserData | null;
/**
* @inheritDoc
*/
protected _onClear(): void;
/**
* @internal
* @private
*/
addArmature(value: ArmatureData): void;
/**
* - Get a specific armature data.
* @param name - The armature data name.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @param name -
* @version DragonBones 3.0
* @language zh_CN
*/
getArmature(name: string): ArmatureData | null;
/**
* - Deprecated, please refer to {@link #dragonBones.BaseFactory#removeDragonBonesData()}.
* @deprecated
* @language en_US
*/
/**
* - {@link #dragonBones.BaseFactory#removeDragonBonesData()}
* @deprecated
* @language zh_CN
*/
dispose(): void;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - The armature data.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
class ArmatureData extends BaseObject {
static toString(): string;
/**
* @private
*/
type: ArmatureType;
/**
* - The animation frame rate.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
frameRate: number;
/**
* @private
*/
cacheFrameRate: number;
/**
* @private
*/
scale: number;
/**
* - The armature name.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
name: string;
/**
* @private
*/
readonly aabb: Rectangle;
/**
* - The names of all the animation data.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
readonly animationNames: Array<string>;
/**
* @private
*/
readonly sortedBones: Array<BoneData>;
/**
* @private
*/
readonly sortedSlots: Array<SlotData>;
/**
* @private
*/
readonly defaultActions: Array<ActionData>;
/**
* @private
*/
readonly actions: Array<ActionData>;
/**
* @private
*/
readonly bones: Map<BoneData>;
/**
* @private
*/
readonly slots: Map<SlotData>;
/**
* @private
*/
readonly constraints: Map<ConstraintData>;
/**
* @private
*/
readonly skins: Map<SkinData>;
/**
* @private
*/
readonly animations: Map<AnimationData>;
/**
* - The default skin data.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @version DragonBones 4.5
* @language zh_CN
*/
defaultSkin: SkinData | null;
/**
* - The default animation data.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @version DragonBones 4.5
* @language zh_CN
*/
defaultAnimation: AnimationData | null;
/**
* @private
*/
canvas: CanvasData | null;
/**
* @private
*/
userData: UserData | null;
/**
* @private
*/
parent: DragonBonesData;
/**
* @inheritDoc
*/
protected _onClear(): void;
/**
* @internal
* @private
*/
sortBones(): void;
/**
* @internal
* @private
*/
cacheFrames(frameRate: number): void;
/**
* @internal
* @private
*/
setCacheFrame(globalTransformMatrix: Matrix, transform: Transform): number;
/**
* @internal
* @private
*/
getCacheFrame(globalTransformMatrix: Matrix, transform: Transform, arrayOffset: number): void;
/**
* @internal
* @private
*/
addBone(value: BoneData): void;
/**
* @internal
* @private
*/
addSlot(value: SlotData): void;
/**
* @internal
* @private
*/
addConstraint(value: ConstraintData): void;
/**
* @internal
* @private
*/
addSkin(value: SkinData): void;
/**
* @internal
* @private
*/
addAnimation(value: AnimationData): void;
/**
* @internal
* @private
*/
addAction(value: ActionData, isDefault: boolean): void;
/**
* - Get a specific done data.
* @param name - The bone name.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @param name -
* @version DragonBones 3.0
* @language zh_CN
*/
getBone(name: string): BoneData | null;
/**
* - Get a specific slot data.
* @param name - The slot name.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @param name -
* @version DragonBones 3.0
* @language zh_CN
*/
getSlot(name: string): SlotData | null;
/**
* @private
*/
getConstraint(name: string): ConstraintData | null;
/**
* - Get a specific skin data.
* @param name - The skin name.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @param name -
* @version DragonBones 3.0
* @language zh_CN
*/
getSkin(name: string): SkinData | null;
/**
* @internal
* @private
*/
getMesh(skinName: string, slotName: string, meshName: string): MeshDisplayData | null;
/**
* - Get a specific animation data.
* @param name - The animation name.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @param name -
* @version DragonBones 3.0
* @language zh_CN
*/
getAnimation(name: string): AnimationData | null;
}
/**
* - The bone data.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
class BoneData extends BaseObject {
static toString(): string;
/**
* @private
*/
inheritTranslation: boolean;
/**
* @private
*/
inheritRotation: boolean;
/**
* @private
*/
inheritScale: boolean;
/**
* @private
*/
inheritReflection: boolean;
/**
* @private
*/
type: BoneType;
/**
* - The bone length.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
length: number;
/**
* - The bone name.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
name: string;
/**
* @private
*/
readonly transform: Transform;
/**
* @private
*/
userData: UserData | null;
/**
* - The parent bone data.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
parent: BoneData | null;
/**
* @inheritDoc
*/
protected _onClear(): void;
}
/**
* @internal
* @private
*/
class SurfaceData extends BoneData {
static toString(): string;
segmentX: number;
segmentY: number;
readonly vertices: Array<number>;
/**
* @inheritDoc
*/
protected _onClear(): void;
}
/**
* - The slot data.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
class SlotData extends BaseObject {
/**
* @internal
* @private
*/
static readonly DEFAULT_COLOR: ColorTransform;
/**
* @internal
* @private
*/
static createColor(): ColorTransform;
static toString(): string;
/**
* @private
*/
blendMode: BlendMode;
/**
* @private
*/
displayIndex: number;
/**
* @private
*/
zOrder: number;
/**
* - The slot name.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
name: string;
/**
* @private
*/
color: ColorTransform;
/**
* @private
*/
userData: UserData | null;
/**
* - The parent bone data.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
parent: BoneData;
/**
* @inheritDoc
*/
protected _onClear(): void;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* @internal
* @private
*/
abstract class ConstraintData extends BaseObject {
order: number;
name: string;
target: BoneData;
root: BoneData;
bone: BoneData | null;
protected _onClear(): void;
}
/**
* @internal
* @private
*/
class IKConstraintData extends ConstraintData {
static toString(): string;
scaleEnabled: boolean;
bendPositive: boolean;
weight: number;
protected _onClear(): void;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* @internal
* @private
*/
class CanvasData extends BaseObject {
static toString(): string;
hasBackground: boolean;
color: number;
x: number;
y: number;
width: number;
height: number;
protected _onClear(): void;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - The skin data, typically a armature data instance contains at least one skinData.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
class SkinData extends BaseObject {
static toString(): string;
/**
* - The skin name.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
name: string;
/**
* @private
*/
readonly displays: Map<Array<DisplayData | null>>;
/**
* @private
*/
parent: ArmatureData;
/**
* @inheritDoc
*/
protected _onClear(): void;
/**
* @internal
* @private
*/
addDisplay(slotName: string, value: DisplayData | null): void;
/**
* @private
*/
getDisplay(slotName: string, displayName: string): DisplayData | null;
/**
* @private
*/
getDisplays(slotName: string): Array<DisplayData | null> | null;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* @internal
* @private
*/
abstract class DisplayData extends BaseObject {
type: DisplayType;
name: string;
path: string;
parent: SkinData;
readonly transform: Transform;
protected _onClear(): void;
}
/**
* @internal
* @private
*/
class ImageDisplayData extends DisplayData {
static toString(): string;
readonly pivot: Point;
texture: TextureData | null;
protected _onClear(): void;
}
/**
* @internal
* @private
*/
class ArmatureDisplayData extends DisplayData {
static toString(): string;
inheritAnimation: boolean;
readonly actions: Array<ActionData>;
armature: ArmatureData | null;
protected _onClear(): void;
/**
* @private
*/
addAction(value: ActionData): void;
}
/**
* @internal
* @private
*/
class MeshDisplayData extends DisplayData {
static toString(): string;
inheritDeform: boolean;
offset: number;
weight: WeightData | null;
glue: GlueData | null;
texture: TextureData | null;
protected _onClear(): void;
}
/**
* @internal
* @private
*/
class BoundingBoxDisplayData extends DisplayData {
static toString(): string;
boundingBox: BoundingBoxData | null;
protected _onClear(): void;
}
/**
* @internal
* @private
*/
class WeightData extends BaseObject {
static toString(): string;
count: number;
offset: number;
readonly bones: Array<BoneData>;
protected _onClear(): void;
addBone(value: BoneData): void;
}
/**
* @internal
* @private
*/
class GlueData extends BaseObject {
static toString(): string;
readonly weights: Array<number>;
readonly meshes: Array<MeshDisplayData | null>;
protected _onClear(): void;
addMesh(value: MeshDisplayData | null): void;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - The base class of bounding box data.
* @see dragonBones.RectangleData
* @see dragonBones.EllipseData
* @see dragonBones.PolygonData
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* @see dragonBones.RectangleData
* @see dragonBones.EllipseData
* @see dragonBones.PolygonData
* @version DragonBones 5.0
* @language zh_CN
*/
abstract class BoundingBoxData extends BaseObject {
/**
* - The bounding box type.
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* @version DragonBones 5.0
* @language zh_CN
*/
type: BoundingBoxType;
/**
* @private
*/
color: number;
/**
* @private
*/
width: number;
/**
* @private
*/
height: number;
/**
* @private
*/
protected _onClear(): void;
/**
* - Check whether the bounding box contains a specific point. (Local coordinate system)
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* @version DragonBones 5.0
* @language zh_CN
*/
abstract containsPoint(pX: number, pY: number): boolean;
/**
* - Check whether the bounding box intersects a specific segment. (Local coordinate system)
* @version DragonBones 5.0
* @language en_US
*/
/**
* - 线
* @version DragonBones 5.0
* @language zh_CN
*/
abstract intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA: {
x: number;
y: number;
} | null, intersectionPointB: {
x: number;
y: number;
} | null, normalRadians: {
x: number;
y: number;
} | null): number;
}
/**
* - The rectangle bounding box data.
* @version DragonBones 5.1
* @language en_US
*/
/**
* -
* @version DragonBones 5.1
* @language zh_CN
*/
class RectangleBoundingBoxData extends BoundingBoxData {
static toString(): string;
/**
* - Compute the bit code for a point (x, y) using the clip rectangle
*/
private static _computeOutCode(x, y, xMin, yMin, xMax, yMax);
/**
* @private
*/
static rectangleIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xMin: number, yMin: number, xMax: number, yMax: number, intersectionPointA?: {
x: number;
y: number;
} | null, intersectionPointB?: {
x: number;
y: number;
} | null, normalRadians?: {
x: number;
y: number;
} | null): number;
/**
* @inheritDoc
* @private
*/
protected _onClear(): void;
/**
* @inheritDoc
*/
containsPoint(pX: number, pY: number): boolean;
/**
* @inheritDoc
*/
intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: {
x: number;
y: number;
} | null, intersectionPointB?: {
x: number;
y: number;
} | null, normalRadians?: {
x: number;
y: number;
} | null): number;
}
/**
* - The ellipse bounding box data.
* @version DragonBones 5.1
* @language en_US
*/
/**
* -
* @version DragonBones 5.1
* @language zh_CN
*/
class EllipseBoundingBoxData extends BoundingBoxData {
static toString(): string;
/**
* @private
*/
static ellipseIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xC: number, yC: number, widthH: number, heightH: number, intersectionPointA?: {
x: number;
y: number;
} | null, intersectionPointB?: {
x: number;
y: number;
} | null, normalRadians?: {
x: number;
y: number;
} | null): number;
/**
* @inheritDoc
* @private
*/
protected _onClear(): void;
/**
* @inheritDoc
*/
containsPoint(pX: number, pY: number): boolean;
/**
* @inheritDoc
*/
intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: {
x: number;
y: number;
} | null, intersectionPointB?: {
x: number;
y: number;
} | null, normalRadians?: {
x: number;
y: number;
} | null): number;
}
/**
* - The polygon bounding box data.
* @version DragonBones 5.1
* @language en_US
*/
/**
* -
* @version DragonBones 5.1
* @language zh_CN
*/
class PolygonBoundingBoxData extends BoundingBoxData {
static toString(): string;
/**
* @private
*/
static polygonIntersectsSegment(xA: number, yA: number, xB: number, yB: number, vertices: Array<number>, intersectionPointA?: {
x: number;
y: number;
} | null, intersectionPointB?: {
x: number;
y: number;
} | null, normalRadians?: {
x: number;
y: number;
} | null): number;
/**
* @private
*/
x: number;
/**
* @private
*/
y: number;
/**
* - The polygon vertices.
* @version DragonBones 5.1
* @language en_US
*/
/**
* -
* @version DragonBones 5.1
* @language zh_CN
*/
readonly vertices: Array<number>;
/**
* @private
*/
weight: WeightData | null;
/**
* @inheritDoc
* @private
*/
protected _onClear(): void;
/**
* @inheritDoc
*/
containsPoint(pX: number, pY: number): boolean;
/**
* @inheritDoc
*/
intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: {
x: number;
y: number;
} | null, intersectionPointB?: {
x: number;
y: number;
} | null, normalRadians?: {
x: number;
y: number;
} | null): number;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - The animation data.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
class AnimationData extends BaseObject {
static toString(): string;
/**
* - FrameIntArray.
* @internal
* @private
*/
frameIntOffset: number;
/**
* - FrameFloatArray.
* @internal
* @private
*/
frameFloatOffset: number;
/**
* - FrameArray.
* @internal
* @private
*/
frameOffset: number;
/**
* - The frame count of the animation.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
frameCount: number;
/**
* - The play times of the animation. [0: Loop play, [1~N]: Play N times]
* @version DragonBones 3.0
* @language en_US
*/
/**
* - [0: , [1~N]: N ]
* @version DragonBones 3.0
* @language zh_CN
*/
playTimes: number;
/**
* - The duration of the animation. (In seconds)
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
duration: number;
/**
* @private
*/
scale: number;
/**
* - The fade in time of the animation. (In seconds)
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
fadeInTime: number;
/**
* @private
*/
cacheFrameRate: number;
/**
* - The animation name.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
name: string;
/**
* @private
*/
readonly cachedFrames: Array<boolean>;
/**
* @private
*/
readonly boneTimelines: Map<Array<TimelineData>>;
/**
* @private
*/
readonly surfaceTimelines: Map<Array<TimelineData>>;
/**
* @private
*/
readonly slotTimelines: Map<Array<TimelineData>>;
/**
* @private
*/
readonly constraintTimelines: Map<Array<TimelineData>>;
/**
* @private
*/
readonly animationTimelines: Map<Array<TimelineData>>;
/**
* @private
*/
readonly boneCachedFrameIndices: Map<Array<number>>;
/**
* @private
*/
readonly slotCachedFrameIndices: Map<Array<number>>;
/**
* @private
*/
actionTimeline: TimelineData | null;
/**
* @private
*/
zOrderTimeline: TimelineData | null;
/**
* @private
*/
parent: ArmatureData;
/**
* @inheritDoc
*/
protected _onClear(): void;
/**
* @internal
* @private
*/
cacheFrames(frameRate: number): void;
/**
* @private
*/
addBoneTimeline(bone: BoneData, timeline: TimelineData): void;
/**
* @private
*/
addSurfaceTimeline(surface: SurfaceData, timeline: TimelineData): void;
/**
* @private
*/
addSlotTimeline(slot: SlotData, timeline: TimelineData): void;
/**
* @private
*/
addConstraintTimeline(constraint: ConstraintData, timeline: TimelineData): void;
/**
* @private
*/
addAnimationTimeline(name: string, timeline: TimelineData): void;
/**
* @private
*/
getBoneTimelines(name: string): Array<TimelineData> | null;
/**
* @private
*/
getSurfaceTimelines(name: string): Array<TimelineData> | null;
/**
* @private
*/
getSlotTimelines(name: string): Array<TimelineData> | null;
/**
* @private
*/
getConstraintTimelines(name: string): Array<TimelineData> | null;
/**
* @private
*/
getAnimationTimelines(name: string): Array<TimelineData> | null;
/**
* @private
*/
getBoneCachedFrameIndices(name: string): Array<number> | null;
/**
* @private
*/
getSlotCachedFrameIndices(name: string): Array<number> | null;
}
/**
* @internal
* @private
*/
class TimelineData extends BaseObject {
static toString(): string;
type: TimelineType;
offset: number;
frameIndicesOffset: number;
protected _onClear(): void;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - The animation config is used to describe all the information needed to play an animation state.
* The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used.
* @see dragonBones.AnimationState
* @beta
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* API 使 bug
* @see dragonBones.AnimationState
* @beta
* @version DragonBones 5.0
* @language zh_CN
*/
class AnimationConfig extends BaseObject {
static toString(): string;
/**
* @private
*/
pauseFadeOut: boolean;
/**
* - Fade out the pattern of other animation states when the animation state is fade in.
* This property is typically used to specify the substitution of multiple animation states blend.
* @default dragonBones.AnimationFadeOutMode.All
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
*
* @default dragonBones.AnimationFadeOutMode.All
* @version DragonBones 5.0
* @language zh_CN
*/
fadeOutMode: AnimationFadeOutMode;
/**
* @private
*/
fadeOutTweenType: TweenType;
/**
* @private
*/
fadeOutTime: number;
/**
* @private
*/
pauseFadeIn: boolean;
/**
* @private
*/
actionEnabled: boolean;
/**
* @private
*/
additiveBlending: boolean;
/**
* - Whether the animation state has control over the display property of the slots.
* Sometimes blend a animation state does not want it to control the display properties of the slots,
* especially if other animation state are controlling the display properties of the slots.
* @default true
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
*
*
* @default true
* @version DragonBones 5.0
* @language zh_CN
*/
displayControl: boolean;
/**
* - Whether to reset the objects without animation to the armature pose when the animation state is start to play.
* This property should usually be set to false when blend multiple animation states.
* @default true
* @version DragonBones 5.1
* @language en_US
*/
/**
* -
* false
* @default true
* @version DragonBones 5.1
* @language zh_CN
*/
resetToPose: boolean;
/**
* @private
*/
fadeInTweenType: TweenType;
/**
* - The play times. [0: Loop play, [1~N]: Play N times]
* @version DragonBones 3.0
* @language en_US
*/
/**
* - [0: , [1~N]: N ]
* @version DragonBones 3.0
* @language zh_CN
*/
playTimes: number;
/**
* - The blend layer.
* High layer animation state will get the blend weight first.
* When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned.
* @readonly
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
*
* 1
* @readonly
* @version DragonBones 5.0
* @language zh_CN
*/
layer: number;
/**
* - The start time of play. (In seconds)
* @default 0.0
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* @default 0.0
* @version DragonBones 5.0
* @language zh_CN
*/
position: number;
/**
* - The duration of play.
* [-1: Use the default value of the animation data, 0: Stop play, (0~N]: The duration] (In seconds)
* @default -1.0
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* [-1: 使, 0: , (0~N]: ]
* @default -1.0
* @version DragonBones 5.0
* @language zh_CN
*/
duration: number;
/**
* - The play speed.
* The value is an overlay relationship with {@link dragonBones.Animation#timeScale}.
* [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play]
* @default 1.0
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* {@link dragonBones.Animation#timeScale}
* [(-N~0): , 0: , (0~1): , 1: , (1~N): ]
* @default 1.0
* @version DragonBones 3.0
* @language zh_CN
*/
timeScale: number;
/**
* - The blend weight.
* @default 1.0
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* @default 1.0
* @version DragonBones 5.0
* @language zh_CN
*/
weight: number;
/**
* - The fade in time.
* [-1: Use the default value of the animation data, [0~N]: The fade in time] (In seconds)
* @default -1.0
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* [-1: 使, [0~N]: ]
* @default -1.0
* @version DragonBones 5.0
* @language zh_CN
*/
fadeInTime: number;
/**
* - The auto fade out time when the animation state play completed.
* [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds)
* @default -1.0
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* [-1: , [0~N]: ]
* @default -1.0
* @version DragonBones 5.0
* @language zh_CN
*/
autoFadeOutTime: number;
/**
* - The name of the animation state. (Can be different from the name of the animation data)
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* @version DragonBones 5.0
* @language zh_CN
*/
name: string;
/**
* - The animation data name.
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* @version DragonBones 5.0
* @language zh_CN
*/
animation: string;
/**
* - The blend group name of the animation state.
* This property is typically used to specify the substitution of multiple animation states blend.
* @readonly
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
*
* @readonly
* @version DragonBones 5.0
* @language zh_CN
*/
group: string;
/**
* @private
*/
readonly boneMask: Array<string>;
/**
* @private
*/
protected _onClear(): void;
/**
* @private
*/
clear(): void;
/**
* @private
*/
copyFrom(value: AnimationConfig): void;
/**
* @private
*/
containsBoneMask(name: string): boolean;
/**
* @private
*/
addBoneMask(armature: Armature, name: string, recursive?: boolean): void;
/**
* @private
*/
removeBoneMask(armature: Armature, name: string, recursive?: boolean): void;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - The texture atlas data.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
abstract class TextureAtlasData extends BaseObject {
/**
* @private
*/
autoSearch: boolean;
/**
* @private
*/
width: number;
/**
* @private
*/
height: number;
/**
* @private
*/
scale: number;
/**
* - The texture atlas name.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
name: string;
/**
* - The image path of the texture atlas.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
imagePath: string;
/**
* @private
*/
readonly textures: Map<TextureData>;
/**
* @inheritDoc
*/
protected _onClear(): void;
/**
* @private
*/
copyFrom(value: TextureAtlasData): void;
/**
* @internal
* @private
*/
abstract createTexture(): TextureData;
/**
* @internal
* @private
*/
addTexture(value: TextureData): void;
/**
* @private
*/
getTexture(name: string): TextureData | null;
}
/**
* @internal
* @private
*/
abstract class TextureData extends BaseObject {
static createRectangle(): Rectangle;
rotated: boolean;
name: string;
readonly region: Rectangle;
parent: TextureAtlasData;
frame: Rectangle | null;
protected _onClear(): void;
copyFrom(value: TextureData): void;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - The armature proxy interface, the docking engine needs to implement it concretely.
* @see dragonBones.Armature
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* @see dragonBones.Armature
* @version DragonBones 5.0
* @language zh_CN
*/
interface IArmatureProxy extends IEventDispatcher {
/**
* @internal
* @private
*/
dbInit(armature: Armature): void;
/**
* @internal
* @private
*/
dbClear(): void;
/**
* @internal
* @private
*/
dbUpdate(): void;
/**
* - Dispose the instance and the Armature instance. (The Armature instance will return to the object pool)
* @example
* <pre>
* removeChild(armatureDisplay);
* armatureDisplay.dispose();
* </pre>
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @example
* <pre>
* removeChild(armatureDisplay);
* armatureDisplay.dispose();
* </pre>
* @version DragonBones 4.5
* @language zh_CN
*/
dispose(disposeProxy: boolean): void;
/**
* - The armature.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @version DragonBones 4.5
* @language zh_CN
*/
readonly armature: Armature;
/**
* - The animation player.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
readonly animation: Animation;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - Armature is the core of the skeleton animation system.
* @see dragonBones.ArmatureData
* @see dragonBones.Bone
* @see dragonBones.Slot
* @see dragonBones.Animation
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @see dragonBones.ArmatureData
* @see dragonBones.Bone
* @see dragonBones.Slot
* @see dragonBones.Animation
* @version DragonBones 3.0
* @language zh_CN
*/
class Armature extends BaseObject implements IAnimatable {
static toString(): string;
private static _onSortSlots(a, b);
/**
* - Whether to inherit the animation control of the parent armature.
* True to try to have the child armature play an animation with the same name when the parent armature play the animation.
* @default true
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* true
* @default true
* @version DragonBones 4.5
* @language zh_CN
*/
inheritAnimation: boolean;
/**
* @private
*/
userData: any;
private _lockUpdate;
private _bonesDirty;
private _slotsDirty;
private _zOrderDirty;
private _flipX;
private _flipY;
/**
* @internal
* @private
*/
_cacheFrameIndex: number;
private readonly _bones;
private readonly _slots;
/**
* @internal
* @private
*/
readonly _glueSlots: Array<Slot>;
/**
* @internal
* @private
*/
readonly _constraints: Array<Constraint>;
private readonly _actions;
/**
* @internal
* @private
*/
_armatureData: ArmatureData;
private _animation;
private _proxy;
private _display;
/**
* @internal
* @private
*/
_replaceTextureAtlasData: TextureAtlasData | null;
private _replacedTexture;
/**
* @internal
* @private
*/
_dragonBones: DragonBones;
private _clock;
/**
* @internal
* @private
*/
_parent: Slot | null;
/**
* @private
*/
protected _onClear(): void;
private _sortBones();
private _sortSlots();
/**
* @internal
* @private
*/
_sortZOrder(slotIndices: Array<number> | Int16Array | null, offset: number): void;
/**
* @internal
* @private
*/
_addBoneToBoneList(value: Bone): void;
/**
* @internal
* @private
*/
_removeBoneFromBoneList(value: Bone): void;
/**
* @internal
* @private
*/
_addSlotToSlotList(value: Slot): void;
/**
* @internal
* @private
*/
_removeSlotFromSlotList(value: Slot): void;
/**
* @internal
* @private
*/
_bufferAction(action: ActionData, append: boolean): void;
/**
* - Dispose the armature. (Return to the object pool)
* @example
* <pre>
* removeChild(armature.display);
* armature.dispose();
* </pre>
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @example
* <pre>
* removeChild(armature.display);
* armature.dispose();
* </pre>
* @version DragonBones 3.0
* @language zh_CN
*/
dispose(): void;
/**
* @internal
* @private
*/
init(armatureData: ArmatureData, proxy: IArmatureProxy, display: any, dragonBones: DragonBones): void;
/**
* @inheritDoc
*/
advanceTime(passedTime: number): void;
/**
* - Forces a specific bone or its owning slot to update the transform or display property in the next frame.
* @param boneName - The bone name. (If not set, all bones will be update)
* @param updateSlot - Whether to update the bone's slots. (Default: false)
* @see dragonBones.Bone#invalidUpdate()
* @see dragonBones.Slot#invalidUpdate()
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @param boneName -
* @param updateSlot - : false
* @see dragonBones.Bone#invalidUpdate()
* @see dragonBones.Slot#invalidUpdate()
* @version DragonBones 3.0
* @language zh_CN
*/
invalidUpdate(boneName?: string | null, updateSlot?: boolean): void;
/**
* - Check whether a specific point is inside a custom bounding box in a slot.
* The coordinate system of the point is the inner coordinate system of the armature.
* Custom bounding boxes need to be customized in Dragonbones Pro.
* @param x - The horizontal coordinate of the point.
* @param y - The vertical coordinate of the point.
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
*
* DragonBones Pro
* @param x -
* @param y -
* @version DragonBones 5.0
* @language zh_CN
*/
containsPoint(x: number, y: number): Slot | null;
/**
* - Check whether a specific segment intersects a custom bounding box for a slot in the armature.
* The coordinate system of the segment and intersection is the inner coordinate system of the armature.
* Custom bounding boxes need to be customized in Dragonbones Pro.
* @param xA - The horizontal coordinate of the beginning of the segment.
* @param yA - The vertical coordinate of the beginning of the segment.
* @param xB - The horizontal coordinate of the end point of the segment.
* @param yB - The vertical coordinate of the end point of the segment.
* @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated)
* @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated)
* @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated)
* @returns The slot of the first custom bounding box where the segment intersects from the start point to the end point.
* @version DragonBones 5.0
* @language en_US
*/
/**
* - 线
* 线
* DragonBones Pro
* @param xA - 线
* @param yA - 线
* @param xB - 线
* @param yB - 线
* @param intersectionPointA - 线
* @param intersectionPointB - 线
* @param normalRadians - 线线 [x: 线线, y: 线线] 线
* @returns 线
* @version DragonBones 5.0
* @language zh_CN
*/
intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: {
x: number;
y: number;
} | null, intersectionPointB?: {
x: number;
y: number;
} | null, normalRadians?: {
x: number;
y: number;
} | null): Slot | null;
/**
* - Get a specific bone.
* @param name - The bone name.
* @see dragonBones.Bone
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @param name -
* @see dragonBones.Bone
* @version DragonBones 3.0
* @language zh_CN
*/
getBone(name: string): Bone | null;
/**
* - Get a specific bone by the display.
* @param display - The display object.
* @see dragonBones.Bone
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @param display -
* @see dragonBones.Bone
* @version DragonBones 3.0
* @language zh_CN
*/
getBoneByDisplay(display: any): Bone | null;
/**
* - Get a specific slot.
* @param name - The slot name.
* @see dragonBones.Slot
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @param name -
* @see dragonBones.Slot
* @version DragonBones 3.0
* @language zh_CN
*/
getSlot(name: string): Slot | null;
/**
* - Get a specific slot by the display.
* @param display - The display object.
* @see dragonBones.Slot
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @param display -
* @see dragonBones.Slot
* @version DragonBones 3.0
* @language zh_CN
*/
getSlotByDisplay(display: any): Slot | null;
/**
* @deprecated
*/
addBone(value: Bone, parentName: string): void;
/**
* @deprecated
*/
addSlot(value: Slot, parentName: string): void;
/**
* @private
*/
addConstraint(value: Constraint): void;
/**
* @deprecated
*/
removeBone(value: Bone): void;
/**
* @deprecated
*/
removeSlot(value: Slot): void;
/**
* - Get all bones.
* @see dragonBones.Bone
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @see dragonBones.Bone
* @version DragonBones 3.0
* @language zh_CN
*/
getBones(): Array<Bone>;
/**
* - Get all slots.
* @see dragonBones.Slot
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @see dragonBones.Slot
* @version DragonBones 3.0
* @language zh_CN
*/
getSlots(): Array<Slot>;
/**
* - Whether to flip the armature horizontally.
* @version DragonBones 5.5
* @language en_US
*/
/**
* -
* @version DragonBones 5.5
* @language zh_CN
*/
flipX: boolean;
/**
* - Whether to flip the armature vertically.
* @version DragonBones 5.5
* @language en_US
*/
/**
* -
* @version DragonBones 5.5
* @language zh_CN
*/
flipY: boolean;
/**
* - The animation cache frame rate, which turns on the animation cache when the set value is greater than 0.
* There is a certain amount of memory overhead to improve performance by caching animation data in memory.
* The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate.
* When the animation cache is turned on, some features will fail, such as the offset property of bone.
* @example
* <pre>
* armature.cacheFrameRate = 24;
* </pre>
* @see dragonBones.DragonBonesData#frameRate
* @see dragonBones.ArmatureData#frameRate
* @version DragonBones 4.5
* @language en_US
*/
/**
* - 0
*
*
* offset
* @example
* <pre>
* armature.cacheFrameRate = 24;
* </pre>
* @see dragonBones.DragonBonesData#frameRate
* @see dragonBones.ArmatureData#frameRate
* @version DragonBones 4.5
* @language zh_CN
*/
cacheFrameRate: number;
/**
* - The armature name.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
readonly name: string;
/**
* - The armature data.
* @see dragonBones.ArmatureData
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @see dragonBones.ArmatureData
* @version DragonBones 4.5
* @language zh_CN
*/
readonly armatureData: ArmatureData;
/**
* - The animation player.
* @see dragonBones.Animation
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @see dragonBones.Animation
* @version DragonBones 3.0
* @language zh_CN
*/
readonly animation: Animation;
/**
* @pivate
*/
readonly proxy: IArmatureProxy;
/**
* - The EventDispatcher instance of the armature.
* @version DragonBones 4.5
* @language en_US
*/
/**
* - EventDispatcher
* @version DragonBones 4.5
* @language zh_CN
*/
readonly eventDispatcher: IEventDispatcher;
/**
* - The display container.
* The display of the slot is displayed as the parent.
* Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
*
* DisplayObjectContainer
* @version DragonBones 3.0
* @language zh_CN
*/
readonly display: any;
/**
* @private
*/
replacedTexture: any;
/**
* @inheritDoc
*/
clock: WorldClock | null;
/**
* - Get the parent slot which the armature belongs to.
* @see dragonBones.Slot
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @see dragonBones.Slot
* @version DragonBones 4.5
* @language zh_CN
*/
readonly parent: Slot | null;
/**
* @deprecated
* @private
*/
replaceTexture(texture: any): void;
/**
* - Deprecated, please refer to {@link #eventDispatcher}.
* @deprecated
* @language en_US
*/
/**
* - {@link #eventDispatcher}
* @deprecated
* @language zh_CN
*/
hasEventListener(type: EventStringType): boolean;
/**
* - Deprecated, please refer to {@link #eventDispatcher}.
* @deprecated
* @language en_US
*/
/**
* - {@link #eventDispatcher}
* @deprecated
* @language zh_CN
*/
addEventListener(type: EventStringType, listener: Function, target: any): void;
/**
* - Deprecated, please refer to {@link #eventDispatcher}.
* @deprecated
* @language en_US
*/
/**
* - {@link #eventDispatcher}
* @deprecated
* @language zh_CN
*/
removeEventListener(type: EventStringType, listener: Function, target: any): void;
/**
* - Deprecated, please refer to {@link #cacheFrameRate}.
* @deprecated
* @language en_US
*/
/**
* - {@link #cacheFrameRate}
* @deprecated
* @language zh_CN
*/
enableAnimationCache(frameRate: number): void;
/**
* - Deprecated, please refer to {@link #display}.
* @deprecated
* @language en_US
*/
/**
* - {@link #display}
* @deprecated
* @language zh_CN
*/
getDisplay(): any;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - The base class of the transform object.
* @see dragonBones.Transform
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @see dragonBones.Transform
* @version DragonBones 4.5
* @language zh_CN
*/
abstract class TransformObject extends BaseObject {
/**
* @private
*/
protected static readonly _helpMatrix: Matrix;
/**
* @private
*/
protected static readonly _helpTransform: Transform;
/**
* @private
*/
protected static readonly _helpPoint: Point;
/**
* - A matrix relative to the armature coordinate system.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
readonly globalTransformMatrix: Matrix;
/**
* - A transform relative to the armature coordinate system.
* @see #updateGlobalTransform()
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @see #updateGlobalTransform()
* @version DragonBones 3.0
* @language zh_CN
*/
readonly global: Transform;
/**
* - The offset transform relative to the armature or the parent bone coordinate system.
* @see #dragonBones.Bone#invalidUpdate()
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @see #dragonBones.Bone#invalidUpdate()
* @version DragonBones 3.0
* @language zh_CN
*/
readonly offset: Transform;
/**
* @private
*/
origin: Transform | null;
/**
* @private
*/
userData: any;
/**
* @private
*/
protected _globalDirty: boolean;
/**
* @internal
* @private
*/
_armature: Armature;
/**
* @internal
* @private
*/
_parent: Bone;
/**
* @private
*/
protected _onClear(): void;
/**
* @internal
* @private
*/
_setArmature(value: Armature | null): void;
/**
* @internal
* @private
*/
_setParent(value: Bone | null): void;
/**
* - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible,
* some engines do not rely on these attributes to update rendering, such as Egret.
* The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale.
* @example
* <pre>
* bone.updateGlobalTransform();
* let rotation = bone.global.rotation;
* </pre>
* @version DragonBones 3.0
* @language en_US
*/
/**
* - {@link #global} 访 Egret
* 使访 {@link #global}
* @example
* <pre>
* bone.updateGlobalTransform();
* let rotation = bone.global.rotation;
* </pre>
* @version DragonBones 3.0
* @language zh_CN
*/
updateGlobalTransform(): void;
/**
* - The armature to which it belongs.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
readonly armature: Armature;
/**
* - The parent bone to which it belongs.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
readonly parent: Bone;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - Bone is one of the most important logical units in the armature animation system,
* and is responsible for the realization of translate, rotation, scaling in the animations.
* A armature can contain multiple bones.
* @see dragonBones.BoneData
* @see dragonBones.Armature
* @see dragonBones.Slot
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
*
* @see dragonBones.BoneData
* @see dragonBones.Armature
* @see dragonBones.Slot
* @version DragonBones 3.0
* @language zh_CN
*/
class Bone extends TransformObject {
static toString(): string;
/**
* - The offset mode.
* @see #offset
* @version DragonBones 5.5
* @language en_US
*/
/**
* -
* @see #offset
* @version DragonBones 5.5
* @language zh_CN
*/
offsetMode: OffsetMode;
/**
* @internal
* @private
*/
readonly animationPose: Transform;
/**
* @internal
* @private
*/
_transformDirty: boolean;
/**
* @internal
* @private
*/
_childrenTransformDirty: boolean;
protected _localDirty: boolean;
/**
* @internal
* @private
*/
_hasConstraint: boolean;
private _visible;
protected _cachedFrameIndex: number;
/**
* @internal
* @private
*/
readonly _blendState: BlendState;
/**
* @internal
* @private
*/
_boneData: BoneData;
/**
* @internal
* @private
*/
_cachedFrameIndices: Array<number> | null;
/**
* @inheritDoc
*/
protected _onClear(): void;
/**
* @private
*/
protected _updateGlobalTransformMatrix(isCache: boolean): void;
/**
* @inheritDoc
*/
_setArmature(value: Armature | null): void;
/**
* @internal
* @private
*/
init(boneData: BoneData): void;
/**
* @internal
* @private
*/
update(cacheFrameIndex: number): void;
/**
* @internal
* @private
*/
updateByConstraint(): void;
/**
* - Forces the bone to update the transform in the next frame.
* When the bone is not animated or its animation state is finished, the bone will not continue to update,
* and when the skeleton must be updated for some reason, the method needs to be called explicitly.
* @example
* <pre>
* let bone = armature.getBone("arm");
* bone.offset.scaleX = 2.0;
* bone.invalidUpdate();
* </pre>
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
*
* @example
* <pre>
* let bone = armature.getBone("arm");
* bone.offset.scaleX = 2.0;
* bone.invalidUpdate();
* </pre>
* @version DragonBones 3.0
* @language zh_CN
*/
invalidUpdate(): void;
/**
* - Check whether the bone contains a specific bone or slot.
* @see dragonBones.Bone
* @see dragonBones.Slot
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @see dragonBones.Bone
* @see dragonBones.Slot
* @version DragonBones 3.0
* @language zh_CN
*/
contains(value: TransformObject): boolean;
/**
* - The bone data.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @version DragonBones 4.5
* @language zh_CN
*/
readonly boneData: BoneData;
/**
* - The visible of all slots in the bone.
* @default true
* @see dragonBones.Slot#visible
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @default true
* @see dragonBones.Slot#visible
* @version DragonBones 3.0
* @language zh_CN
*/
visible: boolean;
/**
* - The bone name.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
readonly name: string;
/**
* - Deprecated, please refer to {@link dragonBones.Armature#getBones()}.
* @deprecated
* @language en_US
*/
/**
* - {@link dragonBones.Armature#getBones()}
* @deprecated
* @language zh_CN
*/
getBones(): Array<Bone>;
/**
* - Deprecated, please refer to {@link dragonBones.Armature#getSlots()}.
* @deprecated
* @language en_US
*/
/**
* - {@link dragonBones.Armature#getSlots()}
* @deprecated
* @language zh_CN
*/
getSlots(): Array<Slot>;
/**
* - Deprecated, please refer to {@link dragonBones.Armature#getSlot()}.
* @deprecated
* @language en_US
*/
/**
* - {@link dragonBones.Armature#getSlot()}
* @deprecated
* @language zh_CN
*/
readonly slot: Slot | null;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* @internal
* @private
*/
class Surface extends Bone {
static toString(): string;
private _dX;
private _dY;
private _k;
private _kX;
private _kY;
/**
* For debug draw.
* @internal
* @private
*/
readonly _vertices: Array<number>;
/**
* For timeline state.
* @internal
* @private
*/
readonly _deformVertices: Array<number>;
/**
* x1, y1, x2, y2, x3, y3, x4, y4, d1X, d1Y, d2X, d2Y
*/
private readonly _hullCache;
/**
* Inside [flag, a, b, c, d, tx, ty], Outside [flag, a, b, c, d, tx, ty]
*/
private readonly _matrixCahce;
/**
* @inheritDoc
*/
protected _onClear(): void;
private _getAffineTransform(x, y, lX, lY, aX, aY, bX, bY, cX, cY, transform, matrix, isDown);
private _updateVertices();
/**
* @private
*/
protected _updateGlobalTransformMatrix(isCache: boolean): void;
_getGlobalTransformMatrix(x: number, y: number): Matrix;
init(surfaceData: SurfaceData): void;
/**
* @internal
* @private
*/
update(cacheFrameIndex: number): void;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - The slot attached to the armature, controls the display status and properties of the display object.
* A bone can contain multiple slots.
* A slot can contain multiple display objects, displaying only one of the display objects at a time,
* but you can toggle the display object into frame animation while the animation is playing.
* The display object can be a normal texture, or it can be a display of a child armature, a grid display object,
* and a custom other display object.
* @see dragonBones.Armature
* @see dragonBones.Bone
* @see dragonBones.SlotData
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
*
*
*
* @see dragonBones.Armature
* @see dragonBones.Bone
* @see dragonBones.SlotData
* @version DragonBones 3.0
* @language zh_CN
*/
abstract class Slot extends TransformObject {
/**
* - Displays the animated state or mixed group name controlled by the object, set to null to be controlled by all animation states.
* @default null
* @see dragonBones.AnimationState#displayControl
* @see dragonBones.AnimationState#name
* @see dragonBones.AnimationState#group
* @version DragonBones 4.5
* @language en_US
*/
/**
* - null
* @default null
* @see dragonBones.AnimationState#displayControl
* @see dragonBones.AnimationState#name
* @see dragonBones.AnimationState#group
* @version DragonBones 4.5
* @language zh_CN
*/
displayController: string | null;
/**
* @private
*/
protected _displayDirty: boolean;
/**
* @private
*/
protected _zOrderDirty: boolean;
/**
* @private
*/
protected _visibleDirty: boolean;
/**
* @private
*/
protected _blendModeDirty: boolean;
/**
* @internal
* @private
*/
_colorDirty: boolean;
/**
* @internal
* @private
*/
_meshDirty: boolean;
/**
* @private
*/
protected _transformDirty: boolean;
/**
* @private
*/
protected _visible: boolean;
/**
* @private
*/
protected _blendMode: BlendMode;
/**
* @private
*/
protected _displayIndex: number;
/**
* @private
*/
protected _animationDisplayIndex: number;
/**
* @internal
* @private
*/
_zOrder: number;
/**
* @private
*/
protected _cachedFrameIndex: number;
/**
* @internal
* @private
*/
_pivotX: number;
/**
* @internal
* @private
*/
_pivotY: number;
/**
* @private
*/
protected readonly _localMatrix: Matrix;
/**
* @internal
* @private
*/
readonly _colorTransform: ColorTransform;
/**
* @internal
* @private
*/
readonly _deformVertices: Array<number>;
/**
* @private
*/
readonly _displayDatas: Array<DisplayData | null>;
/**
* @private
*/
protected readonly _displayList: Array<any | Armature>;
/**
* @private
*/
protected readonly _meshBones: Array<Bone | null>;
/**
* @private
*/
protected readonly _meshSlots: Array<Slot | null>;
/**
* @internal
* @private
*/
_slotData: SlotData;
/**
* @private
*/
protected _rawDisplayDatas: Array<DisplayData | null> | null;
/**
* @private
*/
protected _displayData: DisplayData | null;
/**
* @private
*/
protected _textureData: TextureData | null;
/**
* @internal
* @private
*/
_meshData: MeshDisplayData | null;
/**
* @private
*/
protected _boundingBoxData: BoundingBoxData | null;
/**
* @private
*/
protected _rawDisplay: any;
/**
* @private
*/
protected _meshDisplay: any;
/**
* @private
*/
protected _display: any;
/**
* @private
*/
protected _childArmature: Armature | null;
/**
* @internal
* @private
*/
_cachedFrameIndices: Array<number> | null;
/**
* @inheritDoc
*/
protected _onClear(): void;
/**
* @private
*/
protected abstract _initDisplay(value: any, isRetain: boolean): void;
/**
* @private
*/
protected abstract _disposeDisplay(value: any, isRelease: boolean): void;
/**
* @private
*/
protected abstract _onUpdateDisplay(): void;
/**
* @private
*/
protected abstract _addDisplay(): void;
/**
* @private
*/
protected abstract _replaceDisplay(value: any): void;
/**
* @private
*/
protected abstract _removeDisplay(): void;
/**
* @private
*/
protected abstract _updateZOrder(): void;
/**
* @private
*/
abstract _updateVisible(): void;
/**
* @private
*/
protected abstract _updateBlendMode(): void;
/**
* @private
*/
protected abstract _updateColor(): void;
/**
* @private
*/
protected abstract _updateFrame(): void;
/**
* @private
*/
protected abstract _updateMesh(): void;
/**
* @internal
* @private
*/
abstract _updateGlueMesh(): void;
/**
* @private
*/
protected abstract _updateTransform(): void;
/**
* @private
*/
protected abstract _identityTransform(): void;
/**
* @private
*/
protected _getDefaultRawDisplayData(): DisplayData | null;
/**
* @private
*/
protected _updateDisplayData(): void;
/**
* @private
*/
protected _updateDisplay(): void;
/**
* @private
*/
protected _updateGlobalTransformMatrix(isCache: boolean): void;
/**
* @private
*/
protected _isMeshBonesUpdate(): boolean;
/**
* @inheritDoc
*/
_setArmature(value: Armature | null): void;
/**
* @internal
* @private
*/
_setDisplayIndex(value: number, isAnimation?: boolean): boolean;
/**
* @internal
* @private
*/
_setZorder(value: number): boolean;
/**
* @internal
* @private
*/
_setColor(value: ColorTransform): boolean;
/**
* @internal
* @private
*/
_setDisplayList(value: Array<any> | null): boolean;
/**
* @internal
* @private
*/
init(slotData: SlotData, displayDatas: Array<DisplayData | null> | null, rawDisplay: any, meshDisplay: any): void;
/**
* @internal
* @private
*/
update(cacheFrameIndex: number): void;
/**
* @private
*/
updateTransformAndMatrix(): void;
/**
* @private
*/
replaceDisplayData(value: DisplayData | null, displayIndex?: number): void;
/**
* - Check whether a specific point is inside a custom bounding box in the slot.
* The coordinate system of the point is the inner coordinate system of the armature.
* Custom bounding boxes need to be customized in Dragonbones Pro.
* @param x - The horizontal coordinate of the point.
* @param y - The vertical coordinate of the point.
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
*
* DragonBones Pro
* @param x -
* @param y -
* @version DragonBones 5.0
* @language zh_CN
*/
containsPoint(x: number, y: number): boolean;
/**
* - Check whether a specific segment intersects a custom bounding box for the slot.
* The coordinate system of the segment and intersection is the inner coordinate system of the armature.
* Custom bounding boxes need to be customized in Dragonbones Pro.
* @param xA - The horizontal coordinate of the beginning of the segment.
* @param yA - The vertical coordinate of the beginning of the segment.
* @param xB - The horizontal coordinate of the end point of the segment.
* @param yB - The vertical coordinate of the end point of the segment.
* @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated)
* @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated)
* @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated)
* @returns Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections]
* @version DragonBones 5.0
* @language en_US
*/
/**
* - 线
* 线
* DragonBones Pro
* @param xA - 线
* @param yA - 线
* @param xB - 线
* @param yB - 线
* @param intersectionPointA - 线
* @param intersectionPointB - 线
* @param normalRadians - 线线 [x: 线线, y: 线线] 线
* @returns [-1: 线, 0: , 1: , 2: , 3: , N: N ]
* @version DragonBones 5.0
* @language zh_CN
*/
intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: {
x: number;
y: number;
} | null, intersectionPointB?: {
x: number;
y: number;
} | null, normalRadians?: {
x: number;
y: number;
} | null): number;
/**
* - Forces the slot to update the state of the display object in the next frame.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @version DragonBones 4.5
* @language zh_CN
*/
invalidUpdate(): void;
/**
* - The visible of slot's display object.
* @default true
* @version DragonBones 5.6
* @language en_US
*/
/**
* -
* @default true
* @version DragonBones 5.6
* @language zh_CN
*/
visible: boolean;
/**
* - The index of the display object displayed in the display list.
* @example
* <pre>
* let slot = armature.getSlot("weapon");
* slot.displayIndex = 3;
* slot.displayController = "none";
* </pre>
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @example
* <pre>
* let slot = armature.getSlot("weapon");
* slot.displayIndex = 3;
* slot.displayController = "none";
* </pre>
* @version DragonBones 4.5
* @language zh_CN
*/
displayIndex: number;
/**
* - The slot name.
* @see dragonBones.SlotData#name
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @see dragonBones.SlotData#name
* @version DragonBones 3.0
* @language zh_CN
*/
readonly name: string;
/**
* - Contains a display list of display objects or child armatures.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
displayList: Array<any>;
/**
* - The slot data.
* @see dragonBones.SlotData
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @see dragonBones.SlotData
* @version DragonBones 4.5
* @language zh_CN
*/
readonly slotData: SlotData;
/**
* @private
*/
rawDisplayDatas: Array<DisplayData | null> | null;
/**
* - The custom bounding box data for the slot at current time.
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* @version DragonBones 5.0
* @language zh_CN
*/
readonly boundingBoxData: BoundingBoxData | null;
/**
* @private
*/
readonly rawDisplay: any;
/**
* @private
*/
readonly meshDisplay: any;
/**
* - The display object that the slot displays at this time.
* @example
* <pre>
* let slot = armature.getSlot("text");
* slot.display = new yourEngine.TextField();
* </pre>
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @example
* <pre>
* let slot = armature.getSlot("text");
* slot.display = new yourEngine.TextField();
* </pre>
* @version DragonBones 3.0
* @language zh_CN
*/
display: any;
/**
* - The child armature that the slot displayed at current time.
* @example
* <pre>
* let slot = armature.getSlot("weapon");
* slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
* </pre>
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @example
* <pre>
* let slot = armature.getSlot("weapon");
* slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
* </pre>
* @version DragonBones 3.0
* @language zh_CN
*/
childArmature: Armature | null;
/**
* - Deprecated, please refer to {@link #display}.
* @deprecated
* @language en_US
*/
/**
* - {@link #display}
* @deprecated
* @language zh_CN
*/
getDisplay(): any;
/**
* - Deprecated, please refer to {@link #display}.
* @deprecated
* @language en_US
*/
/**
* - {@link #display}
* @deprecated
* @language zh_CN
*/
setDisplay(value: any): void;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* @internal
* @private
*/
abstract class Constraint extends BaseObject {
protected static readonly _helpMatrix: Matrix;
protected static readonly _helpTransform: Transform;
protected static readonly _helpPoint: Point;
/**
* - For timeline state.
* @internal
*/
_constraintData: ConstraintData;
protected _armature: Armature;
/**
* - For sort bones.
* @internal
*/
_target: Bone;
/**
* - For sort bones.
* @internal
*/
_root: Bone;
protected _bone: Bone | null;
protected _onClear(): void;
abstract init(constraintData: ConstraintData, armature: Armature): void;
abstract update(): void;
abstract invalidUpdate(): void;
readonly name: string;
}
/**
* @internal
* @private
*/
class IKConstraint extends Constraint {
static toString(): string;
private _scaleEnabled;
/**
* - For timeline state.
* @internal
*/
_bendPositive: boolean;
/**
* - For timeline state.
* @internal
*/
_weight: number;
protected _onClear(): void;
private _computeA();
private _computeB();
init(constraintData: ConstraintData, armature: Armature): void;
update(): void;
invalidUpdate(): void;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - Play animation interface. (Both Armature and Wordclock implement the interface)
* Any instance that implements the interface can be added to the Worldclock instance and advance time by Worldclock instance uniformly.
* @see dragonBones.WorldClock
* @see dragonBones.Armature
* @version DragonBones 3.0
* @language en_US
*/
/**
* - (Armature WordClock )
* WorldClock WorldClock
* @see dragonBones.WorldClock
* @see dragonBones.Armature
* @version DragonBones 3.0
* @language zh_CN
*/
interface IAnimatable {
/**
* - Advance time.
* @param passedTime - Passed time. (In seconds)
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @param passedTime -
* @version DragonBones 3.0
* @language zh_CN
*/
advanceTime(passedTime: number): void;
/**
* - The Wordclock instance to which the current belongs.
* @example
* <pre>
* armature.clock = factory.clock; // Add armature to clock.
* armature.clock = null; // Remove armature from clock.
* </pre>
* @version DragonBones 5.0
* @language en_US
*/
/**
* - WordClock
* @example
* <pre>
* armature.clock = factory.clock; // 将骨架添加到时钟。
* armature.clock = null; // 将骨架从时钟移除。
* </pre>
* @version DragonBones 5.0
* @language zh_CN
*/
clock: WorldClock | null;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance.
* @see dragonBones.IAnimateble
* @see dragonBones.Armature
* @version DragonBones 3.0
* @language en_US
*/
/**
* - WorldClock IAnimatable
* @see dragonBones.IAnimateble
* @see dragonBones.Armature
* @version DragonBones 3.0
* @language zh_CN
*/
class WorldClock implements IAnimatable {
/**
* - Current time. (In seconds)
* @version DragonBones 3.0
* @language en_US
*/
/**
* - ()
* @version DragonBones 3.0
* @language zh_CN
*/
time: number;
/**
* - The play speed, used to control animation speed-shift play.
* [0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play]
* @default 1.0
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* [0: , (0~1): , 1: , (1~N): ]
* @default 1.0
* @version DragonBones 3.0
* @language zh_CN
*/
timeScale: number;
private readonly _animatebles;
private _clock;
/**
* - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance.
* When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time.
* @version DragonBones 3.0
* @language en_US
*/
/**
* - WorldClock WorldClock
* WorldClock 使
* @version DragonBones 3.0
* @language zh_CN
*/
constructor(time?: number);
/**
* - Advance time for all IAnimatable instances.
* @param passedTime - Passed time. [-1: Automatically calculates the time difference between the current frame and the previous frame, [0~N): Passed time] (In seconds)
* @version DragonBones 3.0
* @language en_US
*/
/**
* - IAnimatable
* @param passedTime - [-1: , [0~N): ] ()
* @version DragonBones 3.0
* @language zh_CN
*/
advanceTime(passedTime: number): void;
/**
* - Check whether contains a specific instance of IAnimatable.
* @param value - The IAnimatable instance.
* @version DragonBones 3.0
* @language en_US
*/
/**
* - IAnimatable
* @param value - IAnimatable
* @version DragonBones 3.0
* @language zh_CN
*/
contains(value: IAnimatable): boolean;
/**
* - Add IAnimatable instance.
* @param value - The IAnimatable instance.
* @version DragonBones 3.0
* @language en_US
*/
/**
* - IAnimatable
* @param value - IAnimatable
* @version DragonBones 3.0
* @language zh_CN
*/
add(value: IAnimatable): void;
/**
* - Removes a specified IAnimatable instance.
* @param value - The IAnimatable instance.
* @version DragonBones 3.0
* @language en_US
*/
/**
* - IAnimatable
* @param value - IAnimatable
* @version DragonBones 3.0
* @language zh_CN
*/
remove(value: IAnimatable): void;
/**
* - Clear all IAnimatable instances.
* @version DragonBones 3.0
* @language en_US
*/
/**
* - IAnimatable
* @version DragonBones 3.0
* @language zh_CN
*/
clear(): void;
/**
* @inheritDoc
*/
clock: WorldClock | null;
/**
* - Deprecated, please refer to {@link dragonBones.BaseFactory#clock}.
* @deprecated
* @language en_US
*/
/**
* - {@link dragonBones.BaseFactory#clock}
* @deprecated
* @language zh_CN
*/
static readonly clock: WorldClock;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - The animation player is used to play the animation data and manage the animation states.
* @see dragonBones.AnimationData
* @see dragonBones.AnimationState
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @see dragonBones.AnimationData
* @see dragonBones.AnimationState
* @version DragonBones 3.0
* @language zh_CN
*/
class Animation extends BaseObject {
static toString(): string;
/**
* - The play speed of all animations. [0: Stop, (0~1): Slow, 1: Normal, (1~N): Fast]
* @default 1.0
* @version DragonBones 3.0
* @language en_US
*/
/**
* - [0: , (0~1): , 1: , (1~N): ]
* @default 1.0
* @version DragonBones 3.0
* @language zh_CN
*/
timeScale: number;
private _lockUpdate;
private _animationDirty;
private _inheritTimeScale;
private readonly _animationNames;
private readonly _animationStates;
private readonly _animations;
private _armature;
private _animationConfig;
private _lastAnimationState;
/**
* @private
*/
protected _onClear(): void;
private _fadeOut(animationConfig);
/**
* @internal
* @private
*/
init(armature: Armature): void;
/**
* @internal
* @private
*/
advanceTime(passedTime: number): void;
/**
* - Clear all animations states.
* @see dragonBones.AnimationState
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @see dragonBones.AnimationState
* @version DragonBones 4.5
* @language zh_CN
*/
reset(): void;
/**
* - Pause a specific animation state.
* @param animationName - The name of animation state. (If not set, it will pause all animations)
* @see dragonBones.AnimationState
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @param animationName -
* @see dragonBones.AnimationState
* @version DragonBones 3.0
* @language zh_CN
*/
stop(animationName?: string | null): void;
/**
* - Play animation with a specific animation config.
* The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used.
* @param animationConfig - The animation config.
* @returns The playing animation state.
* @see dragonBones.AnimationConfig
* @beta
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* API 使 bug
* @param animationConfig -
* @returns
* @see dragonBones.AnimationConfig
* @beta
* @version DragonBones 5.0
* @language zh_CN
*/
playConfig(animationConfig: AnimationConfig): AnimationState | null;
/**
* - Play a specific animation.
* @param animationName - The name of animation data. (If not set, The default animation will be played, or resume the animation playing from pause status, or replay the last playing animation)
* @param playTimes - Playing repeat times. [-1: Use default value of the animation data, 0: No end loop playing, [1~N]: Repeat N times] (default: -1)
* @returns The playing animation state.
* @example
* <pre>
* armature.animation.play("walk");
* </pre>
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @param animationName -
* @param playTimes - [-1: 使, 0: , [1~N]: N ] : -1
* @returns
* @example
* <pre>
* armature.animation.play("walk");
* </pre>
* @version DragonBones 3.0
* @language zh_CN
*/
play(animationName?: string | null, playTimes?: number): AnimationState | null;
/**
* - Fade in a specific animation.
* @param animationName - The name of animation data.
* @param fadeInTime - The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1)
* @param playTimes - playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1)
* @param layer - The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0)
* @param group - The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null)
* @param fadeOutMode - The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup)
* @returns The playing animation state.
* @example
* <pre>
* armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
* armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
* </pre>
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @param animationName -
* @param fadeInTime - [-1: 使, [0~N]: ()] : -1
* @param playTimes - [-1: 使, 0: , [1~N]: N ] : -1
* @param layer - 1.0 : 0
* @param group - : null
* @param fadeOutMode - : AnimationFadeOutMode.SameLayerAndGroup
* @returns
* @example
* <pre>
* armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
* armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
* </pre>
* @version DragonBones 4.5
* @language zh_CN
*/
fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode): AnimationState | null;
/**
* - Play a specific animation from the specific time.
* @param animationName - The name of animation data.
* @param time - The start time point of playing. (In seconds)
* @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1)
* @returns The played animation state.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @param animationName -
* @param time - ()
* @param playTimes - [-1: 使, 0: , [1~N]: N ] : -1
* @returns
* @version DragonBones 4.5
* @language zh_CN
*/
gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number): AnimationState | null;
/**
* - Play a specific animation from the specific frame.
* @param animationName - The name of animation data.
* @param frame - The start frame of playing.
* @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1)
* @returns The played animation state.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @param animationName -
* @param frame -
* @param playTimes - [-1: 使, 0: , [1~N]: N ] : -1
* @returns
* @version DragonBones 4.5
* @language zh_CN
*/
gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number): AnimationState | null;
/**
* - Play a specific animation from the specific progress.
* @param animationName - The name of animation data.
* @param progress - The start progress value of playing.
* @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1)
* @returns The played animation state.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @param animationName -
* @param progress -
* @param playTimes - [-1: 使, 0: , [1~N]: N ] : -1
* @returns
* @version DragonBones 4.5
* @language zh_CN
*/
gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number): AnimationState | null;
/**
* - Stop a specific animation at the specific time.
* @param animationName - The name of animation data.
* @param time - The stop time. (In seconds)
* @returns The played animation state.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @param animationName -
* @param time - ()
* @returns
* @version DragonBones 4.5
* @language zh_CN
*/
gotoAndStopByTime(animationName: string, time?: number): AnimationState | null;
/**
* - Stop a specific animation at the specific frame.
* @param animationName - The name of animation data.
* @param frame - The stop frame.
* @returns The played animation state.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @param animationName -
* @param frame -
* @returns
* @version DragonBones 4.5
* @language zh_CN
*/
gotoAndStopByFrame(animationName: string, frame?: number): AnimationState | null;
/**
* - Stop a specific animation at the specific progress.
* @param animationName - The name of animation data.
* @param progress - The stop progress value.
* @returns The played animation state.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @param animationName -
* @param progress -
* @returns
* @version DragonBones 4.5
* @language zh_CN
*/
gotoAndStopByProgress(animationName: string, progress?: number): AnimationState | null;
/**
* - Get a specific animation state.
* @param animationName - The name of animation state.
* @example
* <pre>
* armature.animation.play("walk");
* let walkState = armature.animation.getState("walk");
* walkState.timeScale = 0.5;
* </pre>
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @param animationName -
* @example
* <pre>
* armature.animation.play("walk");
* let walkState = armature.animation.getState("walk");
* walkState.timeScale = 0.5;
* </pre>
* @version DragonBones 3.0
* @language zh_CN
*/
getState(animationName: string): AnimationState | null;
/**
* - Check whether a specific animation data is included.
* @param animationName - The name of animation data.
* @see dragonBones.AnimationData
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @param animationName -
* @see dragonBones.AnimationData
* @version DragonBones 3.0
* @language zh_CN
*/
hasAnimation(animationName: string): boolean;
/**
* - Get all the animation states.
* @version DragonBones 5.1
* @language en_US
*/
/**
* -
* @version DragonBones 5.1
* @language zh_CN
*/
getStates(): Array<AnimationState>;
/**
* - Check whether there is an animation state is playing
* @see dragonBones.AnimationState
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @see dragonBones.AnimationState
* @version DragonBones 3.0
* @language zh_CN
*/
readonly isPlaying: boolean;
/**
* - Check whether all the animation states' playing were finished.
* @see dragonBones.AnimationState
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @see dragonBones.AnimationState
* @version DragonBones 3.0
* @language zh_CN
*/
readonly isCompleted: boolean;
/**
* - The name of the last playing animation state.
* @see #lastAnimationState
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @see #lastAnimationState
* @version DragonBones 3.0
* @language zh_CN
*/
readonly lastAnimationName: string;
/**
* - The name of all animation data
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @version DragonBones 4.5
* @language zh_CN
*/
readonly animationNames: Array<string>;
/**
* - All animation data.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @version DragonBones 4.5
* @language zh_CN
*/
animations: Map<AnimationData>;
/**
* - An AnimationConfig instance that can be used quickly.
* @see dragonBones.AnimationConfig
* @version DragonBones 5.0
* @language en_US
*/
/**
* - 使
* @see dragonBones.AnimationConfig
* @version DragonBones 5.0
* @language zh_CN
*/
readonly animationConfig: AnimationConfig;
/**
* - The last playing animation state
* @see dragonBones.AnimationState
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @see dragonBones.AnimationState
* @version DragonBones 3.0
* @language zh_CN
*/
readonly lastAnimationState: AnimationState | null;
/**
* - Deprecated, please refer to {@link #play()} {@link #fadeIn()}.
* @deprecated
* @language en_US
*/
/**
* - {@link #play()} {@link #fadeIn()}
* @deprecated
* @language zh_CN
*/
gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState | null;
/**
* - Deprecated, please refer to {@link #gotoAndStopByTime()}.
* @deprecated
* @language en_US
*/
/**
* - {@link #gotoAndStopByTime()}
* @deprecated
* @language zh_CN
*/
gotoAndStop(animationName: string, time?: number): AnimationState | null;
/**
* - Deprecated, please refer to {@link #animationNames}.
* @deprecated
* @language en_US
*/
/**
* - {@link #animationNames}
* @deprecated
* @language zh_CN
*/
readonly animationList: Array<string>;
/**
* - Deprecated, please refer to {@link #animationNames}.
* @deprecated
* @language en_US
*/
/**
* - {@link #animationNames}
* @deprecated
* @language zh_CN
*/
readonly animationDataList: Array<AnimationData>;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - The animation state is generated when the animation data is played.
* @see dragonBones.Animation
* @see dragonBones.AnimationData
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @see dragonBones.Animation
* @see dragonBones.AnimationData
* @version DragonBones 3.0
* @language zh_CN
*/
class AnimationState extends BaseObject {
static toString(): string;
/**
* @private
*/
actionEnabled: boolean;
/**
* @private
*/
additiveBlending: boolean;
/**
* - Whether the animation state has control over the display object properties of the slots.
* Sometimes blend a animation state does not want it to control the display object properties of the slots,
* especially if other animation state are controlling the display object properties of the slots.
* @default true
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
*
*
* @default true
* @version DragonBones 5.0
* @language zh_CN
*/
displayControl: boolean;
/**
* - Whether to reset the objects without animation to the armature pose when the animation state is start to play.
* This property should usually be set to false when blend multiple animation states.
* @default true
* @version DragonBones 5.1
* @language en_US
*/
/**
* -
* false
* @default true
* @version DragonBones 5.1
* @language zh_CN
*/
resetToPose: boolean;
/**
* - The play times. [0: Loop play, [1~N]: Play N times]
* @version DragonBones 3.0
* @language en_US
*/
/**
* - [0: , [1~N]: N ]
* @version DragonBones 3.0
* @language zh_CN
*/
playTimes: number;
/**
* - The blend layer.
* High layer animation state will get the blend weight first.
* When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned.
* @readonly
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
*
* 1
* @readonly
* @version DragonBones 5.0
* @language zh_CN
*/
layer: number;
/**
* - The play speed.
* The value is an overlay relationship with {@link dragonBones.Animation#timeScale}.
* [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play]
* @default 1.0
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* {@link dragonBones.Animation#timeScale}
* [(-N~0): , 0: , (0~1): , 1: , (1~N): ]
* @default 1.0
* @version DragonBones 3.0
* @language zh_CN
*/
timeScale: number;
/**
* - The blend weight.
* @default 1.0
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* @default 1.0
* @version DragonBones 5.0
* @language zh_CN
*/
weight: number;
/**
* - The auto fade out time when the animation state play completed.
* [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds)
* @default -1.0
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* [-1: , [0~N]: ]
* @default -1.0
* @version DragonBones 5.0
* @language zh_CN
*/
autoFadeOutTime: number;
/**
* @private
*/
fadeTotalTime: number;
/**
* - The name of the animation state. (Can be different from the name of the animation data)
* @readonly
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* @readonly
* @version DragonBones 5.0
* @language zh_CN
*/
name: string;
/**
* - The blend group name of the animation state.
* This property is typically used to specify the substitution of multiple animation states blend.
* @readonly
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
*
* @readonly
* @version DragonBones 5.0
* @language zh_CN
*/
group: string;
private _timelineDirty;
/**
* - xx: Play Enabled, Fade Play Enabled
* @internal
* @private
*/
_playheadState: number;
/**
* -1: Fade in, 0: Fade complete, 1: Fade out;
* @internal
* @private
*/
_fadeState: number;
/**
* -1: Fade start, 0: Fading, 1: Fade complete;
* @internal
* @private
*/
_subFadeState: number;
/**
* @internal
* @private
*/
_position: number;
/**
* @internal
* @private
*/
_duration: number;
private _fadeTime;
private _time;
/**
* @internal
* @private
*/
_fadeProgress: number;
/**
* @internal
* @private
*/
_weightResult: number;
/**
* @internal
* @private
*/
readonly _blendState: BlendState;
private readonly _boneMask;
private readonly _boneTimelines;
private readonly _surfaceTimelines;
private readonly _slotTimelines;
private readonly _constraintTimelines;
private readonly _animationTimelines;
private readonly _poseTimelines;
private readonly _bonePoses;
/**
* @internal
* @private
*/
_animationData: AnimationData;
private _armature;
/**
* @internal
* @private
*/
_actionTimeline: ActionTimelineState;
private _zOrderTimeline;
/**
* @internal
* @private
*/
_parent: AnimationState;
/**
* @private
*/
protected _onClear(): void;
private _updateTimelines();
private _updateBoneAndSlotTimelines();
private _advanceFadeTime(passedTime);
/**
* @internal
* @private
*/
init(armature: Armature, animationData: AnimationData, animationConfig: AnimationConfig): void;
/**
* @internal
* @private
*/
advanceTime(passedTime: number, cacheFrameRate: number): void;
/**
* - Continue play.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
play(): void;
/**
* - Stop play.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
stop(): void;
/**
* - Fade out the animation state.
* @param fadeOutTime - The fade out time. (In seconds)
* @param pausePlayhead - Whether to pause the animation playing when fade out.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @param fadeOutTime -
* @param pausePlayhead -
* @version DragonBones 3.0
* @language zh_CN
*/
fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void;
/**
* - Check if a specific bone mask is included.
* @param name - The bone name.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @param name -
* @version DragonBones 3.0
* @language zh_CN
*/
containsBoneMask(name: string): boolean;
/**
* - Add a specific bone mask.
* @param name - The bone name.
* @param recursive - Whether or not to add a mask to the bone's sub-bone.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @param name -
* @param recursive -
* @version DragonBones 3.0
* @language zh_CN
*/
addBoneMask(name: string, recursive?: boolean): void;
/**
* - Remove the mask of a specific bone.
* @param name - The bone name.
* @param recursive - Whether to remove the bone's sub-bone mask.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @param name -
* @param recursive -
* @version DragonBones 3.0
* @language zh_CN
*/
removeBoneMask(name: string, recursive?: boolean): void;
/**
* - Remove all bone masks.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
removeAllBoneMask(): void;
/**
* - Whether the animation state is fading in.
* @version DragonBones 5.1
* @language en_US
*/
/**
* -
* @version DragonBones 5.1
* @language zh_CN
*/
readonly isFadeIn: boolean;
/**
* - Whether the animation state is fading out.
* @version DragonBones 5.1
* @language en_US
*/
/**
* -
* @version DragonBones 5.1
* @language zh_CN
*/
readonly isFadeOut: boolean;
/**
* - Whether the animation state is fade completed.
* @version DragonBones 5.1
* @language en_US
*/
/**
* -
* @version DragonBones 5.1
* @language zh_CN
*/
readonly isFadeComplete: boolean;
/**
* - Whether the animation state is playing.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
readonly isPlaying: boolean;
/**
* - Whether the animation state is play completed.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
readonly isCompleted: boolean;
/**
* - The times has been played.
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
readonly currentPlayTimes: number;
/**
* - The total time. (In seconds)
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
readonly totalTime: number;
/**
* - The time is currently playing. (In seconds)
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
currentTime: number;
/**
* - The animation data.
* @see dragonBones.AnimationData
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @see dragonBones.AnimationData
* @version DragonBones 3.0
* @language zh_CN
*/
readonly animationData: AnimationData;
}
/**
* @internal
* @private
*/
class BonePose extends BaseObject {
static toString(): string;
readonly current: Transform;
readonly delta: Transform;
readonly result: Transform;
protected _onClear(): void;
}
/**
* @internal
* @private
*/
class BlendState {
dirty: boolean;
layer: number;
leftWeight: number;
layerWeight: number;
blendWeight: number;
update(weight: number, layer: number): number;
clear(): void;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* @internal
* @private
*/
const enum TweenState {
None = 0,
Once = 1,
Always = 2,
}
/**
* @internal
* @private
*/
abstract class TimelineState extends BaseObject {
playState: number;
currentPlayTimes: number;
currentTime: number;
protected _tweenState: TweenState;
protected _frameRate: number;
protected _frameValueOffset: number;
protected _frameCount: number;
protected _frameOffset: number;
protected _frameIndex: number;
protected _frameRateR: number;
protected _position: number;
protected _duration: number;
protected _timeScale: number;
protected _timeOffset: number;
protected _dragonBonesData: DragonBonesData;
protected _animationData: AnimationData;
protected _timelineData: TimelineData | null;
protected _armature: Armature;
protected _animationState: AnimationState;
protected _actionTimeline: TimelineState;
protected _frameArray: Array<number> | Int16Array;
protected _frameIntArray: Array<number> | Int16Array;
protected _frameFloatArray: Array<number> | Int16Array;
protected _timelineArray: Array<number> | Uint16Array;
protected _frameIndices: Array<number>;
protected _onClear(): void;
protected abstract _onArriveAtFrame(): void;
protected abstract _onUpdateFrame(): void;
protected _setCurrentTime(passedTime: number): boolean;
init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void;
fadeOut(): void;
update(passedTime: number): void;
}
/**
* @internal
* @private
*/
abstract class TweenTimelineState extends TimelineState {
private static _getEasingValue(tweenType, progress, easing);
private static _getEasingCurveValue(progress, samples, count, offset);
protected _tweenType: TweenType;
protected _curveCount: number;
protected _framePosition: number;
protected _frameDurationR: number;
protected _tweenProgress: number;
protected _tweenEasing: number;
protected _onClear(): void;
protected _onArriveAtFrame(): void;
protected _onUpdateFrame(): void;
}
/**
* @internal
* @private
*/
abstract class BoneTimelineState extends TweenTimelineState {
bone: Bone;
bonePose: BonePose;
protected _onClear(): void;
blend(state: number): void;
}
/**
* @internal
* @private
*/
abstract class SlotTimelineState extends TweenTimelineState {
slot: Slot;
protected _onClear(): void;
}
/**
* @internal
* @private
*/
abstract class ConstraintTimelineState extends TweenTimelineState {
constraint: Constraint;
protected _onClear(): void;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* @internal
* @private
*/
class ActionTimelineState extends TimelineState {
static toString(): string;
private _onCrossFrame(frameIndex);
protected _onArriveAtFrame(): void;
protected _onUpdateFrame(): void;
update(passedTime: number): void;
setCurrentTime(value: number): void;
}
/**
* @internal
* @private
*/
class ZOrderTimelineState extends TimelineState {
static toString(): string;
protected _onArriveAtFrame(): void;
protected _onUpdateFrame(): void;
}
/**
* @internal
* @private
*/
class BoneAllTimelineState extends BoneTimelineState {
static toString(): string;
protected _onArriveAtFrame(): void;
protected _onUpdateFrame(): void;
fadeOut(): void;
}
/**
* @internal
* @private
*/
class BoneTranslateTimelineState extends BoneTimelineState {
static toString(): string;
protected _onArriveAtFrame(): void;
protected _onUpdateFrame(): void;
}
/**
* @internal
* @private
*/
class BoneRotateTimelineState extends BoneTimelineState {
static toString(): string;
protected _onArriveAtFrame(): void;
protected _onUpdateFrame(): void;
fadeOut(): void;
}
/**
* @internal
* @private
*/
class BoneScaleTimelineState extends BoneTimelineState {
static toString(): string;
protected _onArriveAtFrame(): void;
protected _onUpdateFrame(): void;
}
/**
* @internal
* @private
*/
class SurfaceTimelineState extends TweenTimelineState {
static toString(): string;
surface: Surface;
private _frameFloatOffset;
private _valueCount;
private _deformCount;
private _valueOffset;
private readonly _current;
private readonly _delta;
private readonly _result;
protected _onClear(): void;
protected _onArriveAtFrame(): void;
protected _onUpdateFrame(): void;
init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void;
blend(state: number): void;
}
/**
* @internal
* @private
*/
class SlotDislayTimelineState extends SlotTimelineState {
static toString(): string;
protected _onArriveAtFrame(): void;
}
/**
* @internal
* @private
*/
class SlotColorTimelineState extends SlotTimelineState {
static toString(): string;
private _dirty;
private readonly _current;
private readonly _delta;
private readonly _result;
protected _onClear(): void;
protected _onArriveAtFrame(): void;
protected _onUpdateFrame(): void;
fadeOut(): void;
update(passedTime: number): void;
}
/**
* @internal
* @private
*/
class SlotFFDTimelineState extends SlotTimelineState {
static toString(): string;
meshOffset: number;
private _dirty;
private _frameFloatOffset;
private _valueCount;
private _deformCount;
private _valueOffset;
private readonly _current;
private readonly _delta;
private readonly _result;
protected _onClear(): void;
protected _onArriveAtFrame(): void;
protected _onUpdateFrame(): void;
init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void;
fadeOut(): void;
update(passedTime: number): void;
}
/**
* @internal
* @private
*/
class IKConstraintTimelineState extends ConstraintTimelineState {
static toString(): string;
private _current;
private _delta;
protected _onClear(): void;
protected _onArriveAtFrame(): void;
protected _onUpdateFrame(): void;
}
/**
* @internal
* @private
*/
class AnimationTimelineState extends TweenTimelineState {
static toString(): string;
animationState: AnimationState;
private readonly _floats;
protected _onClear(): void;
protected _onArriveAtFrame(): void;
protected _onUpdateFrame(): void;
blend(state: number): void;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - The properties of the object carry basic information about an event,
* which are passed as parameter or parameter's parameter to event listeners when an event occurs.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @version DragonBones 4.5
* @language zh_CN
*/
class EventObject extends BaseObject {
/**
* - Animation start play.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @version DragonBones 4.5
* @language zh_CN
*/
static readonly START: string;
/**
* - Animation loop play complete once.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @version DragonBones 4.5
* @language zh_CN
*/
static readonly LOOP_COMPLETE: string;
/**
* - Animation play complete.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @version DragonBones 4.5
* @language zh_CN
*/
static readonly COMPLETE: string;
/**
* - Animation fade in start.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @version DragonBones 4.5
* @language zh_CN
*/
static readonly FADE_IN: string;
/**
* - Animation fade in complete.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @version DragonBones 4.5
* @language zh_CN
*/
static readonly FADE_IN_COMPLETE: string;
/**
* - Animation fade out start.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @version DragonBones 4.5
* @language zh_CN
*/
static readonly FADE_OUT: string;
/**
* - Animation fade out complete.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @version DragonBones 4.5
* @language zh_CN
*/
static readonly FADE_OUT_COMPLETE: string;
/**
* - Animation frame event.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @version DragonBones 4.5
* @language zh_CN
*/
static readonly FRAME_EVENT: string;
/**
* - Animation frame sound event.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @version DragonBones 4.5
* @language zh_CN
*/
static readonly SOUND_EVENT: string;
static toString(): string;
/**
* - If is a frame event, the value is used to describe the time that the event was in the animation timeline. (In seconds)
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @version DragonBones 4.5
* @language zh_CN
*/
time: number;
/**
* - The event type
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @version DragonBones 4.5
* @language zh_CN
*/
type: EventStringType;
/**
* - The event name. (The frame event name or the frame sound name)
* @version DragonBones 4.5
* @language en_US
*/
/**
* - ()
* @version DragonBones 4.5
* @language zh_CN
*/
name: string;
/**
* - The armature that dispatch the event.
* @see dragonBones.Armature
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @see dragonBones.Armature
* @version DragonBones 4.5
* @language zh_CN
*/
armature: Armature;
/**
* - The bone that dispatch the event.
* @see dragonBones.Bone
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @see dragonBones.Bone
* @version DragonBones 4.5
* @language zh_CN
*/
bone: Bone | null;
/**
* - The slot that dispatch the event.
* @see dragonBones.Slot
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @see dragonBones.Slot
* @version DragonBones 4.5
* @language zh_CN
*/
slot: Slot | null;
/**
* - The animation state that dispatch the event.
* @see dragonBones.AnimationState
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @see dragonBones.AnimationState
* @version DragonBones 4.5
* @language zh_CN
*/
animationState: AnimationState;
/**
* - The custom data.
* @see dragonBones.CustomData
* @version DragonBones 5.0
* @language en_US
*/
/**
* -
* @see dragonBones.CustomData
* @version DragonBones 5.0
* @language zh_CN
*/
data: UserData | null;
/**
* @private
*/
protected _onClear(): void;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* @private
*/
type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent";
/**
* - The event dispatcher interface.
* Dragonbones event dispatch usually relies on docking engine to implement, which defines the event method to be implemented when docking the engine.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* DragonBones
* @version DragonBones 4.5
* @language zh_CN
*/
interface IEventDispatcher {
/**
* - Checks whether the object has any listeners registered for a specific type of event
* @param type - Event type.
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @param type -
* @version DragonBones 4.5
* @language zh_CN
*/
hasDBEventListener(type: EventStringType): boolean;
/**
* - Dispatches an event into the event flow.
* @param type - Event type.
* @param eventObject - Event object.
* @see dragonBones.EventObject
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @param type -
* @param eventObject -
* @see dragonBones.EventObject
* @version DragonBones 4.5
* @language zh_CN
*/
dispatchDBEvent(type: EventStringType, eventObject: EventObject): void;
/**
* - Add an event listener object so that the listener receives notification of an event.
* @param type - Event type.
* @param listener - Event listener.
* @param thisObject - The listener function's "this".
* @version DragonBones 4.5
* @language en_US
*/
/**
* - 使
* @param type -
* @param listener -
* @param thisObject - this
* @version DragonBones 4.5
* @language zh_CN
*/
addDBEventListener(type: EventStringType, listener: Function, thisObject: any): void;
/**
* - Removes a listener from the object.
* @param type - Event type.
* @param listener - Event listener.
* @param thisObject - The listener function's "this".
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* @param type -
* @param listener -
* @param thisObject - this
* @version DragonBones 4.5
* @language zh_CN
*/
removeDBEventListener(type: EventStringType, listener: Function, thisObject: any): void;
/**
* - Deprecated, please refer to {@link #hasDBEventListener()}.
* @deprecated
* @language en_US
*/
/**
* - {@link #hasDBEventListener()}
* @deprecated
* @language zh_CN
*/
hasEvent(type: EventStringType): boolean;
/**
* - Deprecated, please refer to {@link #addDBEventListener()}.
* @deprecated
* @language en_US
*/
/**
* - {@link #addDBEventListener()}
* @deprecated
* @language zh_CN
*/
addEvent(type: EventStringType, listener: Function, thisObject: any): void;
/**
* - Deprecated, please refer to {@link #removeDBEventListener()}.
* @deprecated
* @language en_US
*/
/**
* - {@link #removeDBEventListener()}
* @deprecated
* @language zh_CN
*/
removeEvent(type: EventStringType, listener: Function, thisObject: any): void;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* @internal
* @private
*/
abstract class DataParser {
protected static readonly DATA_VERSION_2_3: string;
protected static readonly DATA_VERSION_3_0: string;
protected static readonly DATA_VERSION_4_0: string;
protected static readonly DATA_VERSION_4_5: string;
protected static readonly DATA_VERSION_5_0: string;
protected static readonly DATA_VERSION_5_5: string;
protected static readonly DATA_VERSION: string;
protected static readonly DATA_VERSIONS: Array<string>;
protected static readonly TEXTURE_ATLAS: string;
protected static readonly SUB_TEXTURE: string;
protected static readonly FORMAT: string;
protected static readonly IMAGE_PATH: string;
protected static readonly WIDTH: string;
protected static readonly HEIGHT: string;
protected static readonly ROTATED: string;
protected static readonly FRAME_X: string;
protected static readonly FRAME_Y: string;
protected static readonly FRAME_WIDTH: string;
protected static readonly FRAME_HEIGHT: string;
protected static readonly DRADON_BONES: string;
protected static readonly USER_DATA: string;
protected static readonly ARMATURE: string;
protected static readonly BONE: string;
protected static readonly SURFACE: string;
protected static readonly SLOT: string;
protected static readonly CONSTRAINT: string;
protected static readonly IK: string;
protected static readonly SKIN: string;
protected static readonly DISPLAY: string;
protected static readonly ANIMATION: string;
protected static readonly Z_ORDER: string;
protected static readonly FFD: string;
protected static readonly FRAME: string;
protected static readonly TRANSLATE_FRAME: string;
protected static readonly ROTATE_FRAME: string;
protected static readonly SCALE_FRAME: string;
protected static readonly DISPLAY_FRAME: string;
protected static readonly COLOR_FRAME: string;
protected static readonly DEFAULT_ACTIONS: string;
protected static readonly ACTIONS: string;
protected static readonly EVENTS: string;
protected static readonly INTS: string;
protected static readonly FLOATS: string;
protected static readonly STRINGS: string;
protected static readonly CANVAS: string;
protected static readonly TRANSFORM: string;
protected static readonly PIVOT: string;
protected static readonly AABB: string;
protected static readonly COLOR: string;
protected static readonly VERSION: string;
protected static readonly COMPATIBLE_VERSION: string;
protected static readonly FRAME_RATE: string;
protected static readonly TYPE: string;
protected static readonly SUB_TYPE: string;
protected static readonly NAME: string;
protected static readonly PARENT: string;
protected static readonly TARGET: string;
protected static readonly STAGE: string;
protected static readonly SHARE: string;
protected static readonly PATH: string;
protected static readonly LENGTH: string;
protected static readonly DISPLAY_INDEX: string;
protected static readonly BLEND_MODE: string;
protected static readonly INHERIT_TRANSLATION: string;
protected static readonly INHERIT_ROTATION: string;
protected static readonly INHERIT_SCALE: string;
protected static readonly INHERIT_REFLECTION: string;
protected static readonly INHERIT_ANIMATION: string;
protected static readonly INHERIT_DEFORM: string;
protected static readonly SEGMENT_X: string;
protected static readonly SEGMENT_Y: string;
protected static readonly BEND_POSITIVE: string;
protected static readonly CHAIN: string;
protected static readonly WEIGHT: string;
protected static readonly FADE_IN_TIME: string;
protected static readonly PLAY_TIMES: string;
protected static readonly SCALE: string;
protected static readonly OFFSET: string;
protected static readonly POSITION: string;
protected static readonly DURATION: string;
protected static readonly TWEEN_EASING: string;
protected static readonly TWEEN_ROTATE: string;
protected static readonly TWEEN_SCALE: string;
protected static readonly CLOCK_WISE: string;
protected static readonly CURVE: string;
protected static readonly SOUND: string;
protected static readonly EVENT: string;
protected static readonly ACTION: string;
protected static readonly X: string;
protected static readonly Y: string;
protected static readonly SKEW_X: string;
protected static readonly SKEW_Y: string;
protected static readonly SCALE_X: string;
protected static readonly SCALE_Y: string;
protected static readonly VALUE: string;
protected static readonly ROTATE: string;
protected static readonly SKEW: string;
protected static readonly ALPHA_OFFSET: string;
protected static readonly RED_OFFSET: string;
protected static readonly GREEN_OFFSET: string;
protected static readonly BLUE_OFFSET: string;
protected static readonly ALPHA_MULTIPLIER: string;
protected static readonly RED_MULTIPLIER: string;
protected static readonly GREEN_MULTIPLIER: string;
protected static readonly BLUE_MULTIPLIER: string;
protected static readonly UVS: string;
protected static readonly VERTICES: string;
protected static readonly TRIANGLES: string;
protected static readonly WEIGHTS: string;
protected static readonly SLOT_POSE: string;
protected static readonly BONE_POSE: string;
protected static readonly GLUE_WEIGHTS: string;
protected static readonly GLUE_MESHES: string;
protected static readonly GOTO_AND_PLAY: string;
protected static readonly DEFAULT_NAME: string;
protected static _getArmatureType(value: string): ArmatureType;
protected static _getBoneType(value: string): BoneType;
protected static _getDisplayType(value: string): DisplayType;
protected static _getBoundingBoxType(value: string): BoundingBoxType;
protected static _getActionType(value: string): ActionType;
protected static _getBlendMode(value: string): BlendMode;
abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData | null;
abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): boolean;
/**
* - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}.
* @deprecated
* @language en_US
*/
/**
* - {@link dragonBones.BaseFactory#parsetTextureAtlasData()}
* @deprecated
* @language zh_CN
*/
static parseDragonBonesData(rawData: any): DragonBonesData | null;
/**
* - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}.
* @deprecated
* @language en_US
*/
/**
* - {@link dragonBones.BaseFactory#parsetTextureAtlasData()}
* @deprecated
* @language zh_CN
*/
static parseTextureAtlasData(rawData: any, scale?: number): any;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* @internal
* @private
*/
class ObjectDataParser extends DataParser {
protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean;
protected static _getNumber(rawData: any, key: string, defaultValue: number): number;
protected static _getString(rawData: any, key: string, defaultValue: string): string;
protected _rawTextureAtlasIndex: number;
protected readonly _rawBones: Array<BoneData>;
protected _data: DragonBonesData;
protected _armature: ArmatureData;
protected _bone: BoneData;
protected _surface: SurfaceData;
protected _slot: SlotData;
protected _skin: SkinData;
protected _mesh: MeshDisplayData;
protected _animation: AnimationData;
protected _timeline: TimelineData;
protected _rawTextureAtlases: Array<any> | null;
private _defaultColorOffset;
private _prevClockwise;
private _prevRotation;
private readonly _helpMatrixA;
private readonly _helpMatrixB;
private readonly _helpTransform;
private readonly _helpColorTransform;
private readonly _helpPoint;
private readonly _helpArray;
private readonly _intArray;
private readonly _floatArray;
private readonly _frameIntArray;
private readonly _frameFloatArray;
private readonly _frameArray;
private readonly _timelineArray;
private readonly _cacheRawMeshes;
private readonly _cacheMeshes;
private readonly _actionFrames;
private readonly _weightSlotPose;
private readonly _weightBonePoses;
private readonly _cacheBones;
private readonly _slotChildActions;
private _getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, t, result);
private _samplingEasingCurve(curve, samples);
private _parseActionDataInFrame(rawData, frameStart, bone, slot);
private _mergeActionFrame(rawData, frameStart, type, bone, slot);
protected _parseArmature(rawData: any, scale: number): ArmatureData;
protected _parseBone(rawData: any): BoneData;
protected _parseIKConstraint(rawData: any): ConstraintData | null;
protected _parseSlot(rawData: any, zOrder: number): SlotData;
protected _parseSkin(rawData: any): SkinData;
protected _parseDisplay(rawData: any): DisplayData | null;
protected _parsePivot(rawData: any, display: ImageDisplayData): void;
protected _parseMesh(rawData: any, mesh: MeshDisplayData): void;
protected _parseMeshGlue(rawData: any, mesh: MeshDisplayData): void;
protected _parseBoundingBox(rawData: any): BoundingBoxData | null;
protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData;
protected _parseAnimation(rawData: any): AnimationData;
protected _parseTimeline(rawData: any, rawFrames: Array<any> | null, framesKey: string, type: TimelineType, addIntOffset: boolean, addFloatOffset: boolean, frameValueCount: number, frameParser: (rawData: any, frameStart: number, frameCount: number) => number): TimelineData | null;
protected _parseBoneTimeline(rawData: any): void;
protected _parseSlotTimeline(rawData: any): void;
protected _parseFrame(rawData: any, frameStart: number, frameCount: number): number;
protected _parseTweenFrame(rawData: any, frameStart: number, frameCount: number): number;
protected _parseActionFrame(frame: ActionFrame, frameStart: number, frameCount: number): number;
protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): number;
protected _parseBoneAllFrame(rawData: any, frameStart: number, frameCount: number): number;
protected _parseBoneTranslateFrame(rawData: any, frameStart: number, frameCount: number): number;
protected _parseBoneRotateFrame(rawData: any, frameStart: number, frameCount: number): number;
protected _parseBoneScaleFrame(rawData: any, frameStart: number, frameCount: number): number;
protected _parseSurfaceFrame(rawData: any, frameStart: number, frameCount: number): number;
protected _parseSlotDisplayFrame(rawData: any, frameStart: number, frameCount: number): number;
protected _parseSlotColorFrame(rawData: any, frameStart: number, frameCount: number): number;
protected _parseSlotFFDFrame(rawData: any, frameStart: number, frameCount: number): number;
protected _parseIKConstraintFrame(rawData: any, frameStart: number, frameCount: number): number;
protected _parseAnimationFrame(rawData: any, frameStart: number, frameCount: number): number;
protected _parseActionData(rawData: any, type: ActionType, bone: BoneData | null, slot: SlotData | null): Array<ActionData>;
protected _parseTransform(rawData: any, transform: Transform, scale: number): void;
protected _parseColorTransform(rawData: any, color: ColorTransform): void;
protected _parseArray(rawData: any): void;
protected _modifyArray(): void;
parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null;
parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): boolean;
private static _objectDataParserInstance;
/**
* - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}.
* @deprecated
* @language en_US
*/
/**
* - {@link dragonBones.BaseFactory#parseDragonBonesData()}
* @deprecated
* @language zh_CN
*/
static getInstance(): ObjectDataParser;
}
/**
* @internal
* @private
*/
class ActionFrame {
frameStart: number;
readonly actions: Array<number>;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* @internal
* @private
*/
class BinaryDataParser extends ObjectDataParser {
private _binaryOffset;
private _binary;
private _intArrayBuffer;
private _floatArrayBuffer;
private _frameIntArrayBuffer;
private _frameFloatArrayBuffer;
private _frameArrayBuffer;
private _timelineArrayBuffer;
private _inRange(a, min, max);
private _decodeUTF8(data);
private _getUTF16Key(value);
private _parseBinaryTimeline(type, offset, timelineData?);
protected _parseMesh(rawData: any, mesh: MeshDisplayData): void;
protected _parseAnimation(rawData: any): AnimationData;
protected _parseArray(rawData: any): void;
parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null;
private static _binaryDataParserInstance;
/**
* - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}.
* @deprecated
* @language en_US
*/
/**
* - {@link dragonBones.BaseFactory#parseDragonBonesData()}
* @deprecated
* @language zh_CN
*/
static getInstance(): BinaryDataParser;
}
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2017 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare namespace dragonBones {
/**
* - Base class for the factory that create the armatures. (Typically only one global factory instance is required)
* The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances.
* Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance.
* @see dragonBones.DragonBonesData
* @see dragonBones.TextureAtlasData
* @see dragonBones.ArmatureData
* @see dragonBones.Armature
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* DragonBonesData TextureAtlasData
*
* @see dragonBones.DragonBonesData
* @see dragonBones.TextureAtlasData
* @see dragonBones.ArmatureData
* @see dragonBones.Armature
* @version DragonBones 3.0
* @language zh_CN
*/
abstract class BaseFactory {
/**
* @private
*/
protected static _objectParser: ObjectDataParser;
/**
* @private
*/
protected static _binaryParser: BinaryDataParser;
/**
* @private
*/
autoSearch: boolean;
/**
* @private
*/
protected readonly _dragonBonesDataMap: Map<DragonBonesData>;
/**
* @private
*/
protected readonly _textureAtlasDataMap: Map<Array<TextureAtlasData>>;
/**
* @private
*/
protected _dragonBones: DragonBones;
/**
* @private
*/
protected _dataParser: DataParser;
/**
* - Create a factory instance. (typically only one global factory instance is required)
* @version DragonBones 3.0
* @language en_US
*/
/**
* -
* @version DragonBones 3.0
* @language zh_CN
*/
constructor(dataParser?: DataParser | null);
/**
* @private
*/
protected _isSupportMesh(): boolean;
/**
* @private
*/
protected _getTextureData(textureAtlasName: string, textureName: string): TextureData | null;
/**
* @private
*/
protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean;
/**
* @private
*/
protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void;
/**
* @private
*/
protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void;
/**
* @private
*/
protected _buildChildArmature(dataPackage: BuildArmaturePackage | null, slot: Slot, displayData: DisplayData): Armature | null;
/**
* @private
*/
protected _getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, rawDisplayData: DisplayData | null, slot: Slot): any;
/**
* @private
*/
protected abstract _buildTextureAtlasData(textureAtlasData: TextureAtlasData | null, textureAtlas: any): TextureAtlasData;
/**
* @private
*/
protected abstract _buildArmature(dataPackage: BuildArmaturePackage): Armature;
/**
* @private
*/
protected abstract _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, displays: Array<DisplayData | null> | null, armature: Armature): Slot;
/**
* - Parse the raw data to a DragonBonesData instance and cache it to the factory.
* @param rawData - The raw data.
* @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead)
* @param scale - Specify a scaling value for all armatures. (Default: 1.0)
* @returns DragonBonesData instance
* @see #getDragonBonesData()
* @see #addDragonBonesData()
* @see #removeDragonBonesData()
* @see dragonBones.DragonBonesData
* @version DragonBones 4.5
* @language en_US
*/
/**
* - DragonBonesData
* @param rawData -
* @param name - 便 使
* @param scale - : 1.0
* @returns DragonBonesData
* @see #getDragonBonesData()
* @see #addDragonBonesData()
* @see #removeDragonBonesData()
* @see dragonBones.DragonBonesData
* @version DragonBones 4.5
* @language zh_CN
*/
parseDragonBonesData(rawData: any, name?: string | null, scale?: number): DragonBonesData | null;
/**
* - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory.
* @param rawData - The raw texture atlas data.
* @param textureAtlas - The texture atlas object.
* @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead)
* @param scale - Specify a scaling value for the map set. (Default: 1.0)
* @returns TextureAtlasData instance
* @see #getTextureAtlasData()
* @see #addTextureAtlasData()
* @see #removeTextureAtlasData()
* @see dragonBones.TextureAtlasData
* @version DragonBones 4.5
* @language en_US
*/
/**
* - TextureAtlasData
* @param rawData -
* @param textureAtlas -
* @param name - 便 使
* @param scale - : 1.0
* @returns TextureAtlasData
* @see #getTextureAtlasData()
* @see #addTextureAtlasData()
* @see #removeTextureAtlasData()
* @see dragonBones.TextureAtlasData
* @version DragonBones 4.5
* @language zh_CN
*/
parseTextureAtlasData(rawData: any, textureAtlas: any, name?: string | null, scale?: number): TextureAtlasData;
/**
* @private
*/
updateTextureAtlasData(name: string, textureAtlases: Array<any>): void;
/**
* - Get a specific DragonBonesData instance.
* @param name - The DragonBonesData instance cache name.
* @returns DragonBonesData instance
* @see #parseDragonBonesData()
* @see #addDragonBonesData()
* @see #removeDragonBonesData()
* @see dragonBones.DragonBonesData
* @version DragonBones 3.0
* @language en_US
*/
/**
* - DragonBonesData
* @param name - DragonBonesData
* @returns DragonBonesData
* @see #parseDragonBonesData()
* @see #addDragonBonesData()
* @see #removeDragonBonesData()
* @see dragonBones.DragonBonesData
* @version DragonBones 3.0
* @language zh_CN
*/
getDragonBonesData(name: string): DragonBonesData | null;
/**
* - Cache a DragonBonesData instance to the factory.
* @param data - The DragonBonesData instance.
* @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead)
* @see #parseDragonBonesData()
* @see #getDragonBonesData()
* @see #removeDragonBonesData()
* @see dragonBones.DragonBonesData
* @version DragonBones 3.0
* @language en_US
*/
/**
* - DragonBonesData
* @param data - DragonBonesData
* @param name - 便 使
* @see #parseDragonBonesData()
* @see #getDragonBonesData()
* @see #removeDragonBonesData()
* @see dragonBones.DragonBonesData
* @version DragonBones 3.0
* @language zh_CN
*/
addDragonBonesData(data: DragonBonesData, name?: string | null): void;
/**
* - Remove a DragonBonesData instance.
* @param name - The DragonBonesData instance cache name.
* @param disposeData - Whether to dispose data. (Default: true)
* @see #parseDragonBonesData()
* @see #getDragonBonesData()
* @see #addDragonBonesData()
* @see dragonBones.DragonBonesData
* @version DragonBones 3.0
* @language en_US
*/
/**
* - DragonBonesData
* @param name - DragonBonesData
* @param disposeData - : true
* @see #parseDragonBonesData()
* @see #getDragonBonesData()
* @see #addDragonBonesData()
* @see dragonBones.DragonBonesData
* @version DragonBones 3.0
* @language zh_CN
*/
removeDragonBonesData(name: string, disposeData?: boolean): void;
/**
* - Get a list of specific TextureAtlasData instances.
* @param name - The TextureAtlasData cahce name.
* @see #parseTextureAtlasData()
* @see #addTextureAtlasData()
* @see #removeTextureAtlasData()
* @see dragonBones.TextureAtlasData
* @version DragonBones 3.0
* @language en_US
*/
/**
* - TextureAtlasData
* @param name - TextureAtlasData
* @see #parseTextureAtlasData()
* @see #addTextureAtlasData()
* @see #removeTextureAtlasData()
* @see dragonBones.TextureAtlasData
* @version DragonBones 3.0
* @language zh_CN
*/
getTextureAtlasData(name: string): Array<TextureAtlasData> | null;
/**
* - Cache a TextureAtlasData instance to the factory.
* @param data - The TextureAtlasData instance.
* @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead)
* @see #parseTextureAtlasData()
* @see #getTextureAtlasData()
* @see #removeTextureAtlasData()
* @see dragonBones.TextureAtlasData
* @version DragonBones 3.0
* @language en_US
*/
/**
* - TextureAtlasData
* @param data - TextureAtlasData
* @param name - 便 使
* @see #parseTextureAtlasData()
* @see #getTextureAtlasData()
* @see #removeTextureAtlasData()
* @see dragonBones.TextureAtlasData
* @version DragonBones 3.0
* @language zh_CN
*/
addTextureAtlasData(data: TextureAtlasData, name?: string | null): void;
/**
* - Remove a TextureAtlasData instance.
* @param name - The TextureAtlasData instance cache name.
* @param disposeData - Whether to dispose data.
* @see #parseTextureAtlasData()
* @see #getTextureAtlasData()
* @see #addTextureAtlasData()
* @see dragonBones.TextureAtlasData
* @version DragonBones 3.0
* @language en_US
*/
/**
* - TextureAtlasData
* @param name - TextureAtlasData
* @param disposeData -
* @see #parseTextureAtlasData()
* @see #getTextureAtlasData()
* @see #addTextureAtlasData()
* @see dragonBones.TextureAtlasData
* @version DragonBones 3.0
* @language zh_CN
*/
removeTextureAtlasData(name: string, disposeData?: boolean): void;
/**
* - Get a specific armature data.
* @param name - The armature data name.
* @param dragonBonesName - The cached name for DragonbonesData instance.
* @see dragonBones.ArmatureData
* @version DragonBones 5.1
* @language en_US
*/
/**
* -
* @param name -
* @param dragonBonesName - DragonBonesData
* @see dragonBones.ArmatureData
* @version DragonBones 5.1
* @language zh_CN
*/
getArmatureData(name: string, dragonBonesName?: string): ArmatureData | null;
/**
* - Clear all cached DragonBonesData instances and TextureAtlasData instances.
* @param disposeData - Whether to dispose data.
* @version DragonBones 4.5
* @language en_US
*/
/**
* - DragonBonesData TextureAtlasData
* @param disposeData -
* @version DragonBones 4.5
* @language zh_CN
*/
clear(disposeData?: boolean): void;
/**
* - Create a armature from cached DragonBonesData instances and TextureAtlasData instances.
* @param armatureName - The armature data name.
* @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature)
* @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data)
* @returns The armature.
* @example
* <pre>
* let armature = factory.buildArmature("armatureName", "dragonBonesName");
* armature.clock = factory.clock;
* </pre>
* @see dragonBones.DragonBonesData
* @see dragonBones.ArmatureData
* @see dragonBones.Armature
* @version DragonBones 3.0
* @language en_US
*/
/**
* - DragonBonesData TextureAtlasData
* @param armatureName -
* @param dragonBonesName - DragonBonesData DragonBonesData DragonBonesData
* @param skinName - 使
* @returns
* @example
* <pre>
* let armature = factory.buildArmature("armatureName", "dragonBonesName");
* armature.clock = factory.clock;
* </pre>
* @see dragonBones.DragonBonesData
* @see dragonBones.ArmatureData
* @see dragonBones.Armature
* @version DragonBones 3.0
* @language zh_CN
*/
buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): Armature | null;
/**
* @private
*/
replaceDisplay(slot: Slot, displayData: DisplayData, displayIndex?: number): void;
/**
* - Replaces the current display data for a particular slot with a specific display data.
* Specify display data with "dragonBonesName/armatureName/slotName/displayName".
* @param dragonBonesName - The DragonBonesData instance cache name.
* @param armatureName - The armature data name.
* @param slotName - The slot data name.
* @param displayName - The display data name.
* @param slot - The slot.
* @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data)
* @example
* <pre>
* let slot = armature.getSlot("weapon");
* factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
* </pre>
* @version DragonBones 4.5
* @language en_US
*/
/**
* -
* "dragonBonesName/armatureName/slotName/displayName"
* @param dragonBonesName - DragonBonesData
* @param armatureName -
* @param slotName -
* @param displayName -
* @param slot -
* @param displayIndex -
* @example
* <pre>
* let slot = armature.getSlot("weapon");
* factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
* </pre>
* @version DragonBones 4.5
* @language zh_CN
*/
replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): boolean;
/**
* @private
*/
replaceSlotDisplayList(dragonBonesName: string | null, armatureName: string, slotName: string, slot: Slot): boolean;
/**
* - Share specific skin data with specific armature.
* @param armature - The armature.
* @param skin - The skin data.
* @param isOverride - Whether it completely override the original skin. (Default: false)
* @param exclude - A list of slot names that do not need to be replace.
* @example
* <pre>
* let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
* let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
* if (armatureDataB && armatureDataB.defaultSkin) {
* factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
* }
* </pre>
* @see dragonBones.Armature
* @see dragonBones.SkinData
* @version DragonBones 5.6
* @language en_US
*/
/**
* - 使
* @param armature -
* @param skin -
* @param isOverride - : false
* @param exclude -
* @example
* <pre>
* let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
* let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
* if (armatureDataB && armatureDataB.defaultSkin) {
* factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
* }
* </pre>
* @see dragonBones.Armature
* @see dragonBones.SkinData
* @version DragonBones 5.6
* @language zh_CN
*/
replaceSkin(armature: Armature, skin: SkinData, isOverride?: boolean, exclude?: Array<string> | null): boolean;
/**
* - Replaces the existing animation data for a specific armature with the animation data for the specific armature data.
* This enables you to make a armature template so that other armature without animations can share it's animations.
* @param armature - The armtaure.
* @param armatureData - The armature data.
* @param isOverride - Whether to completely overwrite the original animation. (Default: false)
* @example
* <pre>
* let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
* let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
* if (armatureDataB) {
* factory.replaceAnimation(armatureA, armatureDataB);
* }
* </pre>
* @see dragonBones.Armature
* @see dragonBones.ArmatureData
* @version DragonBones 5.6
* @language en_US
*/
/**
* -
*
* @param armature -
* @param armatureData -
* @param isOverride - : false
* @example
* <pre>
* let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
* let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
* if (armatureDataB) {
* factory.replaceAnimation(armatureA, armatureDataB);
* }
* </pre>
* @see dragonBones.Armature
* @see dragonBones.ArmatureData
* @version DragonBones 5.6
* @language zh_CN
*/
replaceAnimation(armature: Armature, armatureData: ArmatureData, isOverride?: boolean): boolean;
/**
* @private
*/
getAllDragonBonesData(): Map<DragonBonesData>;
/**
* @private
*/
getAllTextureAtlasData(): Map<Array<TextureAtlasData>>;
/**
* - An Worldclock instance updated by engine.
* @version DragonBones 5.7
* @language en_US
*/
/**
* - WorldClock
* @version DragonBones 5.7
* @language zh_CN
*/
readonly clock: WorldClock;
/**
* @private
*/
readonly dragonBones: DragonBones;
/**
* - Deprecated, please refer to {@link #replaceSkin}.
* @deprecated
* @language en_US
*/
/**
* - {@link #replaceSkin}
* @deprecated
* @language zh_CN
*/
changeSkin(armature: Armature, skin: SkinData, exclude?: Array<string> | null): boolean;
/**
* - Deprecated, please refer to {@link #replaceAnimation}.
* @deprecated
* @language en_US
*/
/**
* - {@link #replaceAnimation}
* @deprecated
* @language zh_CN
*/
copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string, fromDragonBonesDataName?: string, replaceOriginalAnimation?: boolean): boolean;
}
/**
* @internal
* @private
*/
class BuildArmaturePackage {
dataName: string;
textureAtlasName: string;
data: DragonBonesData;
armature: ArmatureData;
skin: SkinData | null;
}
}
declare namespace sp.spine {
class Animation {
name: string;
timelines: Array<Timeline>;
timelineIds: Array<boolean>;
duration: number;
constructor(name: string, timelines: Array<Timeline>, duration: number);
hasTimeline(id: number): boolean;
apply(skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
static binarySearch(values: ArrayLike<number>, target: number, step?: number): number;
static linearSearch(values: ArrayLike<number>, target: number, step: number): number;
}
interface Timeline {
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
getPropertyId(): number;
}
enum MixBlend {
setup = 0,
first = 1,
replace = 2,
add = 3
}
enum MixDirection {
mixIn = 0,
mixOut = 1
}
enum TimelineType {
rotate = 0,
translate = 1,
scale = 2,
shear = 3,
attachment = 4,
color = 5,
deform = 6,
event = 7,
drawOrder = 8,
ikConstraint = 9,
transformConstraint = 10,
pathConstraintPosition = 11,
pathConstraintSpacing = 12,
pathConstraintMix = 13,
twoColor = 14
}
abstract class CurveTimeline implements Timeline {
static LINEAR: number;
static STEPPED: number;
static BEZIER: number;
static BEZIER_SIZE: number;
private curves;
abstract getPropertyId(): number;
constructor(frameCount: number);
getFrameCount(): number;
setLinear(frameIndex: number): void;
setStepped(frameIndex: number): void;
getCurveType(frameIndex: number): number;
setCurve(frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void;
getCurvePercent(frameIndex: number, percent: number): number;
abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
}
class RotateTimeline extends CurveTimeline {
static ENTRIES: number;
static PREV_TIME: number;
static PREV_ROTATION: number;
static ROTATION: number;
boneIndex: number;
frames: ArrayLike<number>;
constructor(frameCount: number);
getPropertyId(): number;
setFrame(frameIndex: number, time: number, degrees: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
}
class TranslateTimeline extends CurveTimeline {
static ENTRIES: number;
static PREV_TIME: number;
static PREV_X: number;
static PREV_Y: number;
static X: number;
static Y: number;
boneIndex: number;
frames: ArrayLike<number>;
constructor(frameCount: number);
getPropertyId(): number;
setFrame(frameIndex: number, time: number, x: number, y: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
}
class ScaleTimeline extends TranslateTimeline {
constructor(frameCount: number);
getPropertyId(): number;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
}
class ShearTimeline extends TranslateTimeline {
constructor(frameCount: number);
getPropertyId(): number;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
}
class ColorTimeline extends CurveTimeline {
static ENTRIES: number;
static PREV_TIME: number;
static PREV_R: number;
static PREV_G: number;
static PREV_B: number;
static PREV_A: number;
static R: number;
static G: number;
static B: number;
static A: number;
slotIndex: number;
frames: ArrayLike<number>;
constructor(frameCount: number);
getPropertyId(): number;
setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
}
class TwoColorTimeline extends CurveTimeline {
static ENTRIES: number;
static PREV_TIME: number;
static PREV_R: number;
static PREV_G: number;
static PREV_B: number;
static PREV_A: number;
static PREV_R2: number;
static PREV_G2: number;
static PREV_B2: number;
static R: number;
static G: number;
static B: number;
static A: number;
static R2: number;
static G2: number;
static B2: number;
slotIndex: number;
frames: ArrayLike<number>;
constructor(frameCount: number);
getPropertyId(): number;
setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number, r2: number, g2: number, b2: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
}
class AttachmentTimeline implements Timeline {
slotIndex: number;
frames: ArrayLike<number>;
attachmentNames: Array<string>;
constructor(frameCount: number);
getPropertyId(): number;
getFrameCount(): number;
setFrame(frameIndex: number, time: number, attachmentName: string): void;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
}
class DeformTimeline extends CurveTimeline {
slotIndex: number;
attachment: VertexAttachment;
frames: ArrayLike<number>;
frameVertices: Array<ArrayLike<number>>;
constructor(frameCount: number);
getPropertyId(): number;
setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void;
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
}
class EventTimeline implements Timeline {
frames: ArrayLike<number>;
events: Array<Event>;
constructor(frameCount: number);
getPropertyId(): number;
getFrameCount(): number;
setFrame(frameIndex: number, event: Event): void;
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
}
class DrawOrderTimeline implements Timeline {
frames: ArrayLike<number>;
drawOrders: Array<Array<number>>;
constructor(frameCount: number);
getPropertyId(): number;
getFrameCount(): number;
setFrame(frameIndex: number, time: number, drawOrder: Array<number>): void;
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
}
class IkConstraintTimeline extends CurveTimeline {
static ENTRIES: number;
static PREV_TIME: number;
static PREV_MIX: number;
static PREV_SOFTNESS: number;
static PREV_BEND_DIRECTION: number;
static PREV_COMPRESS: number;
static PREV_STRETCH: number;
static MIX: number;
static SOFTNESS: number;
static BEND_DIRECTION: number;
static COMPRESS: number;
static STRETCH: number;
ikConstraintIndex: number;
frames: ArrayLike<number>;
constructor(frameCount: number);
getPropertyId(): number;
setFrame(frameIndex: number, time: number, mix: number, softness: number, bendDirection: number, compress: boolean, stretch: boolean): void;
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
}
class TransformConstraintTimeline extends CurveTimeline {
static ENTRIES: number;
static PREV_TIME: number;
static PREV_ROTATE: number;
static PREV_TRANSLATE: number;
static PREV_SCALE: number;
static PREV_SHEAR: number;
static ROTATE: number;
static TRANSLATE: number;
static SCALE: number;
static SHEAR: number;
transformConstraintIndex: number;
frames: ArrayLike<number>;
constructor(frameCount: number);
getPropertyId(): number;
setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number, scaleMix: number, shearMix: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
}
class PathConstraintPositionTimeline extends CurveTimeline {
static ENTRIES: number;
static PREV_TIME: number;
static PREV_VALUE: number;
static VALUE: number;
pathConstraintIndex: number;
frames: ArrayLike<number>;
constructor(frameCount: number);
getPropertyId(): number;
setFrame(frameIndex: number, time: number, value: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
}
class PathConstraintSpacingTimeline extends PathConstraintPositionTimeline {
constructor(frameCount: number);
getPropertyId(): number;
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
}
class PathConstraintMixTimeline extends CurveTimeline {
static ENTRIES: number;
static PREV_TIME: number;
static PREV_ROTATE: number;
static PREV_TRANSLATE: number;
static ROTATE: number;
static TRANSLATE: number;
pathConstraintIndex: number;
frames: ArrayLike<number>;
constructor(frameCount: number);
getPropertyId(): number;
setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
}
}
declare namespace sp.spine {
class AnimationState {
static emptyAnimation: Animation;
static SUBSEQUENT: number;
static FIRST: number;
static HOLD: number;
static HOLD_MIX: number;
static NOT_LAST: number;
data: AnimationStateData;
tracks: TrackEntry[];
timeScale: number;
events: Event[];
listeners: AnimationStateListener[];
queue: EventQueue;
propertyIDs: IntSet;
animationsChanged: boolean;
trackEntryPool: Pool<TrackEntry>;
constructor(data: AnimationStateData);
update(delta: number): void;
updateMixingFrom(to: TrackEntry, delta: number): boolean;
apply(skeleton: Skeleton): boolean;
applyMixingFrom(to: TrackEntry, skeleton: Skeleton, blend: MixBlend): number;
applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, blend: MixBlend, timelinesRotation: Array<number>, i: number, firstFrame: boolean): void;
queueEvents(entry: TrackEntry, animationTime: number): void;
clearTracks(): void;
clearTrack(trackIndex: number): void;
setCurrent(index: number, current: TrackEntry, interrupt: boolean): void;
setAnimation(trackIndex: number, animationName: string, loop: boolean): TrackEntry;
setAnimationWith(trackIndex: number, animation: Animation, loop: boolean): TrackEntry;
addAnimation(trackIndex: number, animationName: string, loop: boolean, delay: number): TrackEntry;
addAnimationWith(trackIndex: number, animation: Animation, loop: boolean, delay: number): TrackEntry;
setEmptyAnimation(trackIndex: number, mixDuration: number): TrackEntry;
addEmptyAnimation(trackIndex: number, mixDuration: number, delay: number): TrackEntry;
setEmptyAnimations(mixDuration: number): void;
expandToIndex(index: number): TrackEntry;
trackEntry(trackIndex: number, animation: Animation, loop: boolean, last: TrackEntry): TrackEntry;
disposeNext(entry: TrackEntry): void;
_animationsChanged(): void;
computeHold(entry: TrackEntry): void;
computeNotLast(entry: TrackEntry): void;
getCurrent(trackIndex: number): TrackEntry;
addListener(listener: AnimationStateListener): void;
removeListener(listener: AnimationStateListener): void;
clearListeners(): void;
clearListenerNotifications(): void;
}
class TrackEntry {
animation: Animation;
next: TrackEntry;
mixingFrom: TrackEntry;
mixingTo: TrackEntry;
listener: AnimationStateListener;
trackIndex: number;
loop: boolean;
holdPrevious: boolean;
eventThreshold: number;
attachmentThreshold: number;
drawOrderThreshold: number;
animationStart: number;
animationEnd: number;
animationLast: number;
nextAnimationLast: number;
delay: number;
trackTime: number;
trackLast: number;
nextTrackLast: number;
trackEnd: number;
timeScale: number;
alpha: number;
mixTime: number;
mixDuration: number;
interruptAlpha: number;
totalAlpha: number;
mixBlend: MixBlend;
timelineMode: number[];
timelineHoldMix: TrackEntry[];
timelinesRotation: number[];
reset(): void;
getAnimationTime(): number;
setAnimationLast(animationLast: number): void;
isComplete(): boolean;
resetRotationDirections(): void;
}
class EventQueue {
objects: Array<any>;
drainDisabled: boolean;
animState: AnimationState;
constructor(animState: AnimationState);
start(entry: TrackEntry): void;
interrupt(entry: TrackEntry): void;
end(entry: TrackEntry): void;
dispose(entry: TrackEntry): void;
complete(entry: TrackEntry): void;
event(entry: TrackEntry, event: Event): void;
drain(): void;
clear(): void;
}
enum EventType {
start = 0,
interrupt = 1,
end = 2,
dispose = 3,
complete = 4,
event = 5
}
interface AnimationStateListener {
start(entry: TrackEntry): void;
interrupt(entry: TrackEntry): void;
end(entry: TrackEntry): void;
dispose(entry: TrackEntry): void;
complete(entry: TrackEntry): void;
event(entry: TrackEntry, event: Event): void;
}
abstract class AnimationStateAdapter implements AnimationStateListener {
start(entry: TrackEntry): void;
interrupt(entry: TrackEntry): void;
end(entry: TrackEntry): void;
dispose(entry: TrackEntry): void;
complete(entry: TrackEntry): void;
event(entry: TrackEntry, event: Event): void;
}
}
declare namespace sp.spine {
class AnimationStateData {
skeletonData: SkeletonData;
animationToMixTime: Map<number>;
defaultMix: number;
constructor(skeletonData: SkeletonData);
setMix(fromName: string, toName: string, duration: number): void;
setMixWith(from: Animation, to: Animation, duration: number): void;
getMix(from: Animation, to: Animation): number;
}
}
declare namespace sp.spine {
class AssetManager implements Disposable {
private pathPrefix;
private textureLoader;
private assets;
private errors;
private toLoad;
private loaded;
constructor(textureLoader: (image: HTMLImageElement) => any, pathPrefix?: string);
private static downloadText;
private static downloadBinary;
loadBinary(path: string, success?: (path: string, binary: Uint8Array) => void, error?: (path: string, error: string) => void): void;
loadText(path: string, success?: (path: string, text: string) => void, error?: (path: string, error: string) => void): void;
loadTexture(path: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
loadTextureData(path: string, data: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
loadTextureAtlas(path: string, success?: (path: string, atlas: TextureAtlas) => void, error?: (path: string, error: string) => void): void;
get(path: string): any;
remove(path: string): void;
removeAll(): void;
isLoadingComplete(): boolean;
getToLoad(): number;
getLoaded(): number;
dispose(): void;
hasErrors(): boolean;
getErrors(): Map<string>;
}
}
declare namespace sp.spine {
class AtlasAttachmentLoader implements AttachmentLoader {
atlas: TextureAtlas;
constructor(atlas: TextureAtlas);
newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment;
newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment;
newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment;
newPathAttachment(skin: Skin, name: string): PathAttachment;
newPointAttachment(skin: Skin, name: string): PointAttachment;
newClippingAttachment(skin: Skin, name: string): ClippingAttachment;
}
}
declare namespace sp.spine {
enum BlendMode {
Normal = 0,
Additive = 1,
Multiply = 2,
Screen = 3
}
}
declare namespace sp.spine {
class Bone implements Updatable {
data: BoneData;
skeleton: Skeleton;
parent: Bone;
children: Bone[];
x: number;
y: number;
rotation: number;
scaleX: number;
scaleY: number;
shearX: number;
shearY: number;
ax: number;
ay: number;
arotation: number;
ascaleX: number;
ascaleY: number;
ashearX: number;
ashearY: number;
appliedValid: boolean;
a: number;
b: number;
c: number;
d: number;
worldY: number;
worldX: number;
sorted: boolean;
active: boolean;
constructor(data: BoneData, skeleton: Skeleton, parent: Bone);
isActive(): boolean;
update(): void;
updateWorldTransform(): void;
updateWorldTransformWith(x: number, y: number, rotation: number, scaleX: number, scaleY: number, shearX: number, shearY: number): void;
setToSetupPose(): void;
getWorldRotationX(): number;
getWorldRotationY(): number;
getWorldScaleX(): number;
getWorldScaleY(): number;
updateAppliedTransform(): void;
worldToLocal(world: Vector2): Vector2;
localToWorld(local: Vector2): Vector2;
worldToLocalRotation(worldRotation: number): number;
localToWorldRotation(localRotation: number): number;
rotateWorld(degrees: number): void;
}
}
declare namespace sp.spine {
class BoneData {
index: number;
name: string;
parent: BoneData;
length: number;
x: number;
y: number;
rotation: number;
scaleX: number;
scaleY: number;
shearX: number;
shearY: number;
transformMode: TransformMode;
skinRequired: boolean;
color: Color;
constructor(index: number, name: string, parent: BoneData);
}
enum TransformMode {
Normal = 0,
OnlyTranslation = 1,
NoRotationOrReflection = 2,
NoScale = 3,
NoScaleOrReflection = 4
}
}
declare namespace sp.spine {
abstract class ConstraintData {
name: string;
order: number;
skinRequired: boolean;
constructor(name: string, order: number, skinRequired: boolean);
}
}
declare namespace sp.spine {
class Event {
data: EventData;
intValue: number;
floatValue: number;
stringValue: string;
time: number;
volume: number;
balance: number;
constructor(time: number, data: EventData);
}
}
declare namespace sp.spine {
class EventData {
name: string;
intValue: number;
floatValue: number;
stringValue: string;
audioPath: string;
volume: number;
balance: number;
constructor(name: string);
}
}
declare namespace sp.spine {
class IkConstraint implements Updatable {
data: IkConstraintData;
bones: Array<Bone>;
target: Bone;
bendDirection: number;
compress: boolean;
stretch: boolean;
mix: number;
softness: number;
active: boolean;
constructor(data: IkConstraintData, skeleton: Skeleton);
isActive(): boolean;
apply(): void;
update(): void;
apply1(bone: Bone, targetX: number, targetY: number, compress: boolean, stretch: boolean, uniform: boolean, alpha: number): void;
apply2(parent: Bone, child: Bone, targetX: number, targetY: number, bendDir: number, stretch: boolean, softness: number, alpha: number): void;
}
}
declare namespace sp.spine {
class IkConstraintData extends ConstraintData {
bones: BoneData[];
target: BoneData;
bendDirection: number;
compress: boolean;
stretch: boolean;
uniform: boolean;
mix: number;
softness: number;
constructor(name: string);
}
}
declare namespace sp.spine {
class PathConstraint implements Updatable {
static NONE: number;
static BEFORE: number;
static AFTER: number;
static epsilon: number;
data: PathConstraintData;
bones: Array<Bone>;
target: Slot;
position: number;
spacing: number;
rotateMix: number;
translateMix: number;
spaces: number[];
positions: number[];
world: number[];
curves: number[];
lengths: number[];
segments: number[];
active: boolean;
constructor(data: PathConstraintData, skeleton: Skeleton);
isActive(): boolean;
apply(): void;
update(): void;
computeWorldPositions(path: PathAttachment, spacesCount: number, tangents: boolean, percentPosition: boolean, percentSpacing: boolean): number[];
addBeforePosition(p: number, temp: Array<number>, i: number, out: Array<number>, o: number): void;
addAfterPosition(p: number, temp: Array<number>, i: number, out: Array<number>, o: number): void;
addCurvePosition(p: number, x1: number, y1: number, cx1: number, cy1: number, cx2: number, cy2: number, x2: number, y2: number, out: Array<number>, o: number, tangents: boolean): void;
}
}
declare namespace sp.spine {
class PathConstraintData extends ConstraintData {
bones: BoneData[];
target: SlotData;
positionMode: PositionMode;
spacingMode: SpacingMode;
rotateMode: RotateMode;
offsetRotation: number;
position: number;
spacing: number;
rotateMix: number;
translateMix: number;
constructor(name: string);
}
enum PositionMode {
Fixed = 0,
Percent = 1
}
enum SpacingMode {
Length = 0,
Fixed = 1,
Percent = 2
}
enum RotateMode {
Tangent = 0,
Chain = 1,
ChainScale = 2
}
}
declare namespace sp.spine {
class SharedAssetManager implements Disposable {
private pathPrefix;
private clientAssets;
private queuedAssets;
private rawAssets;
private errors;
constructor(pathPrefix?: string);
private queueAsset;
loadText(clientId: string, path: string): void;
loadJson(clientId: string, path: string): void;
loadTexture(clientId: string, textureLoader: (image: HTMLImageElement) => any, path: string): void;
get(clientId: string, path: string): any;
private updateClientAssets;
isLoadingComplete(clientId: string): boolean;
dispose(): void;
hasErrors(): boolean;
getErrors(): Map<string>;
}
}
declare namespace sp.spine {
class Skeleton {
data: SkeletonData;
bones: Array<Bone>;
slots: Array<Slot>;
drawOrder: Array<Slot>;
ikConstraints: Array<IkConstraint>;
transformConstraints: Array<TransformConstraint>;
pathConstraints: Array<PathConstraint>;
_updateCache: Updatable[];
updateCacheReset: Updatable[];
skin: Skin;
color: Color;
time: number;
scaleX: number;
scaleY: number;
x: number;
y: number;
constructor(data: SkeletonData);
updateCache(): void;
sortIkConstraint(constraint: IkConstraint): void;
sortPathConstraint(constraint: PathConstraint): void;
sortTransformConstraint(constraint: TransformConstraint): void;
sortPathConstraintAttachment(skin: Skin, slotIndex: number, slotBone: Bone): void;
sortPathConstraintAttachmentWith(attachment: Attachment, slotBone: Bone): void;
sortBone(bone: Bone): void;
sortReset(bones: Array<Bone>): void;
updateWorldTransform(): void;
setToSetupPose(): void;
setBonesToSetupPose(): void;
setSlotsToSetupPose(): void;
getRootBone(): Bone;
findBone(boneName: string): Bone;
findBoneIndex(boneName: string): number;
findSlot(slotName: string): Slot;
findSlotIndex(slotName: string): number;
setSkinByName(skinName: string): void;
setSkin(newSkin: Skin): void;
getAttachmentByName(slotName: string, attachmentName: string): Attachment;
getAttachment(slotIndex: number, attachmentName: string): Attachment;
setAttachment(slotName: string, attachmentName: string): void;
findIkConstraint(constraintName: string): IkConstraint;
findTransformConstraint(constraintName: string): TransformConstraint;
findPathConstraint(constraintName: string): PathConstraint;
getBounds(offset: Vector2, size: Vector2, temp?: Array<number>): void;
update(delta: number): void;
}
}
declare namespace sp.spine {
class SkeletonBinary {
static AttachmentTypeValues: number[];
static TransformModeValues: TransformMode[];
static PositionModeValues: PositionMode[];
static SpacingModeValues: SpacingMode[];
static RotateModeValues: RotateMode[];
static BlendModeValues: BlendMode[];
static BONE_ROTATE: number;
static BONE_TRANSLATE: number;
static BONE_SCALE: number;
static BONE_SHEAR: number;
static SLOT_ATTACHMENT: number;
static SLOT_COLOR: number;
static SLOT_TWO_COLOR: number;
static PATH_POSITION: number;
static PATH_SPACING: number;
static PATH_MIX: number;
static CURVE_LINEAR: number;
static CURVE_STEPPED: number;
static CURVE_BEZIER: number;
scale: number;
attachmentLoader: AttachmentLoader;
private linkedMeshes;
constructor(attachmentLoader: AttachmentLoader);
readSkeletonData(binary: Uint8Array): SkeletonData;
private readSkin;
private readAttachment;
private readVertices;
private readFloatArray;
private readShortArray;
private readAnimation;
private readCurve;
setCurve(timeline: CurveTimeline, frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void;
}
}
declare namespace sp.spine {
class SkeletonBounds {
minX: number;
minY: number;
maxX: number;
maxY: number;
boundingBoxes: BoundingBoxAttachment[];
polygons: ArrayLike<number>[];
private polygonPool;
update(skeleton: Skeleton, updateAabb: boolean): void;
aabbCompute(): void;
aabbContainsPoint(x: number, y: number): boolean;
aabbIntersectsSegment(x1: number, y1: number, x2: number, y2: number): boolean;
aabbIntersectsSkeleton(bounds: SkeletonBounds): boolean;
containsPoint(x: number, y: number): BoundingBoxAttachment;
containsPointPolygon(polygon: ArrayLike<number>, x: number, y: number): boolean;
intersectsSegment(x1: number, y1: number, x2: number, y2: number): BoundingBoxAttachment;
intersectsSegmentPolygon(polygon: ArrayLike<number>, x1: number, y1: number, x2: number, y2: number): boolean;
getPolygon(boundingBox: BoundingBoxAttachment): ArrayLike<number>;
getWidth(): number;
getHeight(): number;
}
}
declare namespace sp.spine {
class SkeletonClipping {
private triangulator;
private clippingPolygon;
private clipOutput;
clippedVertices: number[];
clippedTriangles: number[];
private scratch;
private clipAttachment;
private clippingPolygons;
clipStart(slot: Slot, clip: ClippingAttachment): number;
clipEndWithSlot(slot: Slot): void;
clipEnd(): void;
isClipping(): boolean;
clipTriangles(vertices: ArrayLike<number>, verticesLength: number, triangles: ArrayLike<number>, trianglesLength: number, uvs: ArrayLike<number>, light: Color, dark: Color, twoColor: boolean): void;
clip(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, clippingArea: Array<number>, output: Array<number>): boolean;
static makeClockwise(polygon: ArrayLike<number>): void;
}
}
declare namespace sp.spine {
class SkeletonData {
name: string;
bones: BoneData[];
slots: SlotData[];
skins: Skin[];
defaultSkin: Skin;
events: EventData[];
animations: Animation[];
ikConstraints: IkConstraintData[];
transformConstraints: TransformConstraintData[];
pathConstraints: PathConstraintData[];
x: number;
y: number;
width: number;
height: number;
version: string;
hash: string;
fps: number;
imagesPath: string;
audioPath: string;
findBone(boneName: string): BoneData;
findBoneIndex(boneName: string): number;
findSlot(slotName: string): SlotData;
findSlotIndex(slotName: string): number;
findSkin(skinName: string): Skin;
findEvent(eventDataName: string): EventData;
findAnimation(animationName: string): Animation;
findIkConstraint(constraintName: string): IkConstraintData;
findTransformConstraint(constraintName: string): TransformConstraintData;
findPathConstraint(constraintName: string): PathConstraintData;
findPathConstraintIndex(pathConstraintName: string): number;
}
}
declare namespace sp.spine {
class SkeletonJson {
attachmentLoader: AttachmentLoader;
scale: number;
private linkedMeshes;
constructor(attachmentLoader: AttachmentLoader);
readSkeletonData(json: string | any): SkeletonData;
readAttachment(map: any, skin: Skin, slotIndex: number, name: string, skeletonData: SkeletonData): Attachment;
readVertices(map: any, attachment: VertexAttachment, verticesLength: number): void;
readAnimation(map: any, name: string, skeletonData: SkeletonData): void;
readCurve(map: any, timeline: CurveTimeline, frameIndex: number): void;
getValue(map: any, prop: string, defaultValue: any): any;
static blendModeFromString(str: string): BlendMode;
static positionModeFromString(str: string): PositionMode;
static spacingModeFromString(str: string): SpacingMode;
static rotateModeFromString(str: string): RotateMode;
static transformModeFromString(str: string): TransformMode;
}
}
declare namespace sp.spine {
class SkinEntry {
slotIndex: number;
name: string;
attachment: Attachment;
constructor(slotIndex: number, name: string, attachment: Attachment);
}
class Skin {
name: string;
attachments: Map<Attachment>[];
bones: BoneData[];
constraints: ConstraintData[];
constructor(name: string);
setAttachment(slotIndex: number, name: string, attachment: Attachment): void;
addSkin(skin: Skin): void;
copySkin(skin: Skin): void;
getAttachment(slotIndex: number, name: string): Attachment;
removeAttachment(slotIndex: number, name: string): void;
getAttachments(): Array<SkinEntry>;
getAttachmentsForSlot(slotIndex: number, attachments: Array<SkinEntry>): void;
clear(): void;
attachAll(skeleton: Skeleton, oldSkin: Skin): void;
}
}
declare namespace sp.spine {
class Slot {
data: SlotData;
bone: Bone;
color: Color;
darkColor: Color;
private attachment;
private attachmentTime;
deform: number[];
constructor(data: SlotData, bone: Bone);
getSkeleton(): Skeleton;
getAttachment(): Attachment;
setAttachment(attachment: Attachment): void;
setAttachmentTime(time: number): void;
getAttachmentTime(): number;
setToSetupPose(): void;
}
}
declare namespace sp.spine {
class SlotData {
index: number;
name: string;
boneData: BoneData;
color: Color;
darkColor: Color;
attachmentName: string;
blendMode: BlendMode;
constructor(index: number, name: string, boneData: BoneData);
}
}
declare namespace sp.spine {
abstract class Texture {
protected _image: HTMLImageElement;
constructor(image: HTMLImageElement);
getImage(): HTMLImageElement;
abstract setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
abstract setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
abstract dispose(): void;
static filterFromString(text: string): TextureFilter;
static wrapFromString(text: string): TextureWrap;
}
enum TextureFilter {
Nearest = 9728,
Linear = 9729,
MipMap = 9987,
MipMapNearestNearest = 9984,
MipMapLinearNearest = 9985,
MipMapNearestLinear = 9986,
MipMapLinearLinear = 9987
}
enum TextureWrap {
MirroredRepeat = 33648,
ClampToEdge = 33071,
Repeat = 10497
}
class TextureRegion {
renderObject: any;
u: number;
v: number;
u2: number;
v2: number;
width: number;
height: number;
rotate: boolean;
offsetX: number;
offsetY: number;
originalWidth: number;
originalHeight: number;
}
class FakeTexture extends Texture {
setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
dispose(): void;
}
}
declare namespace sp.spine {
class TextureAtlas implements Disposable {
pages: TextureAtlasPage[];
regions: TextureAtlasRegion[];
constructor(atlasText: string, textureLoader: (path: string) => any);
private load;
findRegion(name: string): TextureAtlasRegion;
dispose(): void;
}
class TextureAtlasPage {
name: string;
minFilter: TextureFilter;
magFilter: TextureFilter;
uWrap: TextureWrap;
vWrap: TextureWrap;
texture: Texture;
width: number;
height: number;
}
class TextureAtlasRegion extends TextureRegion {
page: TextureAtlasPage;
name: string;
x: number;
y: number;
index: number;
rotate: boolean;
degrees: number;
texture: Texture;
}
}
declare namespace sp.spine {
class TransformConstraint implements Updatable {
data: TransformConstraintData;
bones: Array<Bone>;
target: Bone;
rotateMix: number;
translateMix: number;
scaleMix: number;
shearMix: number;
temp: Vector2;
active: boolean;
constructor(data: TransformConstraintData, skeleton: Skeleton);
isActive(): boolean;
apply(): void;
update(): void;
applyAbsoluteWorld(): void;
applyRelativeWorld(): void;
applyAbsoluteLocal(): void;
applyRelativeLocal(): void;
}
}
declare namespace sp.spine {
class TransformConstraintData extends ConstraintData {
bones: BoneData[];
target: BoneData;
rotateMix: number;
translateMix: number;
scaleMix: number;
shearMix: number;
offsetRotation: number;
offsetX: number;
offsetY: number;
offsetScaleX: number;
offsetScaleY: number;
offsetShearY: number;
relative: boolean;
local: boolean;
constructor(name: string);
}
}
declare namespace sp.spine {
class Triangulator {
private convexPolygons;
private convexPolygonsIndices;
private indicesArray;
private isConcaveArray;
private triangles;
private polygonPool;
private polygonIndicesPool;
triangulate(verticesArray: ArrayLike<number>): Array<number>;
decompose(verticesArray: Array<number>, triangles: Array<number>): Array<Array<number>>;
private static isConcave;
private static positiveArea;
private static winding;
}
}
declare namespace sp.spine {
interface Updatable {
update(): void;
isActive(): boolean;
}
}
declare namespace sp.spine {
interface Map<T> {
[key: string]: T;
}
class IntSet {
array: number[];
add(value: number): boolean;
contains(value: number): boolean;
remove(value: number): void;
clear(): void;
}
interface Disposable {
dispose(): void;
}
interface Restorable {
restore(): void;
}
class Color {
r: number;
g: number;
b: number;
a: number;
static WHITE: Color;
static RED: Color;
static GREEN: Color;
static BLUE: Color;
static MAGENTA: Color;
constructor(r?: number, g?: number, b?: number, a?: number);
set(r: number, g: number, b: number, a: number): this;
setFromColor(c: Color): this;
setFromString(hex: string): this;
add(r: number, g: number, b: number, a: number): this;
clamp(): this;
static rgba8888ToColor(color: Color, value: number): void;
static rgb888ToColor(color: Color, value: number): void;
}
class MathUtils {
static PI: number;
static PI2: number;
static radiansToDegrees: number;
static radDeg: number;
static degreesToRadians: number;
static degRad: number;
static clamp(value: number, min: number, max: number): number;
static cosDeg(degrees: number): number;
static sinDeg(degrees: number): number;
static signum(value: number): number;
static toInt(x: number): number;
static cbrt(x: number): number;
static randomTriangular(min: number, max: number): number;
static randomTriangularWith(min: number, max: number, mode: number): number;
}
abstract class Interpolation {
protected abstract applyInternal(a: number): number;
apply(start: number, end: number, a: number): number;
}
class Pow extends Interpolation {
protected power: number;
constructor(power: number);
applyInternal(a: number): number;
}
class PowOut extends Pow {
constructor(power: number);
applyInternal(a: number): number;
}
class Utils {
static SUPPORTS_TYPED_ARRAYS: boolean;
static arrayCopy<T>(source: ArrayLike<T>, sourceStart: number, dest: ArrayLike<T>, destStart: number, numElements: number): void;
static setArraySize<T>(array: Array<T>, size: number, value?: any): Array<T>;
static ensureArrayCapacity<T>(array: Array<T>, size: number, value?: any): Array<T>;
static newArray<T>(size: number, defaultValue: T): Array<T>;
static newFloatArray(size: number): ArrayLike<number>;
static newShortArray(size: number): ArrayLike<number>;
static toFloatArray(array: Array<number>): number[] | Float32Array;
static toSinglePrecision(value: number): number;
static webkit602BugfixHelper(alpha: number, blend: MixBlend): void;
static contains<T>(array: Array<T>, element: T, identity?: boolean): boolean;
}
class DebugUtils {
static logBones(skeleton: Skeleton): void;
}
class Pool<T> {
private items;
private instantiator;
constructor(instantiator: () => T);
obtain(): T;
free(item: T): void;
freeAll(items: ArrayLike<T>): void;
clear(): void;
}
class Vector2 {
x: number;
y: number;
constructor(x?: number, y?: number);
set(x: number, y: number): Vector2;
length(): number;
normalize(): this;
}
class TimeKeeper {
maxDelta: number;
framesPerSecond: number;
delta: number;
totalTime: number;
private lastTime;
private frameCount;
private frameTime;
update(): void;
}
interface ArrayLike<T> {
length: number;
[n: number]: T;
}
class WindowedMean {
values: Array<number>;
addedValues: number;
lastValue: number;
mean: number;
dirty: boolean;
constructor(windowSize?: number);
hasEnoughData(): boolean;
addValue(value: number): void;
getMean(): number;
}
}
declare namespace sp.spine {
interface VertexEffect {
begin(skeleton: Skeleton): void;
transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void;
end(): void;
}
}
interface Math {
fround(n: number): number;
}
declare namespace sp.spine {
abstract class Attachment {
name: string;
constructor(name: string);
abstract copy(): Attachment;
}
abstract class VertexAttachment extends Attachment {
private static nextID;
id: number;
bones: Array<number>;
vertices: ArrayLike<number>;
worldVerticesLength: number;
deformAttachment: VertexAttachment;
constructor(name: string);
computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
copyTo(attachment: VertexAttachment): void;
}
}
declare namespace sp.spine {
interface AttachmentLoader {
newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment;
newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment;
newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment;
newPathAttachment(skin: Skin, name: string): PathAttachment;
newPointAttachment(skin: Skin, name: string): PointAttachment;
newClippingAttachment(skin: Skin, name: string): ClippingAttachment;
}
}
declare namespace sp.spine {
enum AttachmentType {
Region = 0,
BoundingBox = 1,
Mesh = 2,
LinkedMesh = 3,
Path = 4,
Point = 5,
Clipping = 6
}
}
declare namespace sp.spine {
class BoundingBoxAttachment extends VertexAttachment {
color: Color;
constructor(name: string);
copy(): Attachment;
}
}
declare namespace sp.spine {
class ClippingAttachment extends VertexAttachment {
endSlot: SlotData;
color: Color;
constructor(name: string);
copy(): Attachment;
}
}
declare namespace sp.spine {
class MeshAttachment extends VertexAttachment {
region: TextureRegion;
path: string;
regionUVs: ArrayLike<number>;
uvs: ArrayLike<number>;
triangles: Array<number>;
color: Color;
width: number;
height: number;
hullLength: number;
edges: Array<number>;
private parentMesh;
tempColor: Color;
constructor(name: string);
updateUVs(): void;
getParentMesh(): MeshAttachment;
setParentMesh(parentMesh: MeshAttachment): void;
copy(): Attachment;
newLinkedMesh(): MeshAttachment;
}
}
declare namespace sp.spine {
class PathAttachment extends VertexAttachment {
lengths: Array<number>;
closed: boolean;
constantSpeed: boolean;
color: Color;
constructor(name: string);
copy(): Attachment;
}
}
declare namespace sp.spine {
class PointAttachment extends VertexAttachment {
x: number;
y: number;
rotation: number;
color: Color;
constructor(name: string);
computeWorldPosition(bone: Bone, point: Vector2): Vector2;
computeWorldRotation(bone: Bone): number;
copy(): Attachment;
}
}
declare namespace sp.spine {
class RegionAttachment extends Attachment {
static OX1: number;
static OY1: number;
static OX2: number;
static OY2: number;
static OX3: number;
static OY3: number;
static OX4: number;
static OY4: number;
static X1: number;
static Y1: number;
static C1R: number;
static C1G: number;
static C1B: number;
static C1A: number;
static U1: number;
static V1: number;
static X2: number;
static Y2: number;
static C2R: number;
static C2G: number;
static C2B: number;
static C2A: number;
static U2: number;
static V2: number;
static X3: number;
static Y3: number;
static C3R: number;
static C3G: number;
static C3B: number;
static C3A: number;
static U3: number;
static V3: number;
static X4: number;
static Y4: number;
static C4R: number;
static C4G: number;
static C4B: number;
static C4A: number;
static U4: number;
static V4: number;
x: number;
y: number;
scaleX: number;
scaleY: number;
rotation: number;
width: number;
height: number;
color: Color;
path: string;
rendererObject: any;
region: TextureRegion;
offset: ArrayLike<number>;
uvs: ArrayLike<number>;
tempColor: Color;
constructor(name: string);
updateOffset(): void;
setRegion(region: TextureRegion): void;
computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
copy(): Attachment;
}
}
declare namespace sp.spine {
class JitterEffect implements VertexEffect {
jitterX: number;
jitterY: number;
constructor(jitterX: number, jitterY: number);
begin(skeleton: Skeleton): void;
transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void;
end(): void;
}
}
declare namespace sp.spine {
class SwirlEffect implements VertexEffect {
static interpolation: PowOut;
centerX: number;
centerY: number;
radius: number;
angle: number;
private worldX;
private worldY;
constructor(radius: number);
begin(skeleton: Skeleton): void;
transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void;
end(): void;
}
}
/**
* API for jsb module
* Author: haroel
* Homepage: https://github.com/haroel/creatorexDTS
*/
declare namespace jsb{
export module reflection{
/**
* https://docs.cocos.com/creator/manual/zh/advanced-topics/java-reflection.html
* call OBJC/Java static methods
*
* @param className
* @param methodName
* @param methodSignature
* @param parameters
*/
export function callStaticMethod (className: string, methodName: string, methodSignature: string, ...parameters:any): any;
}
/**
*
*/
export type DownloaderTask = { requestURL: string, storagePath: string, identifier: string };
/**
* Http file downloader for jsb
*/
export class Downloader{
/**
* create a download task
* @param requestURL
* @param storagePath
* @param identifier
*/
createDownloadFileTask (requestURL:string, storagePath:string, identifier?:string): DownloaderTask;
setOnFileTaskSuccess (onSucceed: (task: DownloaderTask) => void): void;
setOnTaskProgress (onProgress: (task: DownloaderTask, bytesReceived: number, totalBytesReceived: number, totalBytesExpected: number) => void): void;
setOnTaskError (onError: (task: DownloaderTask, errorCode: number, errorCodeInternal: number, errorStr: string) => void): void;
}
export interface ManifestAsset {
md5: string;
path: string;
compressed: boolean;
size: number;
downloadState: number;
}
export class Manifest {
constructor (manifestUrl: string);
constructor (content: string, manifestRoot: string);
parseFile (manifestUrl: string): void;
parseJSONString (content: string, manifestRoot: string): void;
getManifestRoot (): string;
getManifestFileUrl (): string;
getVersionFileUrl (): string;
getSearchPaths (): [string];
getVersion (): string;
getPackageUrl (): boolean;
setUpdating (isUpdating: boolean): void;
isUpdating (): boolean;
isVersionLoaded (): boolean;
isLoaded (): boolean;
}
export class EventAssetsManager {
// EventCode
static ERROR_NO_LOCAL_MANIFEST: number;
static ERROR_DOWNLOAD_MANIFEST: number;
static ERROR_PARSE_MANIFEST: number;
static NEW_VERSION_FOUND: number;
static ALREADY_UP_TO_DATE: number;
static UPDATE_PROGRESSION: number;
static ASSET_UPDATED: number;
static ERROR_UPDATING: number;
static UPDATE_FINISHED: number;
static UPDATE_FAILED: number;
static ERROR_DECOMPRESS: number;
constructor (eventName: string, manager: AssetsManager, eventCode: number,
assetId?: string, message?: string, curleCode?: number, curlmCode?: number);
getAssetsManagerEx (): AssetsManager;
isResuming (): boolean;
getDownloadedFiles (): number;
getDownloadedBytes (): number;
getTotalFiles (): number;
getTotalBytes (): number;
getPercent (): number;
getPercentByFile (): number;
getEventCode (): number;
getMessage (): string;
getAssetId (): string;
getCURLECode (): number;
getCURLMCode (): number;
}
export module AssetsManager {
export enum State {
UNINITED,
UNCHECKED,
PREDOWNLOAD_VERSION,
DOWNLOADING_VERSION,
VERSION_LOADED,
PREDOWNLOAD_MANIFEST,
DOWNLOADING_MANIFEST,
MANIFEST_LOADED,
NEED_UPDATE,
READY_TO_UPDATE,
UPDATING,
UNZIPPING,
UP_TO_DATE,
FAIL_TO_UPDATE,
}
}
export class AssetsManager {
constructor (manifestUrl: string, storagePath: string, versionCompareHandle?: (versionA: string, versionB: string) => number);
static create (manifestUrl: string, storagePath: string): AssetsManager;
getState (): AssetsManager.State;
getStoragePath (): string
getMaxConcurrentTask (): number;
// setMaxConcurrentTask (max: number): void; // actually not supported
checkUpdate (): void;
prepareUpdate (): void;
update (): void;
isResuming (): boolean;
getDownloadedFiles (): number;
getDownloadedBytes (): number;
getTotalFiles (): number;
getTotalBytes (): number;
downloadFailedAssets (): void;
getLocalManifest (): Manifest;
loadLocalManifest (manifestUrl: string): boolean;
loadLocalManifest (localManifest: Manifest, storagePath: string): boolean;
getRemoteManifest (): Manifest;
loadRemoteManifest (remoteManifest: Manifest): boolean;
/**
* Setup your own version compare handler, versionA and B is versions in string.
* if the return value greater than 0, versionA is greater than B,
* if the return value equals 0, versionA equals to B,
* if the return value smaller than 0, versionA is smaller than B.
*/
setVersionCompareHandle (versionCompareHandle?: (versionA: string, versionB: string) => number): void;
/**
* Setup the verification callback, Return true if the verification passed, otherwise return false
*/
setVerifyCallback (verifyCallback: (path: string, asset: ManifestAsset) => boolean): void;
setEventCallback (eventCallback: (event: EventAssetsManager) => void): void;
}
/**
* FileUtils Helper class to handle file operations.
*/
export module fileUtils{
/**
* Checks whether the path is an absolute path.
*
* @note On Android, if the parameter passed in is relative to "@assets/", this method will treat it as an absolute path.
* Also on Blackberry, path starts with "app/native/Resources/" is treated as an absolute path.
*
* @param path The path that needs to be checked.
* @return True if it's an absolute path, false if not.
*/
export function isAbsolutePath (path:string):boolean;
/** Returns the fullpath for a given filename.
First it will try to get a new filename from the "filenameLookup" dictionary.
If a new filename can't be found on the dictionary, it will use the original filename.
Then it will try to obtain the full path of the filename using the FileUtils search rules: resolutions, and search paths.
The file search is based on the array element order of search paths and resolution directories.
For instance:
We set two elements("/mnt/sdcard/", "internal_dir/") to search paths vector by setSearchPaths,
and set three elements("resources-ipadhd/", "resources-ipad/", "resources-iphonehd")
to resolutions vector by setSearchResolutionsOrder. The "internal_dir" is relative to "Resources/".
If we have a file named 'sprite.png', the mapping in fileLookup dictionary contains `key: sprite.png -> value: sprite.pvr.gz`.
Firstly, it will replace 'sprite.png' with 'sprite.pvr.gz', then searching the file sprite.pvr.gz as follows:
/mnt/sdcard/resources-ipadhd/sprite.pvr.gz (if not found, search next)
/mnt/sdcard/resources-ipad/sprite.pvr.gz (if not found, search next)
/mnt/sdcard/resources-iphonehd/sprite.pvr.gz (if not found, search next)
/mnt/sdcard/sprite.pvr.gz (if not found, search next)
internal_dir/resources-ipadhd/sprite.pvr.gz (if not found, search next)
internal_dir/resources-ipad/sprite.pvr.gz (if not found, search next)
internal_dir/resources-iphonehd/sprite.pvr.gz (if not found, search next)
internal_dir/sprite.pvr.gz (if not found, return "sprite.png")
If the filename contains relative path like "gamescene/uilayer/sprite.png",
and the mapping in fileLookup dictionary contains `key: gamescene/uilayer/sprite.png -> value: gamescene/uilayer/sprite.pvr.gz`.
The file search order will be:
/mnt/sdcard/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz (if not found, search next)
/mnt/sdcard/gamescene/uilayer/resources-ipad/sprite.pvr.gz (if not found, search next)
/mnt/sdcard/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz (if not found, search next)
/mnt/sdcard/gamescene/uilayer/sprite.pvr.gz (if not found, search next)
internal_dir/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz (if not found, search next)
internal_dir/gamescene/uilayer/resources-ipad/sprite.pvr.gz (if not found, search next)
internal_dir/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz (if not found, search next)
internal_dir/gamescene/uilayer/sprite.pvr.gz (if not found, return "gamescene/uilayer/sprite.png")
If the new file can't be found on the file system, it will return the parameter filename directly.
This method was added to simplify multiplatform support. Whether you are using cocos2d-js or any cross-compilation toolchain like StellaSDK or Apportable,
you might need to load different resources for a given file in the different platforms.
@since v2.1
*/
export function fullPathForFilename (filename:string):string;
/**
* Gets string from a file.
*/
export function getStringFromFile (filename:string):string;
/**
* Removes a file.
*
* @param filepath The full path of the file, it must be an absolute path.
* @return True if the file have been removed successfully, false if not.
*/
export function removeFile (filepath:string):boolean;
/**
* Checks whether the path is a directory.
*
* @param dirPath The path of the directory, it could be a relative or an absolute path.
* @return True if the directory exists, false if not.
*/
export function isDirectoryExist (dirPath:string):boolean;
/**
* Normalize: remove . and ..
* @param filepath
*/
export function normalizePath (filepath:string):string;
/**
* Get default resource root path.
*/
export function getDefaultResourceRootPath ():string;
/**
* Loads the filenameLookup dictionary from the contents of a filename.
*
* @note The plist file name should follow the format below:
*
* @code
* <?xml version="1.0" encoding="UTF-8"?>
* <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
* <plist version="1.0">
* <dict>
* <key>filenames</key>
* <dict>
* <key>sounds/click.wav</key>
* <string>sounds/click.caf</string>
* <key>sounds/endgame.wav</key>
* <string>sounds/endgame.caf</string>
* <key>sounds/gem-0.wav</key>
* <string>sounds/gem-0.caf</string>
* </dict>
* <key>metadata</key>
* <dict>
* <key>version</key>
* <integer>1</integer>
* </dict>
* </dict>
* </plist>
* @endcode
* @param filename The plist file name.
*
@since v2.1
* @js loadFilenameLookup
* @lua loadFilenameLookup
*/
export function loadFilenameLookup (filepath:string):void;
/** Checks whether to pop up a message box when failed to load an image.
* @return True if pop up a message box when failed to load an image, false if not.
*/
export function isPopupNotify ():boolean;
/**
* Sets whether to pop-up a message box when failed to load an image.
*/
export function setPopupNotify (notify:boolean):void;
// Converts the contents of a file to a ValueVector.
// This method is used internally.
export function getValueVectorFromFile (filepath:string):Array<any>;
/**
* Gets the array of search paths.
*
* @return The array of search paths which may contain the prefix of default resource root path.
* @note In best practise, getter function should return the value of setter function passes in.
* But since we should not break the compatibility, we keep using the old logic.
* Therefore, If you want to get the original search paths, please call 'getOriginalSearchPaths()' instead.
* @see fullPathForFilename(const char*).
* @lua NA
*/
export function getSearchPaths ():Array<string>;
/**
*
* @param filepath
*/
export function getFileDir (filepath:string):string;
/**
* write a ValueMap into a plist file
*
*@param dict the ValueMap want to save (key,value)
*@param fullPath The full path to the file you want to save a string
*@return bool
*/
export function writeToFile ( valueMap:any ):boolean;
/**
* Gets the original search path array set by 'setSearchPaths' or 'addSearchPath'.
* @return The array of the original search paths
*/
export function getOriginalSearchPaths ():Array<string>;
/**
* List all files in a directory.
*
* @param dirPath The path of the directory, it could be a relative or an absolute path.
* @return File paths in a string vector
*/
export function listFiles (filepath:string):Array<string>;
/**
* Converts the contents of a file to a ValueMap.
* @param filename The filename of the file to gets content.
* @return ValueMap of the file contents.
* @note This method is used internally.
*/
export function getValueMapFromFile (filepath:string):any;
/**
* Retrieve the file size.
*
* @note If a relative path was passed in, it will be inserted a default root path at the beginning.
* @param filepath The path of the file, it could be a relative or absolute path.
* @return The file size.
*/
export function getFileSize (filepath:string):number;
/** Converts the contents of a file to a ValueMap.
* This method is used internally.
*/
export function getValueMapFromData (filedata:string,filesize:number):any;
/**
* Removes a directory.
*
* @param dirPath The full path of the directory, it must be an absolute path.
* @return True if the directory have been removed successfully, false if not.
*/
export function removeDirectory (dirPath:string):boolean;
/**
* Sets the array of search paths.
*
* You can use this array to modify the search path of the resources.
* If you want to use "themes" or search resources in the "cache", you can do it easily by adding new entries in this array.
*
* @note This method could access relative path and absolute path.
* If the relative path was passed to the vector, FileUtils will add the default resource directory before the relative path.
* For instance:
* On Android, the default resource root path is "@assets/".
* If "/mnt/sdcard/" and "resources-large" were set to the search paths vector,
* "resources-large" will be converted to "@assets/resources-large" since it was a relative path.
*
* @param searchPaths The array contains search paths.
* @see fullPathForFilename(const char*)
* @since v2.1
* In js:var setSearchPaths(var jsval);
* @lua NA
*/
export function setSearchPaths ( searchPath:Array<string>):void;
/**
* write a string into a file
*
* @param dataStr the string want to save
* @param fullPath The full path to the file you want to save a string
* @return bool True if write success
*/
export function writeStringToFile (dataStr:string,fullPath:string):boolean;
/**
* Sets the array that contains the search order of the resources.
*
* @param searchResolutionsOrder The source array that contains the search order of the resources.
* @see getSearchResolutionsOrder(), fullPathForFilename(const char*).
* @since v2.1
* In js:var setSearchResolutionsOrder(var jsval)
* @lua NA
*/
export function setSearchResolutionsOrder (searchResolutionsOrder:Array<string>):void;
/**
* Append search order of the resources.
*
* @see setSearchResolutionsOrder(), fullPathForFilename().
* @since v2.1
*/
export function addSearchResolutionsOrder (order:string,front:boolean):void;
/**
* Add search path.
*
* @since v2.1
*/
export function addSearchPath (path:string,front:boolean):void;
/**
* write ValueVector into a plist file
*
*@param vecData the ValueVector want to save
*@param fullPath The full path to the file you want to save a string
*@return bool
*/
export function writeValueVectorToFile (vecData:Array<any>,fullPath:string):boolean;
/**
* Checks whether a file exists.
*
* @note If a relative path was passed in, it will be inserted a default root path at the beginning.
* @param filename The path of the file, it could be a relative or absolute path.
* @return True if the file exists, false if not.
*/
export function isFileExist (filename:string):boolean;
/**©
* Purges full path caches.
*/
export function purgeCachedEntries ():void;
/**
* Gets full path from a file name and the path of the relative file.
* @param filename The file name.
* @param relativeFile The path of the relative file.
* @return The full path.
* e.g. filename: hello.png, pszRelativeFile: /User/path1/path2/hello.plist
* Return: /User/path1/path2/hello.pvr (If there a a key(hello.png)-value(hello.pvr) in FilenameLookup dictionary. )
*
*/
export function fullPathFromRelativeFile (filename:string,relativeFile:string):string;
/**
* Windows fopen can't support UTF-8 filename
* Need convert all parameters fopen and other 3rd-party libs
*
* @param filenameUtf8 std::string name file for conversion from utf-8
* @return std::string ansi filename in current locale
*/
export function getSuitableFOpen (filenameUtf8:string):string;
/**
* write ValueMap into a plist file
*
*@param dict the ValueMap want to save
*@param fullPath The full path to the file you want to save a string
*@return bool
*/
export function writeValueMapToFile (dict:any,fullPath:string):string;
/**
* Gets filename extension is a suffix (separated from the base filename by a dot) in lower case.
* Examples of filename extensions are .png, .jpeg, .exe, .dmg and .txt.
* @param filePath The path of the file, it could be a relative or absolute path.
* @return suffix for filename in lower case or empty if a dot not found.
*/
export function getFileExtension (filePath:string):string;
/**
* Sets writable path.
*/
export function setWritablePath (writablePath:string):void;
/**
* Set default resource root path.
*/
export function setDefaultResourceRootPath (filepath:string):void;
/**
* Gets the array that contains the search order of the resources.
*
* @see setSearchResolutionsOrder(const std::vector<std::string>&), fullPathForFilename(const char*).
* @since v2.1
* @lua NA
*/
export function getSearchResolutionsOrder ():Array<string>;
/**
* Creates a directory.
*
* @param dirPath The path of the directory, it must be an absolute path.
* @return True if the directory have been created successfully, false if not.
*/
export function createDirectory (dirPath:string):string;
/**
* List all files recursively in a directory.
*
* @param dirPath The path of the directory, it could be a relative or an absolute path.
* @return File paths in a string vector
*/
export function listFilesRecursively (dirPath:string, files:Array<string>):void;
/**
* Gets the writable path.
* @return The path that can be write/read a file in
*/
export function getWritablePath ():string;
}
}
/** Running in the editor. */
declare const CC_EDITOR: boolean;
/** Preview in browser or simulator. */
declare const CC_PREVIEW: boolean;
/** Running in the editor or preview. */
declare const CC_DEV: boolean;
/** Running in the editor or preview, or build in debug mode. */
declare const CC_DEBUG: boolean;
/** Running in published project. */
declare const CC_BUILD: boolean;
/** Running in native platforms (mobile app, desktop app, or simulator). */
declare const CC_JSB: boolean;
/** Running in runtime environments. */
declare const CC_RUNTIME: boolean;
/** Running in the engine's unit test. */
declare const CC_TEST: boolean;
/** Running in the WeChat Mini Game. */
declare const CC_WECHATGAME: boolean;