diff --git a/cocos2d/core/CCActionManager.js b/cocos2d/actions/CCActionManager.js
similarity index 100%
rename from cocos2d/core/CCActionManager.js
rename to cocos2d/actions/CCActionManager.js
diff --git a/cocos2d/actions/index.js b/cocos2d/actions/index.js
index 31b45fdcf8..0b91c2c40a 100644
--- a/cocos2d/actions/index.js
+++ b/cocos2d/actions/index.js
@@ -1,3 +1,4 @@
+require('./CCActionManager.js');
require('./CCAction.js');
require('./CCActionInterval.js');
require('./CCActionInstant.js');
diff --git a/cocos2d/actions3d/CCActionGrid.js b/cocos2d/actions3d/CCActionGrid.js
deleted file mode 100644
index 438633e0dd..0000000000
--- a/cocos2d/actions3d/CCActionGrid.js
+++ /dev/null
@@ -1,427 +0,0 @@
-/****************************************************************************
- Copyright (c) 2008-2010 Ricardo Quesada
- Copyright (c) 2011-2012 cocos2d-x.org
- Copyright (c) 2013-2014 Chukong Technologies Inc.
-
- http://www.cocos2d-x.org
-
- 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.
- ****************************************************************************/
-
-/**
- * Base class for Grid actions
- * @class
- * @extends cc.ActionInterval
- * @param {Number} duration
- * @param {Size} gridSize
- */
-cc.GridAction = cc.ActionInterval.extend(/** @lends cc.GridAction# */{
- _gridSize:null,
- _gridNodeTarget:null,
-
- /**
- * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
- * @param {Number} duration
- * @param {Size} gridSize
- */
- ctor:function(duration, gridSize){
- cc.sys._checkWebGLRenderMode();
- cc.ActionInterval.prototype.ctor.call(this);
- this._gridSize = cc.size(0,0);
-
- gridSize && this.initWithDuration(duration, gridSize);
- },
-
- _cacheTargetAsGridNode:function (target) {
- this._gridNodeTarget = target;
- },
-
- /**
- * to copy object with deep copy.
- * returns a clone of action.
- *
- * @return {cc.Action}
- */
- clone:function(){
- var action = new cc.GridAction();
- var locGridSize = this._gridSize;
- action.initWithDuration(this._duration, cc.size(locGridSize.width, locGridSize.height));
- return action;
- },
-
- /**
- * called before the action start. It will also set the target.
- *
- * @param {_ccsg.Node} target
- */
- startWithTarget:function (target) {
- cc.ActionInterval.prototype.startWithTarget.call(this, target);
- cc.renderer.childrenOrderDirty = true;
- this._cacheTargetAsGridNode(target);
-
- var newGrid = this.getGrid();
-
- var targetGrid = this._gridNodeTarget.getGrid();
- if (targetGrid && targetGrid.getReuseGrid() > 0) {
- var locGridSize = targetGrid.getGridSize();
- if (targetGrid.isActive() && (locGridSize.width === this._gridSize.width) && (locGridSize.height === this._gridSize.height))
- targetGrid.reuse();
- } else {
- if (targetGrid && targetGrid.isActive())
- targetGrid.setActive(false);
- this._gridNodeTarget.setGrid(newGrid);
- this._gridNodeTarget.getGrid().setActive(true);
- }
- },
-
- /**
- * Create a cc.ReverseTime action. Opposite with the original motion trajectory.
- * @return {cc.ReverseTime}
- */
- reverse:function () {
- return new cc.ReverseTime(this);
- },
-
- /**
- * Initializes the action with size and duration.
- * @param {Number} duration
- * @param {Size} gridSize
- * @return {Boolean}
- */
- initWithDuration:function (duration, gridSize) {
- if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
- this._gridSize.width = gridSize.width;
- this._gridSize.height = gridSize.height;
- return true;
- }
- return false;
- },
-
- /**
- * Returns the grid.
- * @return {cc.GridBase}
- */
- getGrid:function () {
- // Abstract class needs implementation
- cc.logID(1017);
- }
-});
-
-/**
- * creates the action with size and duration
- * @function
- * @param {Number} duration
- * @param {Size} gridSize
- * @return {cc.GridAction}
- */
-cc.gridAction = function (duration, gridSize) {
- return new cc.GridAction(duration, gridSize);
-};
-
-/**
- * Please use cc.gridAction instead.
- * Creates the action with size and duration.
- * @param {Number} duration
- * @param {Size} gridSize
- * @return {cc.GridAction}
- * @static
- * @deprecated since v3.0
Please use cc.gridAction instead.
- */
-cc.GridAction.create = cc.gridAction;
-
-/**
- * Base class for cc.Grid3D actions.
- * Grid3D actions can modify a non-tiled grid.
- * @class
- * @extends cc.GridAction
- */
-cc.Grid3DAction = cc.GridAction.extend(/** @lends cc.Grid3DAction# */{
-
- /**
- * returns the grid
- * @return {cc.Grid3D}
- */
- getGrid:function () {
- return new cc.Grid3D(this._gridSize, undefined, undefined, this._gridNodeTarget.getGridRect());
- },
-
- /**
- * get rect of the grid
- * @return {Rect} rect
- */
- getGridRect:function () {
- return this._gridNodeTarget.getGridRect();
- },
-
- /**
- * returns the vertex than belongs to certain position in the grid.
- * It will be deprecated in future, please use getVertex instead.
- * @param {cc.Vec2} position
- * @return {cc.Vertex3F}
- */
- vertex:function (position) {
- return this.getVertex(position);
- },
-
- /**
- * returns the vertex than belongs to certain position in the grid
- * @param {cc.Vec2} position
- * @return {cc.Vertex3F}
- */
- getVertex: function(position){
- return this.target.grid.getVertex(position);
- },
-
- /**
- * returns the non-transformed vertex than belongs to certain position in the grid
- * It will be deprecated in future, please use getVertex instead.
- * @param {cc.Vec2} position
- * @return {cc.Vertex3F}
- */
- originalVertex:function (position) {
- return this.getOriginalVertex(position);
- },
-
- /**
- * returns the non-transformed vertex that belongs to certain position in the grid
- * @param {cc.Vec2} position
- * @return {cc.Vertex3F}
- */
- getOriginalVertex:function (position) {
- return this.target.grid.originalVertex(position);
- },
-
- /**
- * sets a new vertex to a certain position of the grid
- * @param {cc.Vec2} position
- * @param {cc.Vertex3F} vertex
- */
- setVertex:function (position, vertex) {
- this.target.grid.setVertex(position, vertex);
- }
-});
-
-/**
- * creates the action with size and duration
- * @function
- * @param {Number} duration
- * @param {Size} gridSize
- * @return {cc.Grid3DAction}
- */
-cc.grid3DAction = function (duration, gridSize) {
- return new cc.Grid3DAction(duration, gridSize);
-};
-/**
- * Please use cc.grid3DAction instead.
- * creates the action with size and duration.
- * @param {Number} duration
- * @param {Size} gridSize
- * @return {cc.Grid3DAction}
- * @static
- * @deprecated since v3.0
Please use cc.grid3DAction instead.
- */
-cc.Grid3DAction.create = cc.grid3DAction;
-
-/**
- * Base class for cc.TiledGrid3D actions.
- * @class
- * @extends cc.GridAction
- */
-cc.TiledGrid3DAction = cc.GridAction.extend(/** @lends cc.TiledGrid3DAction# */{
-
- /**
- * returns the tile that belongs to a certain position of the grid
- * It will be deprecated in future, please use getTile instead.
- * @param {cc.Vec2} position
- * @return {cc.Quad3}
- */
- tile:function (position) {
- return this.getTile(position);
- },
-
- /**
- * returns the tile that belongs to a certain position of the grid
- * @param {cc.Vec2} position
- * @return {cc.Quad3}
- */
- getTile:function (position) {
- return this.target.grid.tile(position);
- },
-
- /**
- * returns the non-transformed tile that belongs to a certain position of the grid
- * It will be deprecated in future, please use getOriginalTile instead.
- * @param {cc.Vec2} position
- * @return {cc.Quad3}
- */
- originalTile:function (position) {
- return this.getOriginalTile(position);
- },
-
- /**
- * returns the non-transformed tile that belongs to a certain position of the grid
- * @param {cc.Vec2} position
- * @return {cc.Quad3}
- */
- getOriginalTile:function (position) {
- return this.target.grid.originalTile(position);
- },
-
- /**
- * sets a new tile to a certain position of the grid
- * @param {cc.Vec2} position
- * @param {cc.Quad3} coords
- */
- setTile:function (position, coords) {
- this.target.grid.setTile(position, coords);
- },
-
- /**
- * returns the grid
- * @return {cc.TiledGrid3D}
- */
- getGrid:function () {
- return new cc.TiledGrid3D(this._gridSize, undefined, undefined, this._gridNodeTarget.getGridRect());
- }
-});
-
-/**
- * Creates the action with duration and grid size
- * @function
- * @param {Number} duration
- * @param {Size} gridSize
- * @return {cc.TiledGrid3DAction}
- */
-cc.tiledGrid3DAction = function (duration, gridSize) {
- return new cc.TiledGrid3DAction(duration, gridSize);
-};
-
-/**
- * Please use cc.tiledGrid3DAction instead
- * Creates the action with duration and grid size
- * @param {Number} duration
- * @param {Size} gridSize
- * @return {cc.TiledGrid3DAction}
- * @static
- * @deprecated since v3.0
Please use cc.tiledGrid3DAction instead.
- */
-cc.TiledGrid3DAction.create = cc.tiledGrid3DAction;
-
-/**
- *
- * cc.StopGrid action.
- * @warning Don't call this action if another grid action is active.
- * Call if you want to remove the the grid effect. Example:
- * cc.sequence(Lens.action(...), cc.stopGrid(...), null);
- *
- * @class
- * @extends cc.ActionInstant
- */
-cc.StopGrid = cc.ActionInstant.extend(/** @lends cc.StopGrid# */{
-
- /**
- * called before the action start. It will also set the target.
- *
- * @param {_ccsg.Node} target
- */
- startWithTarget:function (target) {
- cc.ActionInstant.prototype.startWithTarget.call(this, target);
- cc.renderer.childrenOrderDirty = true;
- var grid = this.target.grid;
- if (grid && grid.isActive())
- grid.setActive(false);
- }
-});
-
-/**
- * Allocates and initializes the action
- * @function
- * @return {cc.StopGrid}
- */
-cc.stopGrid = function () {
- return new cc.StopGrid();
-};
-/**
- * Please use cc.stopGrid instead
- * Allocates and initializes the action
- * @return {cc.StopGrid}
- * @static
- * @deprecated since v3.0
Please use cc.stopGrid instead.
- */
-cc.StopGrid.create = cc.stopGrid;
-
-/**
- * cc.ReuseGrid action
- * @class
- * @extends cc.ActionInstant
- * @param {Number} times
- */
-cc.ReuseGrid = cc.ActionInstant.extend(/** @lends cc.ReuseGrid# */{
- _times:null,
-
- /**
- * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
- * @param {Number} times
- */
- ctor: function(times) {
- cc.ActionInstant.prototype.ctor.call(this);
- times !== undefined && this.initWithTimes(times);
- },
-
- /**
- * initializes an action with the number of times that the current grid will be reused
- * @param {Number} times
- * @return {Boolean}
- */
- initWithTimes:function (times) {
- this._times = times;
- return true;
- },
-
- /**
- * called before the action start. It will also set the target.
- *
- * @param {_ccsg.Node} target
- */
- startWithTarget:function (target) {
- cc.ActionInstant.prototype.startWithTarget.call(this, target);
- cc.renderer.childrenOrderDirty = true;
- if (this.target.grid && this.target.grid.isActive())
- this.target.grid.setReuseGrid(this.target.grid.getReuseGrid() + this._times);
- }
-});
-
-/**
- * creates an action with the number of times that the current grid will be reused
- * @function
- * @param {Number} times
- * @return {cc.ReuseGrid}
- */
-cc.reuseGrid = function (times) {
- return new cc.ReuseGrid(times);
-};
-/**
- * Please use cc.reuseGrid instead
- * creates an action with the number of times that the current grid will be reused
- * @param {Number} times
- * @return {cc.ReuseGrid}
- * @static
- * @deprecated since v3.0
Please use cc.reuseGrid instead.
- */
-cc.ReuseGrid.create = cc.reuseGrid;
diff --git a/cocos2d/actions3d/CCActionGrid3D.js b/cocos2d/actions3d/CCActionGrid3D.js
deleted file mode 100644
index 6268be0457..0000000000
--- a/cocos2d/actions3d/CCActionGrid3D.js
+++ /dev/null
@@ -1,1257 +0,0 @@
-/****************************************************************************
- Copyright (c) 2008-2010 Ricardo Quesada
- Copyright (c) 2011-2012 cocos2d-x.org
- Copyright (c) 2013-2014 Chukong Technologies Inc.
-
- http://www.cocos2d-x.org
-
- 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.
- ****************************************************************************/
-
-/**
- * cc.Waves3D action.
- * Reference the test cases (Effects Advanced Test)
- * @class
- * @extends cc.Grid3DAction
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} waves
- * @param {Number} amplitude
- */
-cc.Waves3D = cc.Grid3DAction.extend(/** @lends cc.Waves3D# */{
- _waves: 0,
- _amplitude: 0,
- _amplitudeRate: 0,
-
- /**
- * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
- * Create a wave 3d action with duration, grid size, waves and amplitude.
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} waves
- * @param {Number} amplitude
- */
- ctor:function (duration, gridSize, waves, amplitude) {
- cc.GridAction.prototype.ctor.call(this);
- amplitude !== undefined && this.initWithDuration(duration, gridSize, waves, amplitude);
- },
-
- /**
- * get Amplitude
- * @return {Number}
- */
- getAmplitude:function () {
- return this._amplitude;
- },
-
- /**
- * set Amplitude
- * @param {Number} amplitude
- */
- setAmplitude:function (amplitude) {
- this._amplitude = amplitude;
- },
-
- /**
- * get Amplitude Rate
- * @return {Number}
- */
- getAmplitudeRate:function () {
- return this._amplitudeRate;
- },
-
- /**
- * set Amplitude Rate
- * @param {Number} amplitudeRate
- */
- setAmplitudeRate:function (amplitudeRate) {
- this._amplitudeRate = amplitudeRate;
- },
-
- /**
- * initializes an action with duration, grid size, waves and amplitude
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} waves
- * @param {Number} amplitude
- * @return {Boolean}
- */
- initWithDuration:function (duration, gridSize, waves, amplitude) {
- if (cc.Grid3DAction.prototype.initWithDuration.call(this, duration, gridSize)) {
- this._waves = waves;
- this._amplitude = amplitude;
- this._amplitudeRate = 1.0;
- return true;
- }
- return false;
- },
-
- /**
- * Called once per frame. Time is the number of seconds of a frame interval.
- *
- * @param {Number} dt
- */
- update:function (dt) {
- var locGridSize = this._gridSize;
- var locAmplitude = this._amplitude, locPos = cc.p(0, 0);
- var locAmplitudeRate = this._amplitudeRate, locWaves = this._waves;
- for (var i = 0; i < locGridSize.width + 1; ++i) {
- for (var j = 0; j < locGridSize.height + 1; ++j) {
- locPos.x = i;
- locPos.y = j;
- var v = this.originalVertex(locPos);
- v.z += (Math.sin(Math.PI * dt * locWaves * 2 + (v.y + v.x) * 0.01) * locAmplitude * locAmplitudeRate);
- //cc.log("v.z offset is" + (Math.sin(Math.PI * dt * this._waves * 2 + (v.y + v.x) * 0.01) * this._amplitude * this._amplitudeRate));
- this.setVertex(locPos, v);
- }
- }
- }
-});
-
-/**
- * Create a wave 3d action with duration, grid size, waves and amplitude.
- * @function
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} waves
- * @param {Number} amplitude
- */
-cc.waves3D = function (duration, gridSize, waves, amplitude) {
- return new cc.Waves3D(duration, gridSize, waves, amplitude);
-};
-/**
- * Please use cc.waves3D instead.
- * Create a wave 3d action with duration, grid size, waves and amplitude.
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} waves
- * @param {Number} amplitude
- * @static
- * @deprecated since v3.0
Please use cc.waves3D instead.
- */
-cc.Waves3D.create = cc.waves3D;
-
-/**
- * cc.FlipX3D action.
- * Flip around.
- * Reference the test cases (Effects Test)
- * @class
- * @extends cc.Grid3DAction
- * @param {Number} duration
- */
-cc.FlipX3D = cc.Grid3DAction.extend(/** @lends cc.FlipX3D# */{
-
- /**
- * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
- * Create a Flip X 3D action with duration.
- * @param {Number} duration
- */
- ctor: function(duration) {
- if (duration !== undefined)
- cc.GridAction.prototype.ctor.call(this, duration, cc.size(1, 1));
- else cc.GridAction.prototype.ctor.call(this);
- },
-
- /**
- * initializes the action with duration
- * @param {Number} duration
- * @return {Boolean}
- */
- initWithDuration:function (duration) {
- return cc.Grid3DAction.prototype.initWithDuration.call(this, duration, cc.size(1, 1));
- },
-
- /**
- * initializes the action with gridSize and duration
- * @param {Size} gridSize
- * @param {Number} duration
- * @return {Boolean}
- */
- initWithSize:function (gridSize, duration) {
- if (gridSize.width !== 1 || gridSize.height !== 1) {
- // Grid size must be (1,1)
- cc.logID(1018);
- return false;
- }
- return cc.Grid3DAction.prototype.initWithDuration.call(this, duration, gridSize);
- },
-
- /**
- * Called once per frame. Time is the number of seconds of a frame interval.
- *
- * @param {Number} dt
- */
- update:function (dt) {
- var angle = Math.PI * dt; // 180 degrees
- var mz = Math.sin(angle);
- angle = angle / 2.0; // x calculates degrees from 0 to 90
- var mx = Math.cos(angle);
-
- var diff = new cc.Vertex3F();
- var tempVer = cc.p(0, 0);
- tempVer.x = tempVer.y = 1;
- var v0 = this.originalVertex(tempVer);
- tempVer.x = tempVer.y = 0;
- var v1 = this.originalVertex(tempVer);
-
- var x0 = v0.x;
- var x1 = v1.x;
- var x;
- var a, b, c, d;
-
- if (x0 > x1) {
- // Normal Grid
- a = cc.p(0, 0);
- b = cc.p(0, 1);
- c = cc.p(1, 0);
- d = cc.p(1, 1);
- x = x0;
- } else {
- // Reversed Grid
- c = cc.p(0, 0);
- d = cc.p(0, 1);
- a = cc.p(1, 0);
- b = cc.p(1, 1);
- x = x1;
- }
-
- diff.x = ( x - x * mx );
- diff.z = Math.abs(parseFloat((x * mz) / 4.0));
-
- // bottom-left
- var v = this.originalVertex(a);
- v.x = diff.x;
- v.z += diff.z;
- this.setVertex(a, v);
-
- // upper-left
- v = this.originalVertex(b);
- v.x = diff.x;
- v.z += diff.z;
- this.setVertex(b, v);
-
- // bottom-right
- v = this.originalVertex(c);
- v.x -= diff.x;
- v.z -= diff.z;
- this.setVertex(c, v);
-
- // upper-right
- v = this.originalVertex(d);
- v.x -= diff.x;
- v.z -= diff.z;
- this.setVertex(d, v);
- }
-});
-
-/**
- * Create a Flip X 3D action with duration.
- * Flip around.
- * @function
- * @param {Number} duration
- * @return {cc.FlipX3D}
- */
-cc.flipX3D = function (duration) {
- return new cc.FlipX3D(duration);
-};
-
-/**
- * Please use cc.flipX3D instead.
- * Create a Flip X 3D action with duration.
- * Flip around.
- * @param {Number} duration
- * @return {cc.FlipX3D}
- * @static
- * @deprecated since v3.0
Please use cc.flipX3D instead.
- */
-cc.FlipX3D.create = cc.flipX3D;
-
-/**
- * cc.FlipY3D action.
- * Upside down.
- * Reference the test cases (Effects Test)
- * @class
- * @extends cc.FlipX3D
- * @param {Number} duration
- */
-cc.FlipY3D = cc.FlipX3D.extend(/** @lends cc.FlipY3D# */{
-
- /**
- * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
- * Create a flip Y 3d action with duration.
- * @param {Number} duration
- */
- ctor: function(duration) {
- if (duration !== undefined)
- cc.GridAction.prototype.ctor.call(this, duration, cc.size(1, 1));
- else cc.GridAction.prototype.ctor.call(this);
- },
-
- /**
- * Called once per frame. Time is the number of seconds of a frame interval.
- *
- * @param {Number} dt
- */
- update:function (dt) {
- var angle = Math.PI * dt; // 180 degrees
- var mz = Math.sin(angle);
- angle = angle / 2.0; // x calculates degrees from 0 to 90
- var my = Math.cos(angle);
-
- var diff = new cc.Vertex3F();
-
- var tempP = cc.p(0, 0);
- tempP.x = tempP.y = 1;
- var v0 = this.originalVertex(tempP);
- tempP.x = tempP.y = 0;
- var v1 = this.originalVertex(tempP);
-
- var y0 = v0.y;
- var y1 = v1.y;
- var y;
- var a, b, c, d;
-
- if (y0 > y1) {
- // Normal Grid
- a = cc.p(0, 0);
- b = cc.p(0, 1);
- c = cc.p(1, 0);
- d = cc.p(1, 1);
- y = y0;
- } else {
- // Reversed Grid
- b = cc.p(0, 0);
- a = cc.p(0, 1);
- d = cc.p(1, 0);
- c = cc.p(1, 1);
- y = y1;
- }
-
- diff.y = y - y * my;
- diff.z = Math.abs(parseFloat(y * mz) / 4.0);
-
- // bottom-left
- var v = this.originalVertex(a);
- v.y = diff.y;
- v.z += diff.z;
- this.setVertex(a, v);
-
- // upper-left
- v = this.originalVertex(b);
- v.y -= diff.y;
- v.z -= diff.z;
- this.setVertex(b, v);
-
- // bottom-right
- v = this.originalVertex(c);
- v.y = diff.y;
- v.z += diff.z;
- this.setVertex(c, v);
-
- // upper-right
- v = this.originalVertex(d);
- v.y -= diff.y;
- v.z -= diff.z;
- this.setVertex(d, v);
- }
-});
-
-/**
- * Create a flip Y 3d action with duration.
- * Upside down.
- * @function
- * @param {Number} duration
- * @return {cc.FlipY3D}
- */
-cc.flipY3D = function (duration) {
- return new cc.FlipY3D(duration);
-};
-
-/**
- * Please use cc.flipY3D instead.
- * Create a flip Y 3d action with duration.
- * @param {Number} duration
- * @return {cc.FlipY3D}
- * @static
- * @deprecated since v3.0
Please use cc.flipY3D instead.
- */
-cc.FlipY3D.create = cc.flipY3D;
-
-/**
- * cc.Lens3D action.
- * Upside down.
- * Reference the test cases (Effects Test)
- * @class
- * @extends cc.Grid3DAction
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {cc.Vec2} position
- * @param {Number} radius
- */
-cc.Lens3D = cc.Grid3DAction.extend(/** @lends cc.Lens3D# */{
- //lens center position
- _position:null,
- _radius:0,
- //lens effect. Defaults to 0.7 - 0 means no effect, 1 is very strong effect
- _lensEffect:0,
- //lens is concave. (true = concave, false = convex) default is convex i.e. false
- _concave:false,
- _dirty:false,
-
- /**
- * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
- * creates a lens 3d action with center position, radius.
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {cc.Vec2} position
- * @param {Number} radius
- */
- ctor:function (duration, gridSize, position, radius) {
- cc.GridAction.prototype.ctor.call(this);
-
- this._position = cc.p(0, 0);
- radius !== undefined && this.initWithDuration(duration, gridSize, position, radius);
- },
-
- /**
- * Get lens center position
- * @return {Number}
- */
- getLensEffect:function () {
- return this._lensEffect;
- },
-
- /**
- * Set lens center position
- * @param {Number} lensEffect
- */
- setLensEffect:function (lensEffect) {
- this._lensEffect = lensEffect;
- },
-
- /**
- * Set whether lens is concave
- * @param {Boolean} concave
- */
- setConcave:function (concave) {
- this._concave = concave;
- },
-
- /**
- * get Position
- * @return {cc.Vec2}
- */
- getPosition:function () {
- return this._position;
- },
-
- /**
- * set Position
- * @param {cc.Vec2} position
- */
- setPosition:function (position) {
- if (!cc.pointEqualToPoint(position, this._position)) {
- this._position.x = position.x;
- this._position.y = position.y;
- this._dirty = true;
- }
- },
-
- /**
- * initializes the action with center position, radius, a grid size and duration
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {cc.Vec2} position
- * @param {Number} radius
- * @return {Boolean}
- */
- initWithDuration:function (duration, gridSize, position, radius) {
- if (cc.Grid3DAction.prototype.initWithDuration.call(this, duration, gridSize)) {
- this.setPosition(position);
- this._radius = radius;
- this._lensEffect = 0.7;
- this._dirty = true;
- return true;
- }
- return false;
- },
-
- /**
- * Called once per frame. Time is the number of seconds of a frame interval.
- *
- * @param {Number} dt
- */
- update:function (dt) {
- if (this._dirty) {
- var locGridSizeWidth = this._gridSize.width, locGridSizeHeight = this._gridSize.height;
- var locRadius = this._radius, locLensEffect = this._lensEffect;
- var locPos = cc.p(0, 0);
- var vect = cc.p(0, 0);
- var v, r, l, new_r, pre_log;
- for (var i = 0; i < locGridSizeWidth + 1; ++i) {
- for (var j = 0; j < locGridSizeHeight + 1; ++j) {
- locPos.x = i;
- locPos.y = j;
- v = this.originalVertex(locPos);
- vect.x = this._position.x - v.x;
- vect.y = this._position.y - v.y;
- r = cc.pLength(vect);
-
- if (r < locRadius) {
- r = locRadius - r;
- pre_log = r / locRadius;
- if (pre_log === 0)
- pre_log = 0.001;
-
- l = Math.log(pre_log) * locLensEffect;
- new_r = Math.exp(l) * locRadius;
-
- r = cc.pLength(vect);
- if (r > 0) {
- vect.x = vect.x / r;
- vect.y = vect.y / r;
-
- vect.x = vect.x * new_r;
- vect.y = vect.y * new_r;
- v.z += cc.pLength(vect) * locLensEffect;
- }
- }
- this.setVertex(locPos, v);
- }
- }
- this._dirty = false;
- }
- }
-});
-
-/**
- * creates a lens 3d action with center position, radius
- * @function
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {cc.Vec2} position
- * @param {Number} radius
- * @return {cc.Lens3D}
- */
-cc.lens3D = function (duration, gridSize, position, radius) {
- return new cc.Lens3D(duration, gridSize, position, radius);
-};
-
-/**
- * Please use cc.lens3D instead
- * creates a lens 3d action with center position, radius
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {cc.Vec2} position
- * @param {Number} radius
- * @return {cc.Lens3D}
- * @static
- * @deprecated since v3.0
Please use cc.lens3D instead.
- */
-cc.Lens3D.create = cc.lens3D;
-
-/**
- * cc.Ripple3D action.
- * Reference the test cases (Effects Test)
- * @class
- * @extends cc.Grid3DAction
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {cc.Vec2} position
- * @param {Number} radius
- * @param {Number} waves
- * @param {Number} amplitude
- */
-cc.Ripple3D = cc.Grid3DAction.extend(/** @lends cc.Ripple3D# */{
- /* center position */
- _position: null,
- _radius: 0,
- _waves: 0,
- _amplitude: 0,
- _amplitudeRate: 0,
-
- /**
- * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
- * creates a ripple 3d action with radius, number of waves, amplitude.
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {cc.Vec2} position
- * @param {Number} radius
- * @param {Number} waves
- * @param {Number} amplitude
- */
- ctor:function (duration, gridSize, position, radius, waves, amplitude) {
- cc.GridAction.prototype.ctor.call(this);
-
- this._position = cc.p(0, 0);
- amplitude !== undefined && this.initWithDuration(duration, gridSize, position, radius, waves, amplitude);
- },
-
- /**
- * get center position
- * @return {cc.Vec2}
- */
- getPosition:function () {
- return this._position;
- },
-
- /**
- * set center position
- * @param {cc.Vec2} position
- */
- setPosition:function (position) {
- this._position.x = position.x;
- this._position.y = position.y;
- },
-
- /**
- * get Amplitude
- * @return {Number}
- */
- getAmplitude:function () {
- return this._amplitude;
- },
-
- /**
- * set Amplitude
- * @param {Number} amplitude
- */
- setAmplitude:function (amplitude) {
- this._amplitude = amplitude;
- },
-
- /**
- * get Amplitude rate
- * @return {Number}
- */
- getAmplitudeRate:function () {
- return this._amplitudeRate;
- },
-
- /**
- * get amplitude rate
- * @param {Number} amplitudeRate
- */
- setAmplitudeRate:function (amplitudeRate) {
- this._amplitudeRate = amplitudeRate;
- },
-
- /**
- * initializes the action with radius, number of waves, amplitude, a grid size and duration
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {cc.Vec2} position
- * @param {Number} radius
- * @param {Number} waves
- * @param {Number} amplitude
- * @return {Boolean}
- */
- initWithDuration:function (duration, gridSize, position, radius, waves, amplitude) {
- if (cc.Grid3DAction.prototype.initWithDuration.call(this, duration, gridSize)) {
- this.setPosition(position);
- this._radius = radius;
- this._waves = waves;
- this._amplitude = amplitude;
- this._amplitudeRate = 1.0;
- return true;
- }
- return false;
- },
-
- /**
- * Called once per frame. Time is the number of seconds of a frame interval.
- *
- * @param {Number} dt
- */
- update:function (dt) {
- var locGridSizeWidth = this._gridSize.width, locGridSizeHeight = this._gridSize.height;
- var locPos = cc.p(0, 0), locRadius = this._radius;
- var locWaves = this._waves, locAmplitude = this._amplitude, locAmplitudeRate = this._amplitudeRate;
- var v, r, tempPos = cc.p(0, 0);
- for (var i = 0; i < (locGridSizeWidth + 1); ++i) {
- for (var j = 0; j < (locGridSizeHeight + 1); ++j) {
- locPos.x = i;
- locPos.y = j;
- v = this.originalVertex(locPos);
-
- tempPos.x = this._position.x - v.x;
- tempPos.y = this._position.y - v.y;
- r = cc.pLength(tempPos);
-
- if (r < locRadius) {
- r = locRadius - r;
- var rate = Math.pow(r / locRadius, 2);
- v.z += (Math.sin(dt * Math.PI * locWaves * 2 + r * 0.1) * locAmplitude * locAmplitudeRate * rate);
- }
- this.setVertex(locPos, v);
- }
- }
- }
-});
-
-/**
- * creates a ripple 3d action with radius, number of waves, amplitude
- * @function
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {cc.Vec2} position
- * @param {Number} radius
- * @param {Number} waves
- * @param {Number} amplitude
- * @return {cc.Ripple3D}
- */
-cc.ripple3D = function (duration, gridSize, position, radius, waves, amplitude) {
- return new cc.Ripple3D(duration, gridSize, position, radius, waves, amplitude);
-};
-
-/**
- * Please use cc.ripple3D instead
- * creates a ripple 3d action with radius, number of waves, amplitude
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {cc.Vec2} position
- * @param {Number} radius
- * @param {Number} waves
- * @param {Number} amplitude
- * @return {cc.Ripple3D}
- * @static
- * @deprecated since v3.0
Please use cc.ripple3D instead.
- */
-cc.Ripple3D.create = cc.ripple3D;
-
-/**
- * cc.Shaky3D action.
- * Reference the test cases (Effects Test)
- * @class
- * @extends cc.Grid3DAction
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} range
- * @param {Boolean} shakeZ
- */
-cc.Shaky3D = cc.Grid3DAction.extend(/** @lends cc.Shaky3D# */{
- _randRange: 0,
- _shakeZ: false,
-
- /**
- * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
- * Create a shaky3d action with a range, shake Z vertices.
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} range
- * @param {Boolean} shakeZ
- */
- ctor:function (duration, gridSize, range, shakeZ) {
- cc.GridAction.prototype.ctor.call(this);
- shakeZ !== undefined && this.initWithDuration(duration, gridSize, range, shakeZ);
- },
-
- /**
- * initializes the action with a range, shake Z vertices, a grid and duration
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} range
- * @param {Boolean} shakeZ
- * @return {Boolean}
- */
- initWithDuration:function (duration, gridSize, range, shakeZ) {
- if (cc.Grid3DAction.prototype.initWithDuration.call(this, duration, gridSize)) {
- this._randRange = range;
- this._shakeZ = shakeZ;
- return true;
- }
- return false;
- },
-
- /**
- * Called once per frame. Time is the number of seconds of a frame interval.
- *
- * @param {Number} dt
- */
- update:function (dt) {
- var locGridSizeWidth = this._gridSize.width, locGridSizeHeight = this._gridSize.height;
- var locRandRange = this._randRange, locShakeZ = this._shakeZ, locP = cc.p(0, 0);
- var v;
- for (var i = 0; i < (locGridSizeWidth + 1); ++i) {
- for (var j = 0; j < (locGridSizeHeight + 1); ++j) {
- locP.x = i;
- locP.y = j;
- v = this.originalVertex(locP);
- v.x += (cc.rand() % (locRandRange * 2)) - locRandRange;
- v.y += (cc.rand() % (locRandRange * 2)) - locRandRange;
- if (locShakeZ)
- v.z += (cc.rand() % (locRandRange * 2)) - locRandRange;
- this.setVertex(locP, v);
- }
- }
- }
-});
-
-/**
- * creates the action with a range, shake Z vertices, a grid and duration
- * @function
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} range
- * @param {Boolean} shakeZ
- * @return {cc.Shaky3D}
- */
-cc.shaky3D = function (duration, gridSize, range, shakeZ) {
- return new cc.Shaky3D(duration, gridSize, range, shakeZ);
-};
-
-/**
- * Please use cc.shaky3D instead
- * creates the action with a range, shake Z vertices, a grid and duration
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} range
- * @param {Boolean} shakeZ
- * @return {cc.Shaky3D}
- * @static
- * @deprecated since v3.0
Please use cc.shaky3D instead.
- */
-cc.Shaky3D.create = cc.shaky3D;
-
-/**
- * cc.Liquid action.
- * Reference the test cases (Effects Test)
- * @class
- * @extends cc.Grid3DAction
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} waves
- * @param {Number} amplitude
- */
-cc.Liquid = cc.Grid3DAction.extend(/** @lends cc.Liquid# */{
- _waves: 0,
- _amplitude: 0,
- _amplitudeRate: 0,
-
- /**
- * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
- * Create a liquid action with amplitude, a grid and duration.
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} waves
- * @param {Number} amplitude
- */
- ctor: function (duration, gridSize, waves, amplitude) {
- cc.GridAction.prototype.ctor.call(this);
- amplitude !== undefined && this.initWithDuration(duration, gridSize, waves, amplitude);
- },
-
- /**
- * get amplitude
- * @return {Number}
- */
- getAmplitude:function () {
- return this._amplitude;
- },
-
- /**
- * set amplitude
- * @param {Number} amplitude
- */
- setAmplitude:function (amplitude) {
- this._amplitude = amplitude;
- },
-
- /**
- * get amplitude rate
- * @return {Number}
- */
- getAmplitudeRate:function () {
- return this._amplitudeRate;
- },
-
- /**
- * set amplitude rate
- * @param {Number} amplitudeRate
- */
- setAmplitudeRate:function (amplitudeRate) {
- this._amplitudeRate = amplitudeRate;
- },
-
- /**
- * initializes the action with amplitude, a grid and duration
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} waves
- * @param {Number} amplitude
- * @return {Boolean}
- */
- initWithDuration:function (duration, gridSize, waves, amplitude) {
- if (cc.Grid3DAction.prototype.initWithDuration.call(this, duration, gridSize)) {
- this._waves = waves;
- this._amplitude = amplitude;
- this._amplitudeRate = 1.0;
- return true;
- }
- return false;
- },
-
- /**
- * Called once per frame. Time is the number of seconds of a frame interval.
- *
- * @param {Number} dt
- */
- update:function (dt) {
- var locSizeWidth = this._gridSize.width, locSizeHeight = this._gridSize.height, locPos = cc.p(0, 0);
- var locWaves = this._waves, locAmplitude = this._amplitude, locAmplitudeRate = this._amplitudeRate;
- var v;
- for (var i = 1; i < locSizeWidth; ++i) {
- for (var j = 1; j < locSizeHeight; ++j) {
- locPos.x = i;
- locPos.y = j;
- v = this.originalVertex(locPos);
- v.x = (v.x + (Math.sin(dt * Math.PI * locWaves * 2 + v.x * .01) * locAmplitude * locAmplitudeRate));
- v.y = (v.y + (Math.sin(dt * Math.PI * locWaves * 2 + v.y * .01) * locAmplitude * locAmplitudeRate));
- this.setVertex(locPos, v);
- }
- }
- }
-});
-
-/**
- * creates the action with amplitude, a grid and duration
- * @function
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} waves
- * @param {Number} amplitude
- * @return {cc.Liquid}
- */
-cc.liquid = function (duration, gridSize, waves, amplitude) {
- return new cc.Liquid(duration, gridSize, waves, amplitude);
-};
-
-/**
- * Please use cc.liquid instead
- * creates the action with amplitude, a grid and duration
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} waves
- * @param {Number} amplitude
- * @return {cc.Liquid}
- * @static
- * @deprecated since v3.0
Please use cc.liquid instead.
- */
-cc.Liquid.create = cc.liquid;
-
-/**
- * cc.Waves action.
- * Reference the test cases (Effects Test)
- * @class
- * @extends cc.Grid3DAction
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} waves
- * @param {Number} amplitude
- * @param {Boolean} horizontal
- * @param {Boolean} vertical
- */
-cc.Waves = cc.Grid3DAction.extend(/** @lends cc.Waves# */{
- _waves: 0,
- _amplitude: 0,
- _amplitudeRate: 0,
- _vertical: false,
- _horizontal: false,
-
- /**
- * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
- * Create a wave action with amplitude, horizontal sin, vertical sin, a grid and duration.
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} waves
- * @param {Number} amplitude
- * @param {Boolean} horizontal
- * @param {Boolean} vertical
- */
- ctor: function (duration, gridSize, waves, amplitude, horizontal, vertical) {
- cc.GridAction.prototype.ctor.call(this);
- vertical !== undefined && this.initWithDuration(duration, gridSize, waves, amplitude, horizontal, vertical);
- },
-
- /**
- * get amplitude
- * @return {Number}
- */
- getAmplitude:function () {
- return this._amplitude;
- },
-
- /**
- * set amplitude
- * @param {Number} amplitude
- */
- setAmplitude:function (amplitude) {
- this._amplitude = amplitude;
- },
-
- /**
- * get amplitude rate
- * @return {Number}
- */
- getAmplitudeRate:function () {
- return this._amplitudeRate;
- },
-
- /**
- * set amplitude rate
- * @param {Number} amplitudeRate
- */
- setAmplitudeRate:function (amplitudeRate) {
- this._amplitudeRate = amplitudeRate;
- },
-
- /**
- * initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} waves
- * @param {Number} amplitude
- * @param {Boolean} horizontal
- * @param {Boolean} vertical
- * @return {Boolean}
- */
- initWithDuration:function (duration, gridSize, waves, amplitude, horizontal, vertical) {
- if (cc.Grid3DAction.prototype.initWithDuration.call(this, duration, gridSize)) {
- this._waves = waves;
- this._amplitude = amplitude;
- this._amplitudeRate = 1.0;
- this._horizontal = horizontal;
- this._vertical = vertical;
- return true;
- }
- return false;
- },
-
- /**
- * Called once per frame. Time is the number of seconds of a frame interval.
- *
- * @param {Number} dt
- */
- update:function (dt) {
- var locSizeWidth = this._gridSize.width, locSizeHeight = this._gridSize.height, locPos = cc.p(0, 0);
- var locVertical = this._vertical, locHorizontal = this._horizontal;
- var locWaves = this._waves, locAmplitude = this._amplitude, locAmplitudeRate = this._amplitudeRate;
- var v;
- for (var i = 0; i < locSizeWidth + 1; ++i) {
- for (var j = 0; j < locSizeHeight + 1; ++j) {
- locPos.x = i;
- locPos.y = j;
- v = this.originalVertex(locPos);
- if (locVertical)
- v.x = (v.x + (Math.sin(dt * Math.PI * locWaves * 2 + v.y * .01) * locAmplitude * locAmplitudeRate));
- if (locHorizontal)
- v.y = (v.y + (Math.sin(dt * Math.PI * locWaves * 2 + v.x * .01) * locAmplitude * locAmplitudeRate));
- this.setVertex(locPos, v);
- }
- }
- }
-});
-
-/**
- * initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration
- * @function
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} waves
- * @param {Number} amplitude
- * @param {Boolean} horizontal
- * @param {Boolean} vertical
- * @return {cc.Waves}
- */
-cc.waves = function (duration, gridSize, waves, amplitude, horizontal, vertical) {
- return new cc.Waves(duration, gridSize, waves, amplitude, horizontal, vertical);
-};
-
-/**
- * Please use cc.waves instead
- * initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} waves
- * @param {Number} amplitude
- * @param {Boolean} horizontal
- * @param {Boolean} vertical
- * @return {cc.Waves}
- * @static
- * @deprecated since v3.0
Please use cc.waves instead.
- */
-cc.Waves.create = cc.waves;
-
-/** @brief */
-/**
- * cc.Twirl action.
- * Reference the test cases (Effects Test)
- * @class
- * @extends cc.Grid3DAction
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {cc.Vec2} position
- * @param {Number} twirls
- * @param {Number} amplitude
- */
-cc.Twirl = cc.Grid3DAction.extend(/** @lends cc.Twirl# */{
- /* twirl center */
- _position: null,
- _twirls: 0,
- _amplitude: 0,
- _amplitudeRate: 0,
-
- /**
- * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
- * Create a grid 3d action with center position, number of twirls, amplitude, a grid size and duration.
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {cc.Vec2} position
- * @param {Number} twirls
- * @param {Number} amplitude
- */
- ctor:function (duration, gridSize, position, twirls, amplitude) {
- cc.GridAction.prototype.ctor.call(this);
-
- this._position = cc.p(0, 0);
- amplitude !== undefined && this.initWithDuration(duration, gridSize, position, twirls, amplitude);
- },
-
- /**
- * get twirl center
- * @return {cc.Vec2}
- */
- getPosition:function () {
- return this._position;
- },
-
- /**
- * set twirl center
- * @param {cc.Vec2} position
- */
- setPosition:function (position) {
- this._position.x = position.x;
- this._position.y = position.y;
- },
-
- /**
- * get amplitude
- * @return {Number}
- */
- getAmplitude:function () {
- return this._amplitude;
- },
-
- /**
- * set amplitude
- * @param {Number} amplitude
- */
- setAmplitude:function (amplitude) {
- this._amplitude = amplitude;
- },
-
- /**
- * get amplitude rate
- * @return {Number}
- */
- getAmplitudeRate:function () {
- return this._amplitudeRate;
- },
-
- /**
- * set amplitude rate
- * @param {Number} amplitudeRate
- */
- setAmplitudeRate:function (amplitudeRate) {
- this._amplitudeRate = amplitudeRate;
- },
-
- /** initializes the action with center position, number of twirls, amplitude, a grid size and duration */
- initWithDuration:function (duration, gridSize, position, twirls, amplitude) {
- if (cc.Grid3DAction.prototype.initWithDuration.call(this, duration, gridSize)) {
- this.setPosition(position);
- this._twirls = twirls;
- this._amplitude = amplitude;
- this._amplitudeRate = 1.0;
- return true;
- }
- return false;
- },
-
- /**
- * Called once per frame. Time is the number of seconds of a frame interval.
- *
- * @param {Number} dt
- */
- update:function (dt) {
- var c = this._position;
- var locSizeWidth = this._gridSize.width, locSizeHeight = this._gridSize.height, locPos = cc.p(0, 0);
- var amp = 0.1 * this._amplitude * this._amplitudeRate;
- var locTwirls = this._twirls;
- var v, a, dX, dY, avg = cc.p(0, 0);
- for (var i = 0; i < (locSizeWidth + 1); ++i) {
- for (var j = 0; j < (locSizeHeight + 1); ++j) {
- locPos.x = i;
- locPos.y = j;
- v = this.originalVertex(locPos);
-
- avg.x = i - (locSizeWidth / 2.0);
- avg.y = j - (locSizeHeight / 2.0);
-
- a = cc.pLength(avg) * Math.cos(Math.PI / 2.0 + dt * Math.PI * locTwirls * 2) * amp;
-
- dX = Math.sin(a) * (v.y - c.y) + Math.cos(a) * (v.x - c.x);
- dY = Math.cos(a) * (v.y - c.y) - Math.sin(a) * (v.x - c.x);
-
- v.x = c.x + dX;
- v.y = c.y + dY;
-
- this.setVertex(locPos, v);
- }
- }
- }
-});
-
-/**
- * creates the action with center position, number of twirls, amplitude, a grid size and duration
- * @function
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {cc.Vec2} position
- * @param {Number} twirls
- * @param {Number} amplitude
- * @return {cc.Twirl}
- */
-cc.twirl = function (duration, gridSize, position, twirls, amplitude) {
- return new cc.Twirl(duration, gridSize, position, twirls, amplitude);
-};
-
-/**
- * Please use cc.twirl instead
- * creates the action with center position, number of twirls, amplitude, a grid size and duration
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {cc.Vec2} position
- * @param {Number} twirls
- * @param {Number} amplitude
- * @return {cc.Twirl}
- * @static
- * @deprecated since v3.0
Please use cc.twirl instead.
- */
-cc.Twirl.create = cc.twirl;
diff --git a/cocos2d/actions3d/CCActionPageTurn3D.js b/cocos2d/actions3d/CCActionPageTurn3D.js
deleted file mode 100644
index 63d5e791f9..0000000000
--- a/cocos2d/actions3d/CCActionPageTurn3D.js
+++ /dev/null
@@ -1,130 +0,0 @@
-/****************************************************************************
- Copyright (c) 2008-2010 Ricardo Quesada
- Copyright (c) 2011-2012 cocos2d-x.org
- Copyright (c) 2013-2014 Chukong Technologies Inc.
-
- http://www.cocos2d-x.org
-
- 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.
- ****************************************************************************/
-
-/**
- *
- * This action simulates a page turn from the bottom right hand corner of the screen.
- * It's not much use by itself but is used by the PageTurnTransition.
- *
- * Based on an original paper by L Hong et al.
- * http://www.parc.com/publication/1638/turning-pages-of-3d-electronic-books.html
- *
- * @class
- * @extends cc.Grid3DAction
- */
-cc.PageTurn3D = cc.Grid3DAction.extend(/** @lends cc.PageTurn3D# */{
- getGrid: function(){
- var result = new cc.Grid3D(this._gridSize, undefined, undefined, this._gridNodeTarget.getGridRect());
- result.setNeedDepthTestForBlit(true);
- return result;
- },
-
- clone: function(){
- var ret = new cc.PageTurn3D();
- ret.initWithDuration(this._duration, this._gridSize);
- return ret;
- },
-
- /**
- * Update each tick
- * Time is the percentage of the way through the duration
- */
- update:function (time) {
- var tt = Math.max(0, time - 0.25);
- var deltaAy = (tt * tt * 500);
- var ay = -100 - deltaAy;
-
- var deltaTheta = Math.sqrt(time);
- var theta = deltaTheta>0.5?Math.PI/2 *deltaTheta : Math.PI/2*(1-deltaTheta);
- var rotateByYAxis = (2-time)*Math.PI;
-
- var sinTheta = Math.sin(theta);
- var cosTheta = Math.cos(theta);
-
- var locGridSize = this._gridSize;
- var locVer = cc.p(0, 0);
- for (var i = 0; i <= locGridSize.width; ++i) {
- for (var j = 0; j <= locGridSize.height; ++j) {
- locVer.x = i;
- locVer.y = j;
- // Get original vertex
- var p = this.getOriginalVertex(locVer);
-
- p.x -= this.getGridRect().x;
- var R = Math.sqrt((p.x * p.x) + ((p.y - ay) * (p.y - ay)));
- var r = R * sinTheta;
- var alpha = Math.asin(p.x / R);
- var beta = alpha / sinTheta;
- var cosBeta = Math.cos(beta);
-
- // If beta > PI then we've wrapped around the cone
- // Reduce the radius to stop these points interfering with others
- if (beta <= Math.PI)
- p.x = ( r * Math.sin(beta));
- else
- p.x = 0; //Force X = 0 to stop wrapped points
-
- p.y = ( R + ay - ( r * (1 - cosBeta) * sinTheta));
-
- // We scale z here to avoid the animation being
- // too much bigger than the screen due to perspectve transform
- p.z = (r * ( 1 - cosBeta ) * cosTheta);// "100" didn't work for
- p.x = p.z * Math.sin(rotateByYAxis) + p.x * Math.cos(rotateByYAxis);
- p.z = p.z * Math.cos(rotateByYAxis) - p.x * Math.cos(rotateByYAxis);
- p.z/= 7;
- // Stop z coord from dropping beneath underlying page in a transition
- // issue #751
- if (p.z < 0.5)
- p.z = 0.5;
-
- // Set new coords
- p.x+= this.getGridRect().x;
- this.setVertex(locVer, p);
- }
- }
- }
-});
-
-/**
- * create PageTurn3D action
- * @function
- * @param {Number} duration
- * @param {Size} gridSize
- * @return {cc.PageTurn3D}
- */
-cc.pageTurn3D = function (duration, gridSize) {
- return new cc.PageTurn3D(duration, gridSize);
-};
-/**
- * Please use cc.pageTurn3D instead
- * create PageTurn3D action
- * @param {Number} duration
- * @param {Size} gridSize
- * @return {cc.PageTurn3D}
- * @static
- * @deprecated since v3.0 please use cc.pageTurn3D instead.
- */
-cc.PageTurn3D.create = cc.pageTurn3D;
diff --git a/cocos2d/actions3d/CCActionTiledGrid.js b/cocos2d/actions3d/CCActionTiledGrid.js
deleted file mode 100644
index 012a0c90fe..0000000000
--- a/cocos2d/actions3d/CCActionTiledGrid.js
+++ /dev/null
@@ -1,1300 +0,0 @@
-/****************************************************************************
- Copyright (c) 2008-2010 Ricardo Quesada
- Copyright (c) 2011-2012 cocos2d-x.org
- Copyright (c) 2013-2014 Chukong Technologies Inc.
-
- http://www.cocos2d-x.org
-
- 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.
- ****************************************************************************/
-
-/**
- * cc.ShakyTiles3D action.
- * Reference the test cases (Effects Test)
- * @class
- * @extends cc.TiledGrid3DAction
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} range
- * @param {Boolean} shakeZ
- */
-cc.ShakyTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.ShakyTiles3D# */{
- _randRange:0,
- _shakeZ:false,
-
- /**
- * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
- * Creates the action with a range, whether or not to shake Z vertices, a grid size, and duration.
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} range
- * @param {Boolean} shakeZ
- */
- ctor:function (duration, gridSize, range, shakeZ) {
- cc.GridAction.prototype.ctor.call(this);
- shakeZ !== undefined && this.initWithDuration(duration, gridSize, range, shakeZ);
- },
-
- /**
- * Initializes the action with a range, whether or not to shake Z vertices, a grid size, and duration.
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} range
- * @param {Boolean} shakeZ
- * @return {Boolean}
- */
- initWithDuration:function (duration, gridSize, range, shakeZ) {
- if (cc.TiledGrid3DAction.prototype.initWithDuration.call(this, duration, gridSize)) {
- this._randRange = range;
- this._shakeZ = shakeZ;
- return true;
- }
- return false;
- },
-
- /**
- * Called once per frame. Time is the number of seconds of a frame interval.
- * @param {Number} dt
- */
- update:function (dt) {
- var locGridSize = this._gridSize, locRandRange = this._randRange;
- var locPos = cc.p(0, 0);
- for (var i = 0; i < locGridSize.width; ++i) {
- for (var j = 0; j < locGridSize.height; ++j) {
- locPos.x = i;
- locPos.y = j;
- var coords = this.originalTile(locPos);
-
- // X
- coords.bl.x += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
- coords.br.x += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
- coords.tl.x += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
- coords.tr.x += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
-
- // Y
- coords.bl.y += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
- coords.br.y += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
- coords.tl.y += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
- coords.tr.y += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
-
- if (this._shakeZ) {
- coords.bl.z += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
- coords.br.z += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
- coords.tl.z += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
- coords.tr.z += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
- }
-
- this.setTile(locPos, coords);
- }
- }
- }
-});
-
-/**
- * Creates the action with a range, whether or not to shake Z vertices, a grid size, and duration.
- * Reference the test cases (Effects Test)
- * @function
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} range
- * @param {Boolean} shakeZ
- * @return {cc.ShakyTiles3D}
- */
-cc.shakyTiles3D = function (duration, gridSize, range, shakeZ) {
- return new cc.ShakyTiles3D(duration, gridSize, range, shakeZ);
-};
-
-/**
- * Please use cc.shakyTiles3D instead.
- * creates the action with a range, whether or not to shake Z vertices, a grid size, and duration.
- * Reference the test cases (Effects Test)
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} range
- * @param {Boolean} shakeZ
- * @return {cc.ShakyTiles3D}
- * @static
- * @deprecated since v3.0
Please use cc.shakyTiles3D instead.
- */
-cc.ShakyTiles3D.create = cc.shakyTiles3D;
-
-/**
- * cc.ShatteredTiles3D action.
- * Reference the test cases (Effects Test)
- * @class
- * @extends cc.TiledGrid3DAction
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} range
- * @param {Boolean} shatterZ
- */
-cc.ShatteredTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.ShatteredTiles3D# */{
- _randRange:0,
- _once:false,
- _shatterZ:false,
-
- /**
- * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
- * Creates the action with a range, whether of not to shatter Z vertices, a grid size and duration.
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} range
- * @param {Boolean} shatterZ
- */
- ctor:function (duration, gridSize, range, shatterZ) {
- cc.GridAction.prototype.ctor.call(this);
- shatterZ !== undefined && this.initWithDuration(duration, gridSize, range, shatterZ);
- },
-
- /**
- * Initializes the action with a range, whether or not to shatter Z vertices, a grid size and duration.
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} range
- * @param {Boolean} shatterZ
- * @return {Boolean}
- */
- initWithDuration:function (duration, gridSize, range, shatterZ) {
- if (cc.TiledGrid3DAction.prototype.initWithDuration.call(this, duration, gridSize)) {
- this._once = false;
- this._randRange = range;
- this._shatterZ = shatterZ;
- return true;
- }
- return false;
- },
-
- /**
- * Called once per frame. Time is the number of seconds of a frame interval.
- * @param {Number} dt
- */
- update:function (dt) {
- if (this._once === false) {
- var locGridSize = this._gridSize, locRandRange = this._randRange;
- var coords, locPos = cc.p(0, 0);
- for (var i = 0; i < locGridSize.width; ++i) {
- for (var j = 0; j < locGridSize.height; ++j) {
- locPos.x = i;
- locPos.y = j;
- coords = this.originalTile(locPos);
-
- // X
- coords.bl.x += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
- coords.br.x += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
- coords.tl.x += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
- coords.tr.x += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
-
- // Y
- coords.bl.y += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
- coords.br.y += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
- coords.tl.y += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
- coords.tr.y += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
-
- if (this._shatterZ) {
- coords.bl.z += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
- coords.br.z += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
- coords.tl.z += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
- coords.tr.z += ( cc.rand() % (locRandRange * 2) ) - locRandRange;
- }
- this.setTile(locPos, coords);
- }
- }
- this._once = true;
- }
- }
-});
-
-/**
- * Creates the action with a range, whether of not to shatter Z vertices, a grid size and duration.
- * Reference the test cases (Effects Test)
- * @function
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} range
- * @param {Boolean} shatterZ
- * @return {cc.ShatteredTiles3D}
- */
-cc.shatteredTiles3D = function (duration, gridSize, range, shatterZ) {
- return new cc.ShatteredTiles3D(duration, gridSize, range, shatterZ);
-};
-
-/**
- * Please use cc.shatteredTiles3D instead.
- * Creates the action with a range, whether of not to shatter Z vertices, a grid size and duration.
- * Reference the test cases (Effects Test)
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} range
- * @param {Boolean} shatterZ
- * @return {cc.ShatteredTiles3D}
- * @static
- * @deprecated since v3.0
Please use cc.shatteredTiles3D instead.
- */
-cc.ShatteredTiles3D.create = cc.shatteredTiles3D;
-
-/**
- * A Tile composed of position, startPosition and delta.
- * @Class
- *
- * @param {cc.Vec2} [position=cc.p(0,0)]
- * @param {cc.Vec2} [startPosition=cc.p(0,0)]
- * @param {Size} [delta=cc.p(0,0)]
- */
-cc.Tile = function (position, startPosition, delta) {
- this.position = position || cc.p(0,0);
- this.startPosition = startPosition || cc.p(0,0);
- this.delta = delta || cc.p(0,0);
-};
-
-/**
- * cc.ShuffleTiles action, Shuffle the tiles in random order.
- * Reference the test cases (Effects Test)
- * @class
- * @extends cc.TiledGrid3DAction
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} seed
- */
-cc.ShuffleTiles = cc.TiledGrid3DAction.extend(/** @lends cc.ShuffleTiles# */{
- _seed:0,
- _tilesCount:0,
- _tilesOrder:null,
- _tiles:null,
-
- /**
- * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
- * Creates the action with a random seed, the grid size and the duration.
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} seed
- */
- ctor:function (duration, gridSize, seed) {
- cc.GridAction.prototype.ctor.call(this);
- this._tilesOrder = [];
- this._tiles = [];
-
- seed !== undefined && this.initWithDuration(duration, gridSize, seed);
- },
-
- /**
- * Initializes the action with a random seed, the grid size and the duration.
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} seed
- * @return {Boolean}
- */
- initWithDuration:function (duration, gridSize, seed) {
- if (cc.TiledGrid3DAction.prototype.initWithDuration.call(this, duration, gridSize)) {
- this._seed = seed;
- this._tilesOrder.length = 0;
- this._tiles.length = 0;
- return true;
- }
- return false;
- },
-
- /**
- * Shuffle
- * @param {Array} array
- * @param {Number} len
- */
- shuffle:function (array, len) {
- for (var i = len - 1; i >= 0; i--) {
- var j = 0 | (cc.rand() % (i + 1));
- var v = array[i];
- array[i] = array[j];
- array[j] = v;
- }
- },
-
- /**
- * Get Delta
- * @param {Size} pos
- */
- getDelta:function (pos) {
- var locGridSize = this._gridSize;
- var idx = pos.width * locGridSize.height + pos.height;
- return cc.size(((this._tilesOrder[idx] / locGridSize.height) - pos.width),
- ((this._tilesOrder[idx] % locGridSize.height) - pos.height));
- },
-
- /**
- * Place Tile
- * @param {cc.Vec2} pos
- * @param {cc.Tile} tile
- */
- placeTile:function (pos, tile) {
- var coords = this.originalTile(pos);
-
- var step = this.target.grid.getStep();
- var locPosition = tile.position;
- coords.bl.x += (locPosition.x * step.x);
- coords.bl.y += (locPosition.y * step.y);
-
- coords.br.x += (locPosition.x * step.x);
- coords.br.y += (locPosition.y * step.y);
-
- coords.tl.x += (locPosition.x * step.x);
- coords.tl.y += (locPosition.y * step.y);
-
- coords.tr.x += (locPosition.x * step.x);
- coords.tr.y += (locPosition.y * step.y);
-
- this.setTile(pos, coords);
- },
-
- /**
- * Start with target
- * @param {_ccsg.Node} target
- */
- startWithTarget:function (target) {
- cc.TiledGrid3DAction.prototype.startWithTarget.call(this, target);
- var locGridSize = this._gridSize;
-
- this._tilesCount = locGridSize.width * locGridSize.height;
- var locTilesOrder = this._tilesOrder;
- locTilesOrder.length = 0;
-
- /**
- * Use k to loop. Because m_nTilesCount is unsigned int,
- * and i is used later for int.
- */
- for (var k = 0; k < this._tilesCount; ++k)
- locTilesOrder[k] = k;
- this.shuffle(locTilesOrder, this._tilesCount);
-
- var locTiles = this._tiles ;
- locTiles.length = 0;
- var tileIndex = 0, tempSize = cc.size(0,0);
- for (var i = 0; i < locGridSize.width; ++i) {
- for (var j = 0; j < locGridSize.height; ++j) {
- locTiles[tileIndex] = new cc.Tile();
- locTiles[tileIndex].position = cc.p(i, j);
- locTiles[tileIndex].startPosition = cc.p(i, j);
- tempSize.width = i;
- tempSize.height = j;
- locTiles[tileIndex].delta = this.getDelta(tempSize);
- ++tileIndex;
- }
- }
- },
-
- /**
- * Called once per frame. Time is the number of seconds of a frame interval.
- * @param {Number} dt
- */
- update:function (dt) {
- var tileIndex = 0, locGridSize = this._gridSize, locTiles = this._tiles;
- var selTile, locPos = cc.p(0, 0);
- for (var i = 0; i < locGridSize.width; ++i) {
- for (var j = 0; j < locGridSize.height; ++j) {
- locPos.x = i;
- locPos.y = j;
- selTile = locTiles[tileIndex];
- selTile.position.x = selTile.delta.width * dt;
- selTile.position.y = selTile.delta.height * dt;
- this.placeTile(locPos, selTile);
- ++tileIndex;
- }
- }
- }
-});
-
-/**
- * Creates the action with a random seed, the grid size and the duration.
- * Reference the test cases (Effects Test)
- * @function
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} seed
- * @return {cc.ShuffleTiles}
- */
-cc.shuffleTiles = function (duration, gridSize, seed) {
- return new cc.ShuffleTiles(duration, gridSize, seed);
-};
-
-/**
- * Please use cc.shuffleTiles instead.
- * Creates the action with a random seed, the grid size and the duration.
- * Reference the test cases (Effects Test)
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} seed
- * @return {cc.ShuffleTiles}
- * @static
- * @deprecated since v3.0
Please use cc.shuffleTiles instead.
- */
-cc.ShuffleTiles.create = cc.shuffleTiles;
-
-/**
- * cc.FadeOutTRTiles action. Fades out the tiles in a Top-Right direction.
- * Reference the test cases (Effects Test)
- * @class
- * @extends cc.TiledGrid3DAction
- */
-cc.FadeOutTRTiles = cc.TiledGrid3DAction.extend(/** @lends cc.FadeOutTRTiles# */{
- /**
- * Test function
- * @param {cc.Vec2} pos
- * @param {Number} time
- */
- testFunc:function (pos, time) {
- var locX = this._gridSize.width * time;
- var locY = this._gridSize.height * time;
- if (locX === this._gridSize.width && locY === this._gridSize.height) return 0.0;
- if ((locX + locY) === 0.0)
- return 1.0;
- return Math.pow((pos.x + pos.y) / (locX + locY), 6);
- },
-
- /**
- * Turn on Tile
- * @param {cc.Vec2} pos
- */
- turnOnTile:function (pos) {
- this.setTile(pos, this.originalTile(pos));
- },
-
- /**
- * Turn Off Tile
- * @param {cc.Vec2} pos
- */
- turnOffTile:function (pos) {
- this.setTile(pos, new cc.Quad3());
- },
-
- /**
- * Transform tile
- * @param {cc.Vec2} pos
- * @param {Number} distance
- */
- transformTile:function (pos, distance) {
- var coords = this.originalTile(pos);
- var step = this.target.grid.getStep();
-
- coords.bl.x += (step.x / 2) * (1.0 - distance);
- coords.bl.y += (step.y / 2) * (1.0 - distance);
-
- coords.br.x -= (step.x / 2) * (1.0 - distance);
- coords.br.y += (step.y / 2) * (1.0 - distance);
-
- coords.tl.x += (step.x / 2) * (1.0 - distance);
- coords.tl.y -= (step.y / 2) * (1.0 - distance);
-
- coords.tr.x -= (step.x / 2) * (1.0 - distance);
- coords.tr.y -= (step.y / 2) * (1.0 - distance);
-
- this.setTile(pos, coords);
- },
-
- /**
- * Called once per frame. Time is the number of seconds of a frame interval.
- * @param {Number} dt
- */
- update:function (dt) {
- var locGridSize = this._gridSize;
- var locPos = cc.p(0, 0), distance;
- for (var i = 0; i < locGridSize.width; ++i) {
- for (var j = 0; j < locGridSize.height; ++j) {
- locPos.x = i;
- locPos.y = j;
- distance = this.testFunc(locPos, dt);
- if (distance === 0)
- this.turnOffTile(locPos);
- else if (distance < 1)
- this.transformTile(locPos, distance);
- else
- this.turnOnTile(locPos);
- }
- }
- }
-});
-
-/**
- * Creates the action with the grid size and the duration.
- * Reference the test cases (Effects Test)
- * @function
- * @param duration
- * @param gridSize
- * @return {cc.FadeOutTRTiles}
- */
-cc.fadeOutTRTiles = function (duration, gridSize) {
- return new cc.FadeOutTRTiles(duration, gridSize);
-};
-
-/**
- * Please use cc.fadeOutTRTiles instead.
- * Creates the action with the grid size and the duration.
- * Reference the test cases (Effects Test)
- * @param duration
- * @param gridSize
- * @return {cc.FadeOutTRTiles}
- * @static
- * @deprecated since v3.0
Please use cc.fadeOutTRTiles instead.
- */
-cc.FadeOutTRTiles.create = cc.fadeOutTRTiles;
-
-/**
- * cc.FadeOutBLTiles action. Fades out the tiles in a Bottom-Left direction.
- * Reference the test cases (Effects Test)
- * @class
- * @extends cc.FadeOutTRTiles
- */
-cc.FadeOutBLTiles = cc.FadeOutTRTiles.extend(/** @lends cc.FadeOutBLTiles# */{
- /**
- * Test function
- * @param {cc.Vec2} pos
- * @param {Number} time
- */
- testFunc:function (pos, time) {
- var locX = this._gridSize.width * (1.0 - time);
- var locY = this._gridSize.height * (1.0 - time);
- if ((locX + locY) === 0)
- return 0.0;
- if ((pos.x + pos.y) === 0)
- return 1.0;
-
- return Math.pow((locX + locY) / (pos.x + pos.y), 6);
- }
-});
-
-/**
- * Creates the action with the grid size and the duration.
- * Reference the test cases (Effects Test)
- * @function
- * @param duration
- * @param gridSize
- * @return {cc.FadeOutBLTiles}
- */
-cc.fadeOutBLTiles = function (duration, gridSize) {
- return new cc.FadeOutBLTiles(duration, gridSize);
-};
-
-/**
- * Please use cc.fadeOutBLTiles instead.
- * Creates the action with the grid size and the duration.
- * Reference the test cases (Effects Test)
- * @param duration
- * @param gridSize
- * @return {cc.FadeOutBLTiles}
- * @static
- * @deprecated since v3.0
Please use cc.fadeOutBLTiles instead.
- */
-cc.FadeOutBLTiles.create = cc.fadeOutBLTiles;
-
-/**
- * cc.FadeOutUpTiles action. Fades out the tiles in upwards direction.
- * Reference the test cases (Effects Test)
- * @class
- * @extends cc.FadeOutTRTiles
- */
-cc.FadeOutUpTiles = cc.FadeOutTRTiles.extend(/** @lends cc.FadeOutUpTiles# */{
- /**
- * Test function
- * @param {cc.Vec2} pos
- * @param {Number} time
- */
- testFunc:function (pos, time) {
- var locY = this._gridSize.height * time;
- if( locY === this._gridSize.height) return 0.0;
- if (locY === 0.0) return 1.0;
- return Math.pow(pos.y / locY, 6);
- },
-
- transformTile:function (pos, distance) {
- var coords = this.originalTile(pos);
- var step = this.target.grid.getStep();
-
- coords.bl.y += (step.y / 2) * (1.0 - distance);
- coords.br.y += (step.y / 2) * (1.0 - distance);
- coords.tl.y -= (step.y / 2) * (1.0 - distance);
- coords.tr.y -= (step.y / 2) * (1.0 - distance);
-
- this.setTile(pos, coords);
- }
-});
-
-/**
- * Creates the action with the grid size and the duration.
- * Reference the test cases (Effects Test)
- * @function
- * @param {Number} duration
- * @param {Size} gridSize
- * @return {cc.FadeOutUpTiles}
- */
-cc.fadeOutUpTiles = function (duration, gridSize) {
- return new cc.FadeOutUpTiles(duration, gridSize);
-};
-
-/**
- * Please use cc.fadeOutUpTiles instead.
- * Creates the action with the grid size and the duration.
- * Reference the test cases (Effects Test)
- * @param {Number} duration
- * @param {Size} gridSize
- * @return {cc.FadeOutUpTiles}
- * @static
- * @deprecated since v3.0
Please use cc.fadeOutUpTiles instead.
- */
-cc.FadeOutUpTiles.create = cc.fadeOutUpTiles;
-
-/**
- * cc.FadeOutDownTiles action. Fades out the tiles in downwards direction.
- * Reference the test cases (Effects Test)
- * @class
- * @extends cc.FadeOutUpTiles
- */
-cc.FadeOutDownTiles = cc.FadeOutUpTiles.extend(/** @lends cc.FadeOutDownTiles# */{
- /**
- * Test function
- * @param {cc.Vec2} pos
- * @param {Number} time
- */
- testFunc:function (pos, time) {
- var locY = this._gridSize.height * (1.0 - time);
- if( locY === 0.0 ) return 0.0;
- if (pos.y === 0) return 1.0;
- return Math.pow(locY / pos.y, 6);
- }
-});
-
-/**
- * Creates the action with the grid size and the duration.
- * Reference the test cases (Effects Test)
- * @function
- * @param {Number} duration
- * @param {Size} gridSize
- * @return {cc.FadeOutDownTiles}
- */
-cc.fadeOutDownTiles = function (duration, gridSize) {
- return new cc.FadeOutDownTiles(duration, gridSize);
-};
-/**
- * Please use cc.fadeOutDownTiles instead.
- * Creates the action with the grid size and the duration.
- * Reference the test cases (Effects Test)
- * @param {Number} duration
- * @param {Size} gridSize
- * @return {cc.FadeOutDownTiles}
- * @static
- * @deprecated since v3.0
Please use cc.fadeOutDownTiles instead.
- */
-cc.FadeOutDownTiles.create = cc.fadeOutDownTiles;
-
-/**
- * cc.TurnOffTiles action.
- * Turn off the files in random order.
- * Reference the test cases (Effects Test)
- * @class
- * @extends cc.TiledGrid3DAction
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number|Null} [seed=0]
- * @example
- * // turnOffTiles without seed
- * var toff = new cc.TurnOffTiles(this._duration, cc.size(x, y));
- *
- * // turnOffTiles with seed
- * var toff = new cc.TurnOffTiles(this._duration, cc.size(x, y), 0);
- */
-cc.TurnOffTiles = cc.TiledGrid3DAction.extend(/** @lends cc.TurnOffTiles# */{
- _seed:null,
- _tilesCount:0,
- _tilesOrder:null,
-
- /**
- * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
- * Creates the action with a random seed, the grid size and the duration.
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number|Null} [seed=0]
- */
- ctor:function (duration, gridSize, seed) {
- cc.GridAction.prototype.ctor.call(this);
- this._tilesOrder = [];
-
- gridSize !== undefined && this.initWithDuration(duration, gridSize, seed);
- },
-
- /**
- * Initializes the action with a random seed, the grid size and the duration.
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number|Null} [seed=0]
- * @return {Boolean}
- */
- initWithDuration:function (duration, gridSize, seed) {
- if (cc.TiledGrid3DAction.prototype.initWithDuration.call(this, duration, gridSize)) {
- this._seed = seed || 0;
- this._tilesOrder.length = 0;
- return true;
- }
- return false;
- },
-
- /**
- * Shuffle
- * @param {Array} array
- * @param {Number} len
- */
- shuffle:function (array, len) {
- for (var i = len - 1; i >= 0; i--) {
- var j = 0 | (cc.rand() % (i + 1));
- var v = array[i];
- array[i] = array[j];
- array[j] = v;
- }
- },
-
- /**
- * Turn on tile.
- * @param {cc.Vec2} pos
- */
- turnOnTile:function (pos) {
- this.setTile(pos, this.originalTile(pos));
- },
-
- /**
- * Turn off title.
- * @param {cc.Vec2} pos
- */
- turnOffTile:function (pos) {
- this.setTile(pos, new cc.Quad3());
- },
-
- /**
- * called before the action start. It will also set the target.
- * @param {_ccsg.Node} target
- */
- startWithTarget:function (target) {
- cc.TiledGrid3DAction.prototype.startWithTarget.call(this, target);
-
- this._tilesCount = this._gridSize.width * this._gridSize.height;
- var locTilesOrder = this._tilesOrder;
- locTilesOrder.length = 0;
- for (var i = 0; i < this._tilesCount; ++i)
- locTilesOrder[i] = i;
- this.shuffle(locTilesOrder, this._tilesCount);
- },
-
- /**
- * Called once per frame. Time is the number of seconds of a frame interval.
- * @param {Number} dt
- */
- update:function (dt) {
- var l = 0 | (dt * this._tilesCount), locGridSize = this._gridSize;
- var t,tilePos = cc.p(0,0), locTilesOrder = this._tilesOrder;
- for (var i = 0; i < this._tilesCount; i++) {
- t = locTilesOrder[i];
- tilePos.x = 0 | (t / locGridSize.height);
- tilePos.y = t % (0 | locGridSize.height);
- if (i < l)
- this.turnOffTile(tilePos);
- else
- this.turnOnTile(tilePos);
- }
- }
-});
-
-/**
- * Creates the action with a random seed, the grid size and the duration.
- * Reference the test cases (Effects Test)
- * @function
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number|Null} [seed=0]
- * @return {cc.TurnOffTiles}
- * @example
- * // example
- * // turnOffTiles without seed
- * var toff = cc.turnOffTiles(this._duration, cc.size(x, y));
- *
- * // turnOffTiles with seed
- * var toff = cc.turnOffTiles(this._duration, cc.size(x, y), 0);
- */
-cc.turnOffTiles = function (duration, gridSize, seed) {
- return new cc.TurnOffTiles(duration, gridSize, seed);
-};
-/**
- * Please use cc.turnOffTiles instead.
- * Creates the action with a random seed, the grid size and the duration.
- * Reference the test cases (Effects Test)
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number|Null} [seed=0]
- * @return {cc.TurnOffTiles}
- * @static
- * @deprecated since v3.0
Please use cc.turnOffTiles instead.
- */
-cc.TurnOffTiles.create = cc.turnOffTiles;
-
-/**
- * cc.WavesTiles3D action.
- * Reference the test cases (Effects Test)
- * @class
- * @extends cc.TiledGrid3DAction
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} waves
- * @param {Number} amplitude
- */
-cc.WavesTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.WavesTiles3D# */{
- _waves:0,
- _amplitude:0,
- _amplitudeRate:0,
-
- /**
- * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
- * creates the action with a number of waves, the waves amplitude, the grid size and the duration.
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} waves
- * @param {Number} amplitude
- */
- ctor:function (duration, gridSize, waves, amplitude) {
- cc.GridAction.prototype.ctor.call(this);
- amplitude !== undefined && this.initWithDuration(duration, gridSize, waves, amplitude);
- },
-
- /**
- * get amplitude of waves
- * @return {Number}
- */
- getAmplitude:function () {
- return this._amplitude;
- },
-
- /**
- * set amplitude of waves
- * @param {Number} amplitude
- */
- setAmplitude:function (amplitude) {
- this._amplitude = amplitude;
- },
-
- /**
- * get amplitude rate of waves
- * @return {Number}
- */
- getAmplitudeRate:function () {
- return this._amplitudeRate;
- },
-
- /**
- * set amplitude rate of waves
- * @param {Number} amplitudeRate
- */
- setAmplitudeRate:function (amplitudeRate) {
- this._amplitudeRate = amplitudeRate;
- },
-
- /**
- * initializes the action with a number of waves, the waves amplitude, the grid size and the duration
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} waves
- * @param {Number} amplitude
- * @return {Boolean}
- */
- initWithDuration:function (duration, gridSize, waves, amplitude) {
- if (cc.TiledGrid3DAction.prototype.initWithDuration.call(this, duration, gridSize)) {
- this._waves = waves;
- this._amplitude = amplitude;
- this._amplitudeRate = 1.0;
- return true;
- }
- return false;
- },
-
- /**
- * Called once per frame. Time is the number of seconds of a frame interval.
- * @param {Number} dt
- */
- update:function (dt) {
- var locGridSize = this._gridSize, locWaves = this._waves, locAmplitude = this._amplitude, locAmplitudeRate = this._amplitudeRate;
- var locPos = cc.p(0, 0), coords;
- for (var i = 0; i < locGridSize.width; i++) {
- for (var j = 0; j < locGridSize.height; j++) {
- locPos.x = i;
- locPos.y = j;
- coords = this.originalTile(locPos);
- coords.bl.z = (Math.sin(dt * Math.PI * locWaves * 2 +
- (coords.bl.y + coords.bl.x) * 0.01) * locAmplitude * locAmplitudeRate);
- coords.br.z = coords.bl.z;
- coords.tl.z = coords.bl.z;
- coords.tr.z = coords.bl.z;
- this.setTile(locPos, coords);
- }
- }
- }
-});
-
-/**
- * creates the action with a number of waves, the waves amplitude, the grid size and the duration.
- * Reference the test cases (Effects Test)
- * @function
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} waves
- * @param {Number} amplitude
- * @return {cc.WavesTiles3D}
- */
-cc.wavesTiles3D = function (duration, gridSize, waves, amplitude) {
- return new cc.WavesTiles3D(duration, gridSize, waves, amplitude);
-};
-/**
- * Please use cc.wavesTiles3D instead
- * creates the action with a number of waves, the waves amplitude, the grid size and the duration.
- * Reference the test cases (Effects Test)
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} waves
- * @param {Number} amplitude
- * @return {cc.WavesTiles3D}
- * @static
- * @deprecated since v3.0
Please use cc.wavesTiles3D instead.
- */
-cc.WavesTiles3D.create = cc.wavesTiles3D;
-
-/**
- * cc.JumpTiles3D action. A sin function is executed to move the tiles across the Z axis.
- * Reference the test cases (Effects Test)
- * @class
- * @extends cc.TiledGrid3DAction
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} numberOfJumps
- * @param {Number} amplitude
- */
-cc.JumpTiles3D = cc.TiledGrid3DAction.extend(/** @lends cc.JumpTiles3D# */{
- _jumps:0,
- _amplitude:0,
- _amplitudeRate:0,
-
- /**
- * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
- * creates the action with the number of jumps, the sin amplitude, the grid size and the duration.
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} numberOfJumps
- * @param {Number} amplitude
- */
- ctor:function (duration, gridSize, numberOfJumps, amplitude) {
- cc.GridAction.prototype.ctor.call(this);
- amplitude !== undefined && this.initWithDuration(duration, gridSize, numberOfJumps, amplitude);
- },
-
- /**
- * get amplitude of the sin
- * @return {Number}
- */
- getAmplitude:function () {
- return this._amplitude;
- },
-
- /**
- * set amplitude of the sin
- * @param {Number} amplitude
- */
- setAmplitude:function (amplitude) {
- this._amplitude = amplitude;
- },
-
- /**
- * get amplitude rate
- * @return {Number}
- */
- getAmplitudeRate:function () {
- return this._amplitudeRate;
- },
-
- /**
- * set amplitude rate
- * @param amplitudeRate
- */
- setAmplitudeRate:function (amplitudeRate) {
- this._amplitudeRate = amplitudeRate;
- },
-
- /**
- * initializes the action with the number of jumps, the sin amplitude, the grid size and the duration
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} numberOfJumps
- * @param {Number} amplitude
- */
- initWithDuration:function (duration, gridSize, numberOfJumps, amplitude) {
- if (cc.TiledGrid3DAction.prototype.initWithDuration.call(this, duration, gridSize)) {
- this._jumps = numberOfJumps;
- this._amplitude = amplitude;
- this._amplitudeRate = 1.0;
- return true;
- }
- return false;
- },
-
- /**
- * Called once per frame. Time is the number of seconds of a frame interval.
- * @param {Number} dt
- */
- update:function (dt) {
- var sinz = (Math.sin(Math.PI * dt * this._jumps * 2) * this._amplitude * this._amplitudeRate );
- var sinz2 = (Math.sin(Math.PI * (dt * this._jumps * 2 + 1)) * this._amplitude * this._amplitudeRate );
-
- var locGridSize = this._gridSize;
- var locGrid = this.target.grid;
- var coords, locPos = cc.p(0, 0);
- for (var i = 0; i < locGridSize.width; i++) {
- for (var j = 0; j < locGridSize.height; j++) {
- locPos.x = i;
- locPos.y = j;
- //hack for html5
- //var coords = this.originalTile(cc.p(i, j));
- coords = locGrid.originalTile(locPos);
-
- if (((i + j) % 2) === 0) {
- coords.bl.z += sinz;
- coords.br.z += sinz;
- coords.tl.z += sinz;
- coords.tr.z += sinz;
- } else {
- coords.bl.z += sinz2;
- coords.br.z += sinz2;
- coords.tl.z += sinz2;
- coords.tr.z += sinz2;
- }
- //hack for html5
- //this.setTile(cc.p(i, j), coords);
- locGrid.setTile(locPos, coords);
- }
- }
- }
-});
-
-/**
- * creates the action with the number of jumps, the sin amplitude, the grid size and the duration.
- * Reference the test cases (Effects Test)
- * @function
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} numberOfJumps
- * @param {Number} amplitude
- * @return {cc.JumpTiles3D}
- */
-cc.jumpTiles3D = function (duration, gridSize, numberOfJumps, amplitude) {
- return new cc.JumpTiles3D(duration, gridSize, numberOfJumps, amplitude);
-};
-
-/**
- * Please use cc.jumpTiles3D instead
- * creates the action with the number of jumps, the sin amplitude, the grid size and the duration.
- * Reference the test cases (Effects Test)
- * @param {Number} duration
- * @param {Size} gridSize
- * @param {Number} numberOfJumps
- * @param {Number} amplitude
- * @return {cc.JumpTiles3D}
- * @static
- * @deprecated since v3.0
Please use cc.jumpTiles3D instead.
- */
-cc.JumpTiles3D.create = cc.jumpTiles3D;
-
-/**
- * cc.SplitRows action.
- * Reference the test cases (Effects Test)
- * @class
- * @extends cc.TiledGrid3DAction
- * @param {Number} duration
- * @param {Number} rows
- */
-cc.SplitRows = cc.TiledGrid3DAction.extend(/** @lends cc.SplitRows# */{
- _rows:0,
- _winSize:null,
-
- /**
- * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
- * creates the action with the number of rows to split and the duration.
- * @param {Number} duration
- * @param {Number} rows
- */
- ctor:function (duration, rows) {
- cc.GridAction.prototype.ctor.call(this);
- rows !== undefined && this.initWithDuration(duration, rows);
- },
-
- /**
- * initializes the action with the number of rows to split and the duration
- * @param {Number} duration
- * @param {Number} rows
- * @return {Boolean}
- */
- initWithDuration:function (duration, rows) {
- this._rows = rows;
- return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, duration, cc.size(1, rows));
- },
-
- /**
- * Called once per frame. Time is the number of seconds of a frame interval.
- * @param {Number} dt
- */
- update:function (dt) {
- var locGridSize = this._gridSize, locWinSizeWidth = this._winSize.width;
- var coords, direction, locPos = cc.p(0, 0);
- for (var j = 0; j < locGridSize.height; ++j) {
- locPos.y = j;
- coords = this.originalTile(locPos);
- direction = 1;
-
- if ((j % 2 ) === 0)
- direction = -1;
-
- coords.bl.x += direction * locWinSizeWidth * dt;
- coords.br.x += direction * locWinSizeWidth * dt;
- coords.tl.x += direction * locWinSizeWidth * dt;
- coords.tr.x += direction * locWinSizeWidth * dt;
-
- this.setTile(locPos, coords);
- }
- },
-
- /**
- * called before the action start. It will also set the target.
- * @param {_ccsg.Node} target
- */
- startWithTarget:function (target) {
- cc.TiledGrid3DAction.prototype.startWithTarget.call(this, target);
- this._winSize = cc.director.getWinSizeInPixels();
- }
-});
-
-/**
- * creates the action with the number of rows to split and the duration.
- * Reference the test cases (Effects Test)
- * @function
- * @param {Number} duration
- * @param {Number} rows
- * @return {cc.SplitRows}
- */
-cc.splitRows = function (duration, rows) {
- return new cc.SplitRows(duration, rows);
-};
-
-/**
- * Please use cc.splitRows instead
- * creates the action with the number of rows to split and the duration.
- * Reference the test cases (Effects Test)
- * @param {Number} duration
- * @param {Number} rows
- * @return {cc.SplitRows}
- * @static
- * @deprecated since v3.0
Please use cc.splitRows instead.
- */
-cc.SplitRows.create = cc.splitRows;
-
-/**
- * cc.SplitCols action.
- * Reference the test cases (Effects Test)
- * @class
- * @extends cc.TiledGrid3DAction
- * @param {Number} duration
- * @param {Number} cols
- */
-cc.SplitCols = cc.TiledGrid3DAction.extend(/** @lends cc.SplitCols# */{
- _cols:0,
- _winSize:null,
-
- /**
- * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
- * Creates the action with the number of columns to split and the duration.
- * @param {Number} duration
- * @param {Number} cols
- */
- ctor:function (duration, cols) {
- cc.GridAction.prototype.ctor.call(this);
- cols !== undefined && this.initWithDuration(duration, cols);
- },
- /**
- * initializes the action with the number of columns to split and the duration
- * @param {Number} duration
- * @param {Number} cols
- * @return {Boolean}
- */
- initWithDuration:function (duration, cols) {
- this._cols = cols;
- return cc.TiledGrid3DAction.prototype.initWithDuration.call(this, duration, cc.size(cols, 1));
- },
-
- /**
- * Called once per frame. Time is the number of seconds of a frame interval.
- * @param {Number} dt
- */
- update:function (dt) {
- var locGridSizeWidth = this._gridSize.width, locWinSizeHeight = this._winSize.height;
- var coords, direction, locPos = cc.p(0, 0);
- for (var i = 0; i < locGridSizeWidth; ++i) {
- locPos.x = i;
- coords = this.originalTile(locPos);
- direction = 1;
-
- if ((i % 2 ) === 0)
- direction = -1;
-
- coords.bl.y += direction * locWinSizeHeight * dt;
- coords.br.y += direction * locWinSizeHeight * dt;
- coords.tl.y += direction * locWinSizeHeight * dt;
- coords.tr.y += direction * locWinSizeHeight * dt;
-
- this.setTile(locPos, coords);
- }
- cc.renderer.childrenOrderDirty = true;
- },
-
- /**
- * called before the action start. It will also set the target.
- * @param {_ccsg.Node} target
- */
- startWithTarget:function (target) {
- cc.TiledGrid3DAction.prototype.startWithTarget.call(this, target);
- this._winSize = cc.director.getWinSizeInPixels();
- }
-});
-
-/**
- * creates the action with the number of columns to split and the duration.
- * Reference the test cases (Effects Test)
- * @function
- * @param {Number} duration
- * @param {Number} cols
- * @return {cc.SplitCols}
- */
-cc.splitCols = function (duration, cols) {
- return new cc.SplitCols(duration, cols);
-};
-
-/**
- * Please use cc.splitCols instead.
- * creates the action with the number of columns to split and the duration.
- * Reference the test cases (Effects Test)
- * @param {Number} duration
- * @param {Number} cols
- * @return {cc.SplitCols}
- * @static
- * @deprecated since v3.0
Please use cc.splitCols instead.
- */
-cc.SplitCols.create = cc.splitCols;
diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js
index ad2d2cc4c9..a9c2b15785 100644
--- a/cocos2d/core/CCDirector.js
+++ b/cocos2d/core/CCDirector.js
@@ -1195,7 +1195,11 @@ cc.Director = Class.extend(/** @lends cc.Director# */{
*/
setActionManager: function (actionManager) {
if (this._actionManager !== actionManager) {
+ if (this._actionManager) {
+ this._scheduler.unscheduleUpdate(this._actionManager);
+ }
this._actionManager = actionManager;
+ this._scheduler.scheduleUpdate(this._actionManager, cc.Scheduler.PRIORITY_SYSTEM, false);
}
},
diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js
index 15add16539..31179bc79e 100644
--- a/cocos2d/core/CCNode.js
+++ b/cocos2d/core/CCNode.js
@@ -865,7 +865,7 @@ var Node = cc.Class({
sgNode.onEnter = function () {
_ccsg.Node.prototype.onEnter.call(this);
if (this._entity && !this._entity._active) {
- cc.director.getActionManager().pauseTarget(this);
+ cc.director._actionManager && cc.director._actionManager.pauseTarget(this);
cc.eventManager.pauseTarget(this);
}
};
@@ -963,7 +963,10 @@ var Node = cc.Class({
_onPreDestroy () {
var destroyByParent = this._onPreDestroyBase();
- cc.director.getActionManager().removeAllActionsFromTarget(this);
+ // Actions
+ if (cc.director._actionManager) {
+ cc.director._actionManager.removeAllActionsFromTarget(this);
+ }
// Remove Node.currentHovered
if (_currentHovered === this) {
@@ -1008,9 +1011,10 @@ var Node = cc.Class({
},
_onPostActivated (active) {
+ var actionManager = cc.director._actionManager;
if (active) {
// activate
- cc.director.getActionManager().resumeTarget(this);
+ actionManager && actionManager.resumeTarget(this);
cc.eventManager.resumeTarget(this);
if (this._touchListener) {
var mask = this._touchListener.mask = _searchMaskInParent(this);
@@ -1024,7 +1028,7 @@ var Node = cc.Class({
}
else {
// deactivate
- cc.director.getActionManager().pauseTarget(this);
+ actionManager && actionManager.pauseTarget(this);
cc.eventManager.pauseTarget(this);
}
},
@@ -1056,7 +1060,9 @@ var Node = cc.Class({
if (!this._activeInHierarchy) {
// deactivate ActionManager and EventManager by default
- cc.director.getActionManager().pauseTarget(this);
+ if (cc.director._actionManager) {
+ cc.director._actionManager.pauseTarget(this);
+ }
cc.eventManager.pauseTarget(this);
}
@@ -1327,17 +1333,11 @@ var Node = cc.Class({
* node.runAction(action.repeatForever()); // right
*/
runAction (action) {
- if (!this.active)
+ if (!this.active || !cc.director._actionManager)
return;
cc.assertID(action, 1618);
- if (!cc.macro.ENABLE_GC_FOR_NATIVE_OBJECTS) {
- this._retainAction(action);
- }
- if (CC_JSB) {
- this._sgNode._owner = this;
- }
- cc.director.getActionManager().addAction(action, this, false);
+ cc.director._actionManager.addAction(action, this, false);
return action;
},
@@ -1349,7 +1349,9 @@ var Node = cc.Class({
* node.stopAllActions();
*/
stopAllActions () {
- cc.director.getActionManager().removeAllActionsFromTarget(this);
+ if (cc.director._actionManager) {
+ cc.director._actionManager.removeAllActionsFromTarget(this);
+ }
},
/**
@@ -1362,7 +1364,9 @@ var Node = cc.Class({
* node.stopAction(action);
*/
stopAction (action) {
- cc.director.getActionManager().removeAction(action);
+ if (cc.director._actionManager) {
+ cc.director._actionManager.removeAction(action);
+ }
},
/**
@@ -1378,7 +1382,9 @@ var Node = cc.Class({
cc.logID(1612);
return;
}
- cc.director.getActionManager().removeActionByTag(tag, this);
+ if (cc.director._actionManager) {
+ cc.director._actionManager.removeActionByTag(tag, this);
+ }
},
/**
@@ -1396,7 +1402,7 @@ var Node = cc.Class({
cc.logID(1613);
return null;
}
- return cc.director.getActionManager().getActionByTag(tag, this);
+ return cc.director._actionManager ? cc.director._actionManager.getActionByTag(tag, this) : null;
},
/**
@@ -1418,24 +1424,8 @@ var Node = cc.Class({
* cc.log("Running Action Count: " + count);
*/
getNumberOfRunningActions () {
- return cc.director.getActionManager().getNumberOfRunningActionsInTarget(this);
- },
-
- _retainAction (action) {
- if (CC_JSB && action instanceof cc.Action && this._retainedActions.indexOf(action) === -1) {
- this._retainedActions.push(action);
- action.retain();
- }
- },
-
- _releaseAllActions () {
- if (CC_JSB) {
- for (var i = 0; i < this._retainedActions.length; ++i) {
- this._retainedActions[i].release();
- }
- this._retainedActions.length = 0;
- }
- },
+ return cc.director._actionManager ? cc.director._actionManager.getNumberOfRunningActionsInTarget(this) : 0;
+ }
setTag (value) {
this._tag = value;
@@ -2232,7 +2222,7 @@ var Node = cc.Class({
*/
cleanup () {
// actions
- cc.director.getActionManager().removeAllActionsFromTarget(this);
+ cc.director._actionManager && cc.director._actionManager.removeAllActionsFromTarget(this);
// event
cc.eventManager.removeListeners(this);
@@ -2326,12 +2316,13 @@ var Node = cc.Class({
sgNode.setColor(this._color);
// update ActionManager and EventManager because sgNode maybe changed
+ var actionManager = cc.director._actionManager;
if (this._activeInHierarchy) {
- cc.director.getActionManager().resumeTarget(this);
+ actionManager && actionManager.resumeTarget(this);
cc.eventManager.resumeTarget(this);
}
else {
- cc.director.getActionManager().pauseTarget(this);
+ actionManager && actionManager.pauseTarget(this);
cc.eventManager.pauseTarget(this);
}
},
@@ -2369,12 +2360,13 @@ var Node = cc.Class({
this._onRestoreBase();
+ var actionManager = cc.director._actionManager;
if (this._activeInHierarchy) {
- cc.director.getActionManager().resumeTarget(this);
+ actionManager && actionManager.resumeTarget(this);
cc.eventManager.resumeTarget(this);
}
else {
- cc.director.getActionManager().pauseTarget(this);
+ actionManager && actionManager.pauseTarget(this);
cc.eventManager.pauseTarget(this);
}
},
diff --git a/cocos2d/core/base-nodes/CCSGNode.js b/cocos2d/core/base-nodes/CCSGNode.js
index 09bcc24dda..04e52e7f5c 100644
--- a/cocos2d/core/base-nodes/CCSGNode.js
+++ b/cocos2d/core/base-nodes/CCSGNode.js
@@ -1440,7 +1440,7 @@ _ccsg.Node = cc.Class({
runAction: function (action) {
cc.assertID(action, 1618);
- this.actionManager.addAction(action, this, !this._running);
+ this.actionManager && this.actionManager.addAction(action, this, !this._running);
return action;
},
@@ -1458,7 +1458,7 @@ _ccsg.Node = cc.Class({
* @param {cc.Action} action An action object to be removed.
*/
stopAction: function (action) {
- this.actionManager.removeAction(action);
+ this.actionManager && this.actionManager.removeAction(action);
},
/**
@@ -1471,7 +1471,7 @@ _ccsg.Node = cc.Class({
cc.logID(1612);
return;
}
- this.actionManager.removeActionByTag(tag, this);
+ this.actionManager && this.actionManager.removeActionByTag(tag, this);
},
/**
@@ -1486,7 +1486,7 @@ _ccsg.Node = cc.Class({
cc.logID(1613);
return null;
}
- return this.actionManager.getActionByTag(tag, this);
+ return this.actionManager ? this.actionManager.getActionByTag(tag, this) : null;
},
/** Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).
@@ -1497,7 +1497,7 @@ _ccsg.Node = cc.Class({
* @return {Number} The number of actions that are running plus the ones that are schedule to run
*/
getNumberOfRunningActions: function () {
- return this.actionManager.getNumberOfRunningActionsInTarget(this);
+ return this.actionManager ? this.actionManager.getNumberOfRunningActionsInTarget(this) : 0;
},
// _ccsg.Node - Callbacks
diff --git a/cocos2d/core/components/CCRendererInSG.js b/cocos2d/core/components/CCRendererInSG.js
index f723e18b72..7adaed58e1 100644
--- a/cocos2d/core/components/CCRendererInSG.js
+++ b/cocos2d/core/components/CCRendererInSG.js
@@ -71,7 +71,7 @@ var RendererInSG = cc.Class({
},
onEnable: function () {
- if (CC_JSB && cc.director.getActionManager().getNumberOfRunningActionsInTarget(this.node) > 0) {
+ if (CC_JSB && cc.director._actionManager && cc.director._actionManager.getNumberOfRunningActionsInTarget(this.node) > 0) {
cc.errorID(1629, this.node.name);
cc.errorID(1630);
cc.errorID(1631);
diff --git a/extends.js b/extends.js
index 451072940b..93e4fceeee 100644
--- a/extends.js
+++ b/extends.js
@@ -53,13 +53,13 @@ if (!cc.runtime) {
}
if (!(CC_EDITOR && Editor.isMainProcess)) {
- if (!CC_JSB) {
- require('./cocos2d/actions');
- require('./external/chipmunk/chipmunk.js');
- }
-
+ require('./cocos2d/actions');
require('./extensions/ccpool/CCNodePool.js');
require('./extensions/ccpool/CCPool.js');
+
+ if (!CC_JSB) {
+ require('./external/chipmunk/chipmunk.js');
+ }
}
if (!CC_EDITOR || !Editor.isMainProcess) {
diff --git a/jsb/index.js b/jsb/index.js
index 952d0b659d..dff4307fe5 100644
--- a/jsb/index.js
+++ b/jsb/index.js
@@ -77,7 +77,6 @@ require('./jsb-particle');
require('./jsb-spine');
require('./jsb-enums');
require('./jsb-event');
-require('./jsb-action');
require('./jsb-etc');
require('./jsb-audio');
require('./jsb-tiledmap');
diff --git a/jsb/jsb-action.js b/jsb/jsb-action.js
deleted file mode 100644
index 9415274cb4..0000000000
--- a/jsb/jsb-action.js
+++ /dev/null
@@ -1,450 +0,0 @@
-/****************************************************************************
- Copyright (c) 2013-2016 Chukong Technologies Inc.
-
- http://www.cocos.com
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated engine source code (the "Software"), a limited,
- worldwide, royalty-free, non-assignable, revocable and non-exclusive license
- to use Cocos Creator solely to develop games on your target platforms. You shall
- not use Cocos Creator software for developing other software or tools that's
- used for developing games. You are not granted to publish, distribute,
- sublicense, and/or sell copies of Cocos Creator.
-
- The software or tools in this License Agreement are licensed, not sold.
- Chukong Aipu reserves all rights not expressly granted to you.
-
- 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.
- ****************************************************************************/
-
-var ENABLE_GC_FOR_NATIVE_OBJECTS = cc.macro.ENABLE_GC_FOR_NATIVE_OBJECTS;
-
-// Independent Action from retain/release
-var actionArr = [
- 'ActionEase',
- 'EaseExponentialIn',
- 'EaseExponentialOut',
- 'EaseExponentialInOut',
- 'EaseSineIn',
- 'EaseSineOut',
- 'EaseSineInOut',
- 'EaseBounce',
- 'EaseBounceIn',
- 'EaseBounceOut',
- 'EaseBounceInOut',
- 'EaseBackIn',
- 'EaseBackOut',
- 'EaseBackInOut',
- 'EaseRateAction',
- 'EaseIn',
- 'EaseElastic',
- 'EaseElasticIn',
- 'EaseElasticOut',
- 'EaseElasticInOut',
- 'RemoveSelf',
- 'FlipX',
- 'FlipY',
- 'Place',
- 'CallFunc',
- 'DelayTime',
- 'Sequence',
- 'Spawn',
- 'Speed',
- 'Repeat',
- 'RepeatForever',
- 'Follow',
- 'TargetedAction',
- 'Animate',
- 'OrbitCamera',
- 'GridAction',
- 'ProgressTo',
- 'ProgressFromTo',
- 'ActionInterval',
- 'RotateTo',
- 'RotateBy',
- 'MoveBy',
- 'MoveTo',
- 'SkewTo',
- 'SkewBy',
- 'JumpTo',
- 'JumpBy',
- 'ScaleTo',
- 'ScaleBy',
- 'Blink',
- 'FadeTo',
- 'FadeIn',
- 'FadeOut',
- 'TintTo',
- 'TintBy',
-];
-
-function setCtorReplacer (proto) {
- var ctor = proto._ctor;
- proto._ctor = function (...args) {
- ctor.apply(this, args);
- this.retain();
- this._retained = true;
- };
-}
-function setAliasReplacer (name, type) {
- var aliasName = name[0].toLowerCase() + name.substr(1);
- cc[aliasName] = function (...args) {
- var action = type.create.apply(this, args);
- action.retain();
- action._retained = true;
- return action;
- };
-}
-
-if (!ENABLE_GC_FOR_NATIVE_OBJECTS) {
- for (var i = 0; i < actionArr.length; ++i) {
- var name = actionArr[i];
- var type = cc[name];
- if (!type)
- continue;
- var proto = type.prototype;
- setCtorReplacer(proto);
- if (name.indexOf('Ease') === -1) {
- setAliasReplacer(name, type);
- }
- }
-}
-
-cc.targetedAction = function (target, action) {
- return new cc.TargetedAction(target, action);
-};
-
-cc.TargetedAction.prototype._ctor = function(target, action) {
- var node = target._sgNode || target;
- node._owner = target;
- action && this.initWithTarget(node, action);
-};
-
-cc.follow = function (followedNode, rect) {
- return new cc.Follow(followedNode._sgNode, rect);
-};
-
-cc.Follow.prototype.update = function(dt) {
- var target = this.getTarget();
- if (target._owner) {
- target._owner.setPosition(target.getPosition());
- }
-};
-
-var _FlipX = cc.FlipX;
-cc.FlipX = _FlipX.extend({
- _flippedX:false,
-
- ctor:function(flip){
- _FlipX.prototype.ctor.call(this);
- this.initWithFlipX(flip);
- },
-
- initWithFlipX:function (flip) {
- this._flippedX = !!flip;
- return true;
- },
-
- update:function (dt) {
- var target = this.getTarget();
- target.scaleX = Math.abs(target.scaleX) * (this._flippedX ? -1 : 1);
- },
-
- reverse:function () {
- return new cc.FlipX(!this._flippedX);
- },
-
- clone:function(){
- return new cc.FlipX(this._flippedX);
- }
-});
-
-cc.flipX = function (flip) {
- return new cc.FlipX(flip);
-};
-
-var _FlipY = cc.FlipY;
-cc.FlipY = _FlipY.extend({
- _flippedY:false,
-
- ctor: function(flip){
- _FlipY.prototype.ctor.call(this);
- this.initWithFlipY(flip);
- },
-
- initWithFlipY:function (flip) {
- this._flippedY = !!flip;
- return true;
- },
-
- update:function (dt) {
- var target = this.getTarget();
- target.scaleY = Math.abs(target.scaleY) * (this._flippedY ? -1 : 1);
- },
-
- reverse:function () {
- return new cc.FlipY(!this._flippedY);
- },
-
- clone:function(){
- return new cc.FlipY(this._flippedY);
- }
-});
-
-cc.flipY = function (flip) {
- return new cc.FlipY(flip);
-};
-
-function setRendererVisibility (sgNode, toggleVisible, visible) {
- if (!sgNode) { return; }
- var _renderComps = sgNode._owner.getComponentsInChildren(cc._SGComponent);
- for (var i = 0; i < _renderComps.length; ++i) {
- var render = _renderComps[i];
- render.enabled = toggleVisible ? !render.enabled : visible;
- }
-}
-
-cc.Show.prototype.update = function (dt) {
- setRendererVisibility(this.getTarget(), false, true);
-};
-
-cc.Hide.prototype.update = function (dt) {
- setRendererVisibility(this.getTarget(), false, false);
-};
-
-cc.ToggleVisibility.prototype.update = function (dt) {
- setRendererVisibility(this.getTarget(), true);
-};
-
-// Special call func
-cc.callFunc = function (selector, selectorTarget, data) {
- var callback = function (sender, data) {
- if (sender) {
- sender = sender._owner || sender;
- }
- selector.call(this, sender, data);
- };
- var action = cc.CallFunc.create(callback, selectorTarget, data);
- if (!ENABLE_GC_FOR_NATIVE_OBJECTS) {
- action.retain();
- action._retained = true;
- }
- return action;
-};
-
-cc.CallFunc.prototype._ctor = function (selector, selectorTarget, data) {
- if(selector !== undefined){
- var callback = function (sender, data) {
- if (sender) {
- sender = sender._owner || sender;
- }
- selector.call(this, sender, data);
- };
- if(selectorTarget === undefined)
- this.initWithFunction(callback);
- else this.initWithFunction(callback, selectorTarget, data);
- }
- if (!ENABLE_GC_FOR_NATIVE_OBJECTS) {
- this.retain();
- this._retained = true;
- }
-};
-
-function setChainFuncReplacer (proto, name) {
- var oldFunc = proto[name];
- proto[name] = function (...args) {
- if (this._retained) {
- this.release();
- this._retained = false;
- }
- var newAction = oldFunc.apply(this, args);
- newAction.retain();
- newAction._retained = true;
- return newAction;
- };
-}
-
-if (!ENABLE_GC_FOR_NATIVE_OBJECTS) {
- setChainFuncReplacer(cc.ActionInterval.prototype, 'repeat');
- setChainFuncReplacer(cc.ActionInterval.prototype, 'repeatForever');
- setChainFuncReplacer(cc.ActionInterval.prototype, 'easing');
-
- var jsbRunAction = cc.Node.prototype.runAction;
- cc.Node.prototype.runAction = function (action) {
- jsbRunAction.call(this, action);
- if (action._retained) {
- action.release();
- action._retained = false;
- }
- return action;
- };
-}
-
-function getSGTarget (target) {
- if (target instanceof cc.Component) {
- target = target.node._sgNode;
- }
- else if (target instanceof cc.Node) {
- target = target._sgNode;
- }
- else if (!(target instanceof _ccsg.Node)) {
- target = null;
- }
- return target;
-}
-var jsbAddAction = cc.ActionManager.prototype.addAction;
-cc.ActionManager.prototype.addAction = function (action, target, paused) {
- target = getSGTarget(target);
- if (target) {
- jsbAddAction.call(this, action, target, paused);
- if (!ENABLE_GC_FOR_NATIVE_OBJECTS && action._retained) {
- action.release();
- action._retained = false;
- }
- }
-};
-
-function actionMgrFuncReplacer (funcName, targetPos) {
- var proto = cc.ActionManager.prototype;
- var oldFunc = proto[funcName];
- proto[funcName] = function (...args) {
- for (var i = 0; i < args.length; i++) {
- if (i === targetPos)
- args[i] = getSGTarget(args[i]);
- }
- if (!args[targetPos]) {
- return;
- }
- else {
- return oldFunc.apply(this, args);
- }
- };
-}
-
-var targetRelatedFuncs = [
- ['removeAllActionsFromTarget', 0],
- ['removeActionByTag', 1],
- ['getActionByTag', 1],
- ['getNumberOfRunningActionsInTarget', 0],
- ['pauseTarget', 0],
- ['resumeTarget', 0]
-];
-
-for (var i = 0; i < targetRelatedFuncs.length; ++i) {
- actionMgrFuncReplacer.apply(null, targetRelatedFuncs[i]);
-}
-
-cc.ActionManager.prototype.resumeTargets = function (targetsToResume) {
- if (!targetsToResume)
- return;
-
- for (var i = 0; i< targetsToResume.length; i++) {
- if (targetsToResume[i])
- this.resumeTarget(targetsToResume[i]);
- }
-};
-
-cc.ActionManager.prototype.pauseTargets = function (targetsToPause) {
- if (!targetsToPause)
- return;
-
- for (var i = 0; i< targetsToPause.length; i++) {
- if (targetsToPause[i])
- this.pauseTarget(targetsToPause[i]);
- }
-};
-
-
-
-function syncPositionUpdate (dt) {
- this._jsbUpdate(dt);
- var target = this.getTarget();
- if (target._owner) {
- target._owner.x = target.getPositionX();
- target._owner.y = target.getPositionY();
- }
-}
-
-function syncRotationUpdate (dt) {
- this._jsbUpdate(dt);
- var target = this.getTarget();
- if (target._owner) {
- target._owner.rotationX = target.getRotationX();
- target._owner.rotationY = target.getRotationY();
- }
-}
-
-function syncScaleUpdate (dt) {
- this._jsbUpdate(dt);
- var target = this.getTarget();
- if (target._owner) {
- target._owner.scaleX = target.getScaleX();
- target._owner.scaleY = target.getScaleY();
- }
-}
-
-function syncRemoveSelfUpdate (dt) {
- this._jsbUpdate(dt);
- var target = this.getTarget();
- if (target._owner) {
- target._owner.removeFromParent();
- }
-}
-
-function syncSkewUpdate (dt) {
- this._jsbUpdate(dt);
- var target = this.getTarget();
- if (target._owner) {
- target._owner.skewX = target.getSkewX();
- target._owner.skewY = target.getSkewY();
- }
-}
-
-function syncOpacityUpdate (dt) {
- this._jsbUpdate(dt);
- var target = this.getTarget();
- if (target._owner) {
- target._owner.opacity = target.getOpacity();
- }
-}
-
-function syncColorUpdate (dt) {
- this._jsbUpdate(dt);
- var target = this.getTarget();
- if (target._owner) {
- target._owner.color = target.getColor();
- }
-}
-
-// Sub classes must be registered before their super class.
-// Otherwise, JSB there will be internal Error: "too much recursion".
-var actionUpdate = {
- 'MoveBy': syncPositionUpdate,
- 'JumpBy': syncPositionUpdate,
- 'Place': syncPositionUpdate,
- 'CardinalSplineTo': syncPositionUpdate,
- 'RotateTo': syncRotationUpdate,
- 'RotateBy': syncRotationUpdate,
- 'ScaleTo': syncScaleUpdate,
- 'RemoveSelf': syncRemoveSelfUpdate,
- 'SkewTo': syncSkewUpdate,
- 'Blink': syncOpacityUpdate,
- 'FadeIn': syncOpacityUpdate,
- 'FadeOut': syncOpacityUpdate,
- 'FadeTo': syncOpacityUpdate,
- 'TintTo': syncColorUpdate,
- 'TintBy': syncColorUpdate,
- 'BezierBy': syncPositionUpdate
-};
-
-for (var key in actionUpdate) {
- var action = cc[key];
- action.prototype._jsbUpdate = action.prototype.update;
- action.prototype.update = actionUpdate[key];
-}
\ No newline at end of file
diff --git a/jsb/jsb-director.js b/jsb/jsb-director.js
index 8225493feb..4f915f5efb 100644
--- a/jsb/jsb-director.js
+++ b/jsb/jsb-director.js
@@ -42,10 +42,19 @@ cc.js.mixin(cc.director, {
this._compScheduler = new ComponentScheduler();
this._nodeActivator = new NodeActivator();
+ var scheduler = this.getScheduler();
+ // ActionManager
+ if (cc.ActionManager) {
+ this._actionManager = new cc.ActionManager();
+ scheduler.scheduleUpdate(this._actionManager, cc.Scheduler.PRIORITY_SYSTEM, false);
+ } else {
+ this._actionManager = null;
+ }
+
// Animation manager
if (cc.AnimationManager) {
this._animationManager = new cc.AnimationManager();
- this.getScheduler().scheduleUpdate(this._animationManager, cc.Scheduler.PRIORITY_SYSTEM, false);
+ scheduler.scheduleUpdate(this._animationManager, cc.Scheduler.PRIORITY_SYSTEM, false);
}
else {
this._animationManager = null;
@@ -54,7 +63,7 @@ cc.js.mixin(cc.director, {
// collider manager
if (cc.CollisionManager) {
this._collisionManager = new cc.CollisionManager();
- this.getScheduler().scheduleUpdate(this._collisionManager, cc.Scheduler.PRIORITY_SYSTEM, false);
+ scheduler.scheduleUpdate(this._collisionManager, cc.Scheduler.PRIORITY_SYSTEM, false);
}
else {
this._collisionManager = null;
@@ -89,9 +98,8 @@ cc.js.mixin(cc.director, {
cc.eventManager.setEnabled(true);
// Action manager
- var actionManager = this.getActionManager();
- if (actionManager) {
- this.getScheduler().scheduleUpdate(actionManager, cc.Scheduler.PRIORITY_SYSTEM, false);
+ if (this._actionManager) {
+ this.getScheduler().scheduleUpdate(this._actionManager, cc.Scheduler.PRIORITY_SYSTEM, false);
}
// Animation manager
@@ -112,6 +120,20 @@ cc.js.mixin(cc.director, {
this.startAnimation();
},
+ getActionManager: function () {
+ return this._actionManager;
+ },
+
+ setActionManager: function (actionManager) {
+ if (this._actionManager !== actionManager) {
+ if (this._actionManager) {
+ this._scheduler.unscheduleUpdate(this._actionManager);
+ }
+ this._actionManager = actionManager;
+ this._scheduler.scheduleUpdate(this._actionManager, cc.Scheduler.PRIORITY_SYSTEM, false);
+ }
+ },
+
/**
* Returns the cc.AnimationManager associated with this director.
* @method getAnimationManager
@@ -436,6 +458,8 @@ cc.js.mixin(cc.director, {
},
});
+cc.defineGetterSetter(cc.director, "actionManager", cc.director.getActionManager, cc.director.setActionManager);
+
cc.EventTarget.call(cc.director);
cc.js.addon(cc.director, cc.EventTarget.prototype);
diff --git a/jsb/jsb-enums.js b/jsb/jsb-enums.js
index dd3a062637..158cca13c2 100644
--- a/jsb/jsb-enums.js
+++ b/jsb/jsb-enums.js
@@ -25,14 +25,6 @@
'use strict';
-cc.ProgressTimer.Type = cc.Enum({
- /**
- * Radial Counter-Clockwise
- */
- RADIAL: 0,
- BAR: 1
-});
-
//FIXME: should delete this line after implementing the VideoPlayer on Mac and Windows
if (cc.sys.os === cc.sys.OS_OSX || cc.sys.os === cc.sys.OS_WINDOWS) {
cc.VideoPlayer = {};
diff --git a/jsb/jsb-etc.js b/jsb/jsb-etc.js
index 542b729704..28ea17aa25 100644
--- a/jsb/jsb-etc.js
+++ b/jsb/jsb-etc.js
@@ -207,9 +207,6 @@ window._ccsg = {
window.__errorHandler = function (filename, lineno, message) {
};
-// rename cc.Class to cc._Class
-cc._Class = cc.Class;
-
// fix cc.formatStr (#2630)
cc.formatStr = cc.js.formatStr;
diff --git a/predefine.js b/predefine.js
index a0753fb4f9..0c1412bf8f 100644
--- a/predefine.js
+++ b/predefine.js
@@ -73,7 +73,11 @@ require('./cocos2d/core/platform/CCMacro');
require('./cocos2d/core/load-pipeline');
require('./cocos2d/core/textures');
-if (!CC_JSB) {
+if (CC_JSB) {
+ // rename cc.Class to cc._Class
+ cc._Class = cc.Class;
+}
+else {
require('./cocos2d/kazmath');
require('./cocos2d/core/CCDirector');
require('./cocos2d/core/CCDirectorWebGL');
@@ -83,7 +87,6 @@ if (!CC_JSB) {
require('./cocos2d/core/platform/CCSAXParser');
require('./cocos2d/core/platform/CCView');
require('./cocos2d/core/platform/CCScreen');
- require('./cocos2d/core/CCActionManager');
require('./cocos2d/core/CCScheduler');
require('./cocos2d/core/event-manager');
require('./cocos2d/core/renderer');