diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js
index c21d915c48..972a9074f9 100644
--- a/cocos2d/core/CCDirector.js
+++ b/cocos2d/core/CCDirector.js
@@ -229,7 +229,7 @@ cc.Director.prototype = {
* @method convertToGL
* @param {Vec2} uiPoint
* @return {Vec2}
- * @deprecated
+ * @deprecated since v2.0
*/
convertToGL: function (uiPoint) {
var container = cc.game.container;
@@ -239,7 +239,7 @@ cc.Director.prototype = {
var top = box.top + window.pageYOffset - container.clientTop;
var x = view._devicePixelRatio * (uiPoint.x - left);
var y = view._devicePixelRatio * (top + box.height - uiPoint.y);
- return view._isRotated ? {x: view._viewPortRect.width - y, y: x} : {x: x, y: y};
+ return view._isRotated ? {x: view._viewportRect.width - y, y: x} : {x: x, y: y};
},
/**
@@ -251,7 +251,7 @@ cc.Director.prototype = {
* @method convertToUI
* @param {Vec2} glPoint
* @return {Vec2}
- * @deprecated
+ * @deprecated since v2.0
*/
convertToUI: function (glPoint) {
var container = cc.game.container;
@@ -262,7 +262,7 @@ cc.Director.prototype = {
var uiPoint = {x: 0, y: 0};
if (view._isRotated) {
uiPoint.x = left + glPoint.y / view._devicePixelRatio;
- uiPoint.y = top + box.height - (view._viewPortRect.width - glPoint.x) / view._devicePixelRatio;
+ uiPoint.y = top + box.height - (view._viewportRect.width - glPoint.x) / view._devicePixelRatio;
}
else {
uiPoint.x = left + glPoint.x * view._devicePixelRatio;
@@ -302,32 +302,12 @@ cc.Director.prototype = {
* 如果要获取屏幕物理分辨率,需要用 cc.view.getFrameSize())
* @method getWinSizeInPixels
* @return {Size}
- * @deprecated
+ * @deprecated since v2.0
*/
getWinSizeInPixels: function () {
return cc.size(this._winSizeInPoints.width, this._winSizeInPoints.height);
},
- /**
- * !#en Returns the visible size of the running scene.
- * !#zh 获取运行场景的可见大小。
- * @method getVisibleSize
- * @see cc.visibleRect
- * @return {Size}
- * @deprecated
- */
- getVisibleSize: null,
-
- /**
- * !#en Returns the visible origin of the running scene.
- * !#zh 获取视图在游戏内容中的坐标原点。
- * @method getVisibleOrigin
- * @see cc.visibleRect
- * @return {Vec2}
- * @deprecated
- */
- getVisibleOrigin: null,
-
/**
* !#en Pause the director's ticker, only involve the game logic execution.
* It won't pause the rendering process nor the event manager.
@@ -343,55 +323,9 @@ cc.Director.prototype = {
this._paused = true;
},
- /*
- * !#en
- * Suspends the execution of the running scene, pushing it on the stack of suspended scenes.
- * The new scene will be executed.
- * Try to avoid big stacks of pushed scenes to reduce memory allocation.
- * ONLY call it if there is a running scene.
- * !#zh
- * 暂停当前运行的场景,压入到暂停的场景栈中。
- * 新场景将被执行。
- * 尽量避免压入大场景,以减少内存分配。
- * 只能在有运行场景时调用它。
- * @method pushScene
- * @param {Scene} scene
- * @deprecated
- */
- pushScene: function (scene) {
- },
-
- /*
- * Pops out a scene from the queue.
- * This scene will replace the running one.
- * The running scene will be deleted. If there are no more scenes in the stack the execution is terminated.
- * ONLY call it if there is a running scene.
- * @deprecated
- */
- popScene: function () {
- },
-
- /**
- * Pops out all scenes from the queue until the root scene in the queue.
- * This scene will replace the running one.
- * Internally it will call "popToSceneStackLevel(1)".
- * @deprecated
- */
- popToRootScene: function () {},
-
- /**
- * Pops out all scenes from the queue until it reaches "level".
- * If level is 0, it will end the director.
- * If level is 1, it will pop all scenes until it reaches to root scene.
- * If level is <= than the current stack level, it won't do anything.
- * @param {Number} level
- * @deprecated
- */
- popToSceneStackLevel: function (level) {},
-
/**
* Removes cached all cocos2d cached data.
- * @deprecated
+ * @deprecated since v2.0
*/
purgeCachedData: function () {
cc.loader.releaseAll();
@@ -775,9 +709,14 @@ cc.Director.prototype = {
* !#zh 启用/禁用深度测试(在 Canvas 渲染模式下不会生效)。
* @method setDepthTest
* @param {Boolean} on
- * @deprecated
+ * @deprecated since v2.0
*/
- setDepthTest: function () {},
+ setDepthTest: function (value) {
+ if (!cc.Camera.main) {
+ return;
+ }
+ cc.Camera.main.depth = !!value;
+ },
/**
* !#en
@@ -788,46 +727,22 @@ cc.Director.prototype = {
* 支持全透明,但不支持透明度为中间值。要支持全透明需手工开启 cc.macro.ENABLE_TRANSPARENT_CANVAS。
* @method setClearColor
* @param {Color} clearColor
- * @deprecated
+ * @deprecated since v2.0
*/
setClearColor: function (clearColor) {
if (!cc.Camera.main) {
return;
}
-
cc.Camera.main.backgroundColor = clearColor;
},
/**
- * !#en
- * Sets an OpenGL projection.
- * Implementation can be found in CCDirectorCanvas.js/CCDirectorWebGL.js.
- * !#zh 设置 OpenGL 投影。
- * @method setProjection
- * @param {Number} projection
- * @deprecated
- */
- setProjection: function (projection) {},
-
- /**
- * !#en
- * Gets an OpenGL projection.
- * !#zh 获取 OpenGL 投影。
- * @method getProjection
- * @return {Number}
- * @deprecated
- */
- getProjection: function () {},
-
- /**
- * !#en
- * Returns current render Scene, normally you will never need to use this API.
- * In most case, you probably want to use `getScene` instead.
- * !#zh 获取当前运行的渲染场景,一般情况下,你不会需要用到这个接口,请使用 getScene。
+ * !#en Returns current logic Scene.
+ * !#zh 获取当前逻辑场景。
* @method getRunningScene
* @private
* @return {Scene}
- * @deprecated
+ * @deprecated since v2.0
*/
getRunningScene: function () {
return this._scene;
@@ -850,25 +765,22 @@ cc.Director.prototype = {
* !#en Returns the FPS value. Please use {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} to control animation interval.
* !#zh 获取单位帧执行时间。请使用 {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}} 来控制游戏帧率。
* @method getAnimationInterval
- * @deprecated
+ * @deprecated since v2.0
* @return {Number}
*/
getAnimationInterval: function () {
- return cc.game._frameTime;
+ return 1000 / cc.game.getFrameRate();
},
/**
* Sets animation interval, this doesn't control the main loop.
* To control the game's frame rate overall, please use {{#crossLink "Game.setFrameRate"}}cc.game.setFrameRate{{/crossLink}}
* @method setAnimationInterval
- * @deprecated
+ * @deprecated since v2.0
* @param {Number} value - The animation interval desired.
*/
setAnimationInterval: function (value) {
- if (!this.invalid) {
- this.stopAnimation();
- this.startAnimation();
- }
+ cc.game.setFrameRate(Math.round(1000 / value));
},
/**
@@ -1255,7 +1167,7 @@ cc.Director._getInstance = function () {
* @default 0
* @readonly
* @static
- * @deprecated
+ * @deprecated since v2.0
*/
cc.Director.PROJECTION_2D = 0;
@@ -1265,7 +1177,7 @@ cc.Director.PROJECTION_2D = 0;
* @default 1
* @readonly
* @static
- * @deprecated
+ * @deprecated since v2.0
*/
cc.Director.PROJECTION_3D = 1;
@@ -1275,7 +1187,7 @@ cc.Director.PROJECTION_3D = 1;
* @default 3
* @readonly
* @static
- * @deprecated
+ * @deprecated since v2.0
*/
cc.Director.PROJECTION_CUSTOM = 3;
@@ -1285,6 +1197,6 @@ cc.Director.PROJECTION_CUSTOM = 3;
* @default cc.Director.PROJECTION_2D
* @readonly
* @static
- * @deprecated
+ * @deprecated since v2.0
*/
cc.Director.PROJECTION_DEFAULT = cc.Director.PROJECTION_2D;
diff --git a/cocos2d/core/CCGame.js b/cocos2d/core/CCGame.js
index 11366470e0..26fcd55c4b 100644
--- a/cocos2d/core/CCGame.js
+++ b/cocos2d/core/CCGame.js
@@ -255,20 +255,30 @@ var game = {
// @Game play control
/**
- * !#en Set frameRate of game.
+ * !#en Set frame rate of game.
* !#zh 设置游戏帧率。
* @method setFrameRate
* @param {Number} frameRate
*/
setFrameRate: function (frameRate) {
- var self = this, config = self.config, CONFIG_KEY = self.CONFIG_KEY;
+ var config = this.config, CONFIG_KEY = this.CONFIG_KEY;
config[CONFIG_KEY.frameRate] = frameRate;
- if (self._intervalId)
- window.cancelAnimFrame(self._intervalId);
- self._intervalId = 0;
- self._paused = true;
- self._setAnimFrame();
- self._runMainLoop();
+ if (this._intervalId)
+ window.cancelAnimFrame(this._intervalId);
+ this._intervalId = 0;
+ this._paused = true;
+ this._setAnimFrame();
+ this._runMainLoop();
+ },
+
+ /**
+ * !#en Get frame rate set for the game, it doesn't represent the real frame rate.
+ * !#zh 获取设置的游戏帧率(不等同于实际帧率)。
+ * @method getFrameRate
+ * @return {Number} frame rate
+ */
+ getFrameRate: function () {
+ return this.config[this.CONFIG_KEY.frameRate];
},
/**
diff --git a/cocos2d/core/CCScheduler.js b/cocos2d/core/CCScheduler.js
index 14629ee1d0..9db347adc3 100644
--- a/cocos2d/core/CCScheduler.js
+++ b/cocos2d/core/CCScheduler.js
@@ -462,44 +462,6 @@ cc.Scheduler.prototype = {
this._currentTarget = null;
},
- /**
- * !#en
- *
- * The scheduled method will be called every 'interval' seconds.
- * If paused is YES, then it won't be called until it is resumed.
- * If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.
- * If the callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
- * repeat let the action be repeated repeat + 1 times, use cc.macro.REPEAT_FOREVER to let the action run continuously
- * delay is the amount of time the action will wait before it'll start
- *
- * !#zh
- * 指定回调函数,调用对象等信息来添加一个新的定时器。
- * 当时间间隔达到指定值时,设置的回调函数将会被调用。
- * 如果 paused 值为 true,那么直到 resume 被调用才开始计时。
- * 如果 interval 值为 0,那么回调函数每一帧都会被调用,但如果是这样,
- * 建议使用 scheduleUpdateForTarget 代替。
- * 如果回调函数已经被定时器使用,那么只会更新之前定时器的时间间隔参数,不会设置新的定时器。
- * repeat 值可以让定时器触发 repeat + 1 次,使用 cc.macro.REPEAT_FOREVER
- * 可以让定时器一直循环触发。
- * delay 值指定延迟时间,定时器会在延迟指定的时间之后开始计时。
- * @method scheduleCallbackForTarget
- * @deprecated since v3.4 please use .schedule
- * @param {Object} target
- * @param {Function} callback_fn
- * @param {Number} interval
- * @param {Number} [repeat=cc.macro.REPEAT_FOREVER]
- * @param {Number} [delay=0]
- * @param {Boolean} paused
- * @example {@link utils/api/engine/docs/cocos2d/core/CCScheduler/scheduleCallbackForTarget.js}
- * @typescript
- * scheduleCallbackForTarget(target: any, callback: Function, interval: number, repeat: number, delay: number, paused?: boolean): void
- * scheduleCallbackForTarget(target: any, callback: Function, interval: number, paused?: boolean): void
- */
- scheduleCallbackForTarget: function(target, callback_fn, interval, repeat, delay, paused){
- //cc.log("scheduleCallbackForTarget is deprecated. Please use schedule.");
- this.schedule(callback_fn, target, interval, repeat, delay, paused);
- },
-
/**
* !#en The schedule
* !#zh 定时器
@@ -1017,103 +979,6 @@ cc.Scheduler.prototype = {
}
return false;
},
-
- /**
- * !#en
- * Schedules the 'update' callback_fn for a given target with a given priority.
- * The 'update' callback_fn will be called every frame.
- * The lower the priority, the earlier it is called.
- * !#zh
- * 为指定对象设置 update 定时器。
- * update 定时器每一帧都会被调用。
- * 优先级的值越低,越早被调用。
- * @method scheduleUpdateForTarget
- * @deprecated since v3.4 please use .scheduleUpdate
- * @param {Object} target
- * @param {Number} priority
- * @param {Boolean} paused
- * @example {@link utils/api/engine/docs/cocos2d/core/CCScheduler/scheduleUpdateForTarget.js}
- */
- scheduleUpdateForTarget: function(target, priority, paused){
- //cc.log("scheduleUpdateForTarget is deprecated. Please use scheduleUpdate.");
- this.scheduleUpdate(target, priority, paused);
- },
-
- /**
- * !#en
- * Unschedule a callback function for a given target.
- * If you want to unschedule the "update", use unscheduleUpdateForTarget.
- * !#zh
- * 根据指定的回调函数和调用对象对象取消相应的定时器。
- * 如果需要取消 update 定时器,请使用 unscheduleUpdateForTarget()。
- * @method unscheduleCallbackForTarget
- * @deprecated since v3.4 please use .unschedule
- * @param {Object} target
- * @param {Function} callback - callback[Function] or key[String]
- * @example {@link utils/api/engine/docs/cocos2d/core/CCScheduler/unscheduleCallbackForTarget.js}
- */
- unscheduleCallbackForTarget: function (target, callback) {
- //cc.log("unscheduleCallbackForTarget is deprecated. Please use unschedule.");
- this.unschedule(callback, target);
- },
-
- /**
- * !#en Unschedules the update callback function for a given target.
- * !#zh 取消指定对象的所有定时器。
- * @method unscheduleUpdateForTarget
- * @param {Object} target
- * @deprecated since v3.4 please use .unschedule
- * @example {@link utils/api/engine/docs/cocos2d/core/CCScheduler/unscheduleUpdateForTarget.js}
- */
- unscheduleUpdateForTarget: function (target) {
- //cc.log("unscheduleUpdateForTarget is deprecated. Please use unschedule.");
- this.unscheduleUpdate(target);
- },
-
- /**
- * !#en
- * Unschedules all function callbacks for a given target.
- * This also includes the "update" callback function.
- * !#zh 取消指定对象的所有定时器,包括 update 定时器。
- * @method unscheduleAllCallbacksForTarget
- * @deprecated since v3.4 please use unscheduleAllForTarget
- * @param {Object} target
- */
- unscheduleAllCallbacksForTarget: function(target){
- //cc.log("unscheduleAllCallbacksForTarget is deprecated. Please use unscheduleAll.");
- this.unscheduleAllForTarget(target);
- },
-
- /**
- * !#en
- * Unschedules all function callbacks from all targets.
- * You should NEVER call this method, unless you know what you are doing.
- * !#zh
- * 取消所有对象的所有定时器。
- * 不要调用这个方法,除非你知道你正在做什么。
- * @method unscheduleAllCallbacks
- * @deprecated since v3.4 please use .unscheduleAllWithMinPriority
- */
- unscheduleAllCallbacks: function(){
- //cc.log("unscheduleAllCallbacks is deprecated. Please use unscheduleAll.");
- this.unscheduleAllWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM);
- },
-
- /**
- * !#en
- * Unschedules all function callbacks from all targets with a minimum priority.
- * You should only call this with kCCPriorityNonSystemMin or higher.
- * !#zh
- * 取消所有优先级的值大于指定优先级的所有对象的所有定时器。
- * 你应该只暂停优先级的值大于 PRIORITY_NON_SYSTEM_MIN 的定时器。
- * @method unscheduleAllCallbacksWithMinPriority
- * @deprecated since v3.4 please use .unscheduleAllWithMinPriority
- * @param {Number} minPriority
- */
- unscheduleAllCallbacksWithMinPriority: function (minPriority) {
- //cc.log("unscheduleAllCallbacksWithMinPriority is deprecated. Please use unscheduleAllWithMinPriority.");
- this.unscheduleAllWithMinPriority(minPriority);
- }
};
/**
diff --git a/cocos2d/core/assets/CCSpriteFrame.js b/cocos2d/core/assets/CCSpriteFrame.js
index 7543b06d25..de6441f01e 100644
--- a/cocos2d/core/assets/CCSpriteFrame.js
+++ b/cocos2d/core/assets/CCSpriteFrame.js
@@ -178,18 +178,6 @@ var SpriteFrame = cc.Class(/** @lends cc.SpriteFrame# */{
return this._texture && this._texture.loaded;
},
- /**
- * !#en Add a event listener for texture loaded event.
- * !#zh 添加纹理读取事件监听事件
- * @method addLoadedEventListener
- * @param {Function} callback
- * @param {Object} target
- * @deprecated since 3.1, please use EventTarget API instead
- */
- addLoadedEventListener: function (callback, target) {
- this.once("load", callback, target);
- },
-
/**
* !#en Returns whether the sprite frame is rotated in the texture.
* !#zh 获取 SpriteFrame 是否旋转
diff --git a/cocos2d/core/assets/CCTexture2D.js b/cocos2d/core/assets/CCTexture2D.js
index 70401b08eb..fb45d17a63 100644
--- a/cocos2d/core/assets/CCTexture2D.js
+++ b/cocos2d/core/assets/CCTexture2D.js
@@ -549,7 +549,7 @@ var Texture2D = cc.Class({
* Release texture, please use destroy instead.
* !#zh 释放纹理,请使用 destroy 替代。
* @method releaseTexture
- * @deprecated
+ * @deprecated since v2.0
*/
releaseTexture () {
this._image = null;
diff --git a/cocos2d/core/components/editbox/CCEditBoxImpl.js b/cocos2d/core/components/editbox/CCEditBoxImpl.js
index 535b9e59d0..e284de2d69 100644
--- a/cocos2d/core/components/editbox/CCEditBoxImpl.js
+++ b/cocos2d/core/components/editbox/CCEditBoxImpl.js
@@ -370,7 +370,7 @@ _p._beginEditingOnMobile = function () {
} else {
this.__fullscreen = false;
}
- this.__autoResize = cc.view.__resizeWithBrowserSize;
+ this.__autoResize = cc.view._resizeWithBrowserSize;
cc.view.resizeWithBrowserSize(false);
};
diff --git a/cocos2d/core/load-pipeline/pipeline.js b/cocos2d/core/load-pipeline/pipeline.js
index 2b7aa55315..e9ec658f8c 100644
--- a/cocos2d/core/load-pipeline/pipeline.js
+++ b/cocos2d/core/load-pipeline/pipeline.js
@@ -282,7 +282,7 @@ proto.flowIn = function (items) {
}
};
-/**
+/*
* !#en
* Let new items flow into the pipeline and give a callback when the list of items are all completed.
* This is for loading dependencies for an existing item in flow, usually used in a pipe logic.
@@ -348,28 +348,6 @@ proto.copyItemStates = function (srcItem, dstItems) {
}
};
-/**
- * !#en Returns whether the pipeline is flowing (contains item) currently.
- * !#zh 获取 pipeline 当前是否正在处理中。
- * @method isFlowing
- * @return {Boolean}
- * @deprecated since v1.3
- */
-proto.isFlowing = function () {
- return true;
-};
-
-/**
- * !#en Returns all items in pipeline. Returns null, please use API of Loader or LoadingItems.
- * !#zh 获取 pipeline 中的所有 items。返回 null,请使用 Loader / LoadingItems API。
- * @method getItems
- * @return {LoadingItems}
- * @deprecated since v1.3
- */
-proto.getItems = function () {
- return null;
-};
-
/**
* !#en Returns an item in pipeline.
* !#zh 根据 id 获取一个 item
diff --git a/cocos2d/core/platform/CCMacro.js b/cocos2d/core/platform/CCMacro.js
index fb273d3cd7..49be59557d 100644
--- a/cocos2d/core/platform/CCMacro.js
+++ b/cocos2d/core/platform/CCMacro.js
@@ -333,7 +333,7 @@ cc.macro = {
* 如果游戏中的动态物体比较多的话,建议将此选项关闭。
* 如果游戏中的静态物体比较多的话,建议将此选项打开。
* @property {Boolean} ENABLE_CULLING
- * @deprecated
+ * @deprecated since v2.0
* @default false
*/
ENABLE_CULLING: false,
diff --git a/cocos2d/core/platform/CCView.js b/cocos2d/core/platform/CCView.js
index dd97ab1879..8f7cc89857 100644
--- a/cocos2d/core/platform/CCView.js
+++ b/cocos2d/core/platform/CCView.js
@@ -133,24 +133,19 @@ var View = function () {
_t._designResolutionSize = cc.size(w, h);
_t._originalDesignResolutionSize = cc.size(w, h);
// Viewport is the container's rect related to content's coordinates in pixel
- _t._viewPortRect = cc.rect(0, 0, w, h);
+ _t._viewportRect = cc.rect(0, 0, w, h);
// The visible rect in content's coordinate in point
_t._visibleRect = cc.rect(0, 0, w, h);
- _t._contentTranslateLeftTop = {left: 0, top: 0};
_t._autoFullScreen = false;
// The device's pixel ratio (for retina displays)
_t._devicePixelRatio = 1;
- // the view name
- _t._viewName = "Cocos2dHTML5";
// Custom callback for resize event
_t._resizeCallback = null;
_t._orientationChanging = true;
_t._resizing = false;
_t._scaleX = 1;
- _t._originalScaleX = 1;
_t._scaleY = 1;
- _t._originalScaleY = 1;
_t._isRotated = false;
_t._orientation = 3;
@@ -169,11 +164,8 @@ var View = function () {
_t._initialized = false;
- _t._contentTranslateLeftTop = null;
-
- _t._frameZoomFactor = 1.0;
- _t.__resizeWithBrowserSize = false;
- _t._isAdjustViewPort = true;
+ _t._resizeWithBrowserSize = false;
+ _t._isAdjustViewport = true;
_t._targetDensityDPI = cc.macro.DENSITYDPI_HIGH;
_t.enableAntiAlias(true);
@@ -227,7 +219,6 @@ View.prototype = {
},
/**
- *
* !#en
* Sets view's target-densitydpi for android mobile browser. it can be set to:
* 1. cc.macro.DENSITYDPI_DEVICE, value is "device-dpi"
@@ -236,7 +227,6 @@ View.prototype = {
* 4. cc.macro.DENSITYDPI_LOW, value is "low-dpi"
* 5. Custom value, e.g: "480"
* !#zh 设置目标内容的每英寸像素点密度。
- *
*
* @method setTargetDensityDPI
* @param {String} densityDPI
@@ -261,7 +251,7 @@ View.prototype = {
* !#en
* Sets whether resize canvas automatically when browser's size changed.
* Useful only on web.
- * !#zh 设置当发现浏览器(模拟器)的尺寸改变时,是否自动调整 canvas 尺寸大小。
+ * !#zh 设置当发现浏览器的尺寸改变时,是否自动调整 canvas 尺寸大小。
* 仅在 Web 模式下有效。
* @method resizeWithBrowserSize
* @param {Boolean} enabled - Whether enable automatic resize with browser's resize event
@@ -269,8 +259,8 @@ View.prototype = {
resizeWithBrowserSize: function (enabled) {
if (enabled) {
//enable
- if (!this.__resizeWithBrowserSize) {
- this.__resizeWithBrowserSize = true;
+ if (!this._resizeWithBrowserSize) {
+ this._resizeWithBrowserSize = true;
window.addEventListener('resize', this._resizeEvent);
window.addEventListener('orientationchange', this._orientationChange);
}
@@ -403,22 +393,12 @@ View.prototype = {
},
_adjustViewportMeta: function () {
- if (this._isAdjustViewPort && !CC_WECHATGAME && !CC_QQPLAY) {
+ if (this._isAdjustViewport && !CC_WECHATGAME && !CC_QQPLAY) {
this._setViewportMeta(__BrowserGetter.meta, false);
- this._isAdjustViewPort = false;
+ this._isAdjustViewport = false;
}
},
- // Other helper functions
- _resetScale: function () {
- this._scaleX = this._originalScaleX;
- this._scaleY = this._originalScaleY;
- },
-
- // Useless, just make sure the compatibility temporarily, should be removed
- _adjustSizeToBrowser: function () {
- },
-
initialize: function () {
this._initialized = true;
},
@@ -433,11 +413,11 @@ View.prototype = {
* 默认设置为启动,我们强烈建议你不要将它设置为关闭。
* 即使当它启动时,你仍然能够设置你的 viewport meta,它不会被覆盖。
* 仅在 Web 模式下有效
- * @method adjustViewPort
+ * @method adjustViewportMeta
* @param {Boolean} enabled - Enable automatic modification to "viewport" meta
*/
- adjustViewPort: function (enabled) {
- this._isAdjustViewPort = enabled;
+ adjustViewportMeta: function (enabled) {
+ this._isAdjustViewport = enabled;
},
/**
@@ -548,58 +528,7 @@ View.prototype = {
return this._autoFullScreen;
},
- /**
- * !#en
- * Get whether render system is ready(no matter opengl or canvas),
- * this name is for the compatibility with cocos2d-x, subclass must implement this method.
- * !#zh 查看渲染系统是否准备完善(无论是在 OpenGL 还是 Canvas),
- * 这个方法名是为了和 cocos2d-x 保持对接,它的子类必须实现这个方法。
- * @method isViewReady
- * @return {Boolean}
- * @deprecated
- */
- isViewReady: function () {
- return cc.game.canvas && cc.game._renderContext;
- },
-
- /**
- * !#en
- * Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
- * !#zh 给外框设置缩放系数。这个方法是为了调试大分辨率设备(例如:新款 ipad)下的桌面应用。
- * @method setFrameZoomFactor
- * @param {Number} zoomFactor
- */
- setFrameZoomFactor: function (zoomFactor) {
- this._frameZoomFactor = zoomFactor;
- cc.director.setProjection(cc.director.getProjection());
- },
-
- /**
- * !#en
- * Sets the resolution translate on View.
-
- * @method setContentTranslateLeftTop
- * @param {Number} offsetLeft
- * @param {Number} offsetTop
- * @deprecated
- */
- setContentTranslateLeftTop: function (offsetLeft, offsetTop) {
- this._contentTranslateLeftTop = {left: offsetLeft, top: offsetTop};
- },
-
- /**
- * !#en
- * Returns the resolution translate on View
- * !#zh 返回转化分辨率后的视图
- * @method getContentTranslateLeftTop
- * @return {Size|Object}
- */
- getContentTranslateLeftTop: function () {
- return this._contentTranslateLeftTop;
- },
-
- /**
- * !#en
+ /*
* Not support on native.
* On web, it sets the size of the canvas.
* !#zh 这个方法并不支持 native 平台,在 Web 平台下,可以用来设置 canvas 尺寸。
@@ -703,7 +632,7 @@ View.prototype = {
* @return {Vec2}
*/
getVisibleOrigin: function () {
- return cc.p(this._visibleRect.x,this._visibleRect.y);
+ return cc.v2(this._visibleRect.x,this._visibleRect.y);
},
/**
@@ -714,20 +643,10 @@ View.prototype = {
* @return {Vec2}
*/
getVisibleOriginInPixel: function () {
- return cc.p(this._visibleRect.x * this._scaleX,
+ return cc.v2(this._visibleRect.x * this._scaleX,
this._visibleRect.y * this._scaleY);
},
- /**
- * !#en
- * Returns whether developer can set content's scale factor.
- * !#zh 返回开发者是否能够设置 content 的尺寸元素。
- * @method canSetContentScaleFactor
- * @deprecated
- * @return {Boolean}
- */
- canSetContentScaleFactor: function () {},
-
/**
* !#en
* Returns the current resolution policy
@@ -824,7 +743,7 @@ View.prototype = {
}
if(result.viewport){
- var vp = this._viewPortRect,
+ var vp = this._viewportRect,
vb = this._visibleRect,
rv = result.viewport;
@@ -848,8 +767,6 @@ View.prototype = {
cc.winSize.width = director._winSizeInPoints.width;
cc.winSize.height = director._winSizeInPoints.height;
- this._originalScaleX = this._scaleX;
- this._originalScaleY = this._scaleY;
cc.visibleRect && cc.visibleRect.init(this._visibleRect);
renderer.updateCameraViewport();
@@ -905,19 +822,19 @@ View.prototype = {
* !#en
* Sets view port rectangle with points.
* !#zh 用设计分辨率下的点尺寸来设置视窗。
- * @method setViewPortInPoints
- * @deprecated
+ * @method setViewportInPoints
+ * @deprecated since v2.0
* @param {Number} x
* @param {Number} y
* @param {Number} w width
* @param {Number} h height
*/
- setViewPortInPoints: function (x, y, w, h) {
- var locFrameZoomFactor = this._frameZoomFactor, locScaleX = this._scaleX, locScaleY = this._scaleY;
- cc.game._renderContext.viewport((x * locScaleX * locFrameZoomFactor + this._viewPortRect.x * locFrameZoomFactor),
- (y * locScaleY * locFrameZoomFactor + this._viewPortRect.y * locFrameZoomFactor),
- (w * locScaleX * locFrameZoomFactor),
- (h * locScaleY * locFrameZoomFactor));
+ setViewportInPoints: function (x, y, w, h) {
+ var locScaleX = this._scaleX, locScaleY = this._scaleY;
+ cc.game._renderContext.viewport((x * locScaleX + this._viewportRect.x),
+ (y * locScaleY + this._viewportRect.y),
+ (w * locScaleX),
+ (h * locScaleY));
},
/**
@@ -925,18 +842,18 @@ View.prototype = {
* Sets Scissor rectangle with points.
* !#zh 用设计分辨率下的点的尺寸来设置 scissor 剪裁区域。
* @method setScissorInPoints
- * @deprecated
+ * @deprecated since v2.0
* @param {Number} x
* @param {Number} y
* @param {Number} w
* @param {Number} h
*/
setScissorInPoints: function (x, y, w, h) {
- var zoomFactor = this._frameZoomFactor, scaleX = this._scaleX, scaleY = this._scaleY;
- var sx = Math.ceil(x * scaleX * zoomFactor + this._viewPortRect.x * zoomFactor);
- var sy = Math.ceil(y * scaleY * zoomFactor + this._viewPortRect.y * zoomFactor);
- var sw = Math.ceil(w * scaleX * zoomFactor);
- var sh = Math.ceil(h * scaleY * zoomFactor);
+ var scaleX = this._scaleX, scaleY = this._scaleY;
+ var sx = Math.ceil(x * scaleX + this._viewportRect.x);
+ var sy = Math.ceil(y * scaleY + this._viewportRect.y);
+ var sw = Math.ceil(w * scaleX);
+ var sh = Math.ceil(h * scaleY);
if (!_scissorRect) {
var boxArr = gl.getParameter(gl.SCISSOR_BOX);
@@ -957,7 +874,7 @@ View.prototype = {
* Returns whether GL_SCISSOR_TEST is enable
* !#zh 检查 scissor 是否生效。
* @method isScissorEnabled
- * @deprecated
+ * @deprecated since v2.0
* @return {Boolean}
*/
isScissorEnabled: function () {
@@ -969,7 +886,7 @@ View.prototype = {
* Returns the current scissor rectangle
* !#zh 返回当前的 scissor 剪裁区域。
* @method getScissorRect
- * @deprecated
+ * @deprecated since v2.0
* @return {Rect}
*/
getScissorRect: function () {
@@ -980,48 +897,22 @@ View.prototype = {
var scaleXFactor = 1 / this._scaleX;
var scaleYFactor = 1 / this._scaleY;
return cc.rect(
- (_scissorRect.x - this._viewPortRect.x) * scaleXFactor,
- (_scissorRect.y - this._viewPortRect.y) * scaleYFactor,
+ (_scissorRect.x - this._viewportRect.x) * scaleXFactor,
+ (_scissorRect.y - this._viewportRect.y) * scaleYFactor,
_scissorRect.width * scaleXFactor,
_scissorRect.height * scaleYFactor
);
},
- /**
- * !#en
- * Sets the name of the view
- * !#zh 设置视图名称。
- * @method setViewName
- * @deprecated
- * @param {String} viewName
- */
- setViewName: function (viewName) {
- if (viewName != null && viewName.length > 0) {
- this._viewName = viewName;
- }
- },
-
- /**
- * !#en
- * Returns the name of the view
- * !#zh 返回视图名称。
- * @method getViewName
- * @deprecated
- * @return {String}
- */
- getViewName: function () {
- return this._viewName;
- },
-
/**
* !#en
* Returns the view port rectangle.
* !#zh 返回视窗剪裁区域。
- * @method getViewPortRect
+ * @method getViewportRect
* @return {Rect}
*/
- getViewPortRect: function () {
- return this._viewPortRect;
+ getViewportRect: function () {
+ return this._viewportRect;
},
/**
@@ -1070,23 +961,23 @@ View.prototype = {
convertToLocationInView: function (tx, ty, relatedPos) {
var x = this._devicePixelRatio * (tx - relatedPos.left);
var y = this._devicePixelRatio * (relatedPos.top + relatedPos.height - ty);
- return this._isRotated ? {x: this._viewPortRect.width - y, y: x} : {x: x, y: y};
+ return this._isRotated ? {x: this._viewportRect.width - y, y: x} : {x: x, y: y};
},
_convertMouseToLocationInView: function (in_out_point, relatedPos) {
- var viewport = this._viewPortRect, _t = this;
+ var viewport = this._viewportRect, _t = this;
in_out_point.x = ((_t._devicePixelRatio * (in_out_point.x - relatedPos.left)) - viewport.x) / _t._scaleX;
in_out_point.y = (_t._devicePixelRatio * (relatedPos.top + relatedPos.height - in_out_point.y) - viewport.y) / _t._scaleY;
},
_convertPointWithScale: function (point) {
- var viewport = this._viewPortRect;
+ var viewport = this._viewportRect;
point.x = (point.x - viewport.x) / this._scaleX;
point.y = (point.y - viewport.y) / this._scaleY;
},
_convertTouchesWithScale: function (touches) {
- var viewport = this._viewPortRect, scaleX = this._scaleX, scaleY = this._scaleY,
+ var viewport = this._viewportRect, scaleX = this._scaleX, scaleY = this._scaleY,
selTouch, selPoint, selPrePoint;
for (var i = 0; i < touches.length; i++) {
selTouch = touches[i];
diff --git a/cocos2d/core/renderer/index.js b/cocos2d/core/renderer/index.js
index 2733d36930..117ee55a3e 100644
--- a/cocos2d/core/renderer/index.js
+++ b/cocos2d/core/renderer/index.js
@@ -116,7 +116,7 @@ module.exports = {
}
if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS) {
- let vp = cc.view.getViewPortRect();
+ let vp = cc.view.getViewportRect();
this.device.setViewport(vp.x, vp.y, vp.width, vp.height);
this._camera.a = cc.view.getScaleX();
this._camera.d = -cc.view.getScaleY();
diff --git a/cocos2d/core/value-types/vec2.js b/cocos2d/core/value-types/vec2.js
index c04b010cde..02e276f970 100644
--- a/cocos2d/core/value-types/vec2.js
+++ b/cocos2d/core/value-types/vec2.js
@@ -666,7 +666,7 @@ cc.v2 = function v2 (x, y) {
* !#en This function is deprecated since v2.0, please use {{#crossLink "v2"}}cc.v2{{/crossLink}}.
* !#zh 这个函数从 v2.0 开始被废弃,请使用 {{#crossLink "v2"}}cc.v2{{/crossLink}}。
* @method p
- * @deprecated
+ * @deprecated since v2.0
* @param {Number|Object} [x=0] a Number or a size object
* @param {Number} [y=0]
* @return {Vec2}
diff --git a/cocos2d/deprecated.js b/cocos2d/deprecated.js
index 98a4d5cf7e..90229b557d 100644
--- a/cocos2d/deprecated.js
+++ b/cocos2d/deprecated.js
@@ -130,15 +130,16 @@ if (CC_DEV) {
ownerName = ownerName || js.getClassName(ownerCtor);
for (var prop in obj) {
(function(){
- var originFunc = ownerCtor[prop];
+ var propName = prop;
+ var originFunc = ownerCtor[propName];
if (!originFunc) return;
function warn () {
- cc.warn('Sorry, %s.%s is deprecated. Please use %s instead', ownerName, prop, obj[prop]);
+ cc.warn('Sorry, %s.%s is deprecated. Please use %s instead', ownerName, propName, obj[propName]);
return originFunc.apply(this, arguments);
}
- ownerCtor[prop] = warn;
+ ownerCtor[propName] = warn;
})();
}
}
@@ -153,6 +154,9 @@ if (CC_DEV) {
cc.errorID(1400, 'spriteFrame._textureLoaded', 'spriteFrame.textureLoaded()');
return this.textureLoaded();
});
+ markAsRemoved(cc.SpriteFrame, [
+ 'addLoadedEventListener'
+ ]);
// cc.textureCache
js.get(cc, 'textureCache', function () {
@@ -196,6 +200,61 @@ if (CC_DEV) {
EVENT_BEFORE_VISIT: 'EVENT_AFTER_UPDATE',
EVENT_AFTER_VISIT: 'EVENT_BEFORE_DRAW',
}, 'cc.Director');
+ markFunctionWarning(cc.Director.prototype, {
+ convertToGL: 'cc.view.convertToLocationInView',
+ convertToUI: '',
+ getWinSizeInPixels: 'cc.director.getWinSize',
+ getVisibleSize: 'cc.visibleRect',
+ getVisibleOrigin: 'cc.visibleRect',
+ purgeCachedData: 'cc.loader.releaseAll',
+ setDepthTest: 'cc.Camera.main.depth',
+ setClearColor: 'cc.Camera.main.backgroundColor',
+ getRunningScene: 'cc.director.getScene',
+ getAnimationInterval: 'cc.game.getFrameRate',
+ setAnimationInterval: 'cc.game.setFrameRate',
+
+ }, 'cc.Director');
+ markAsRemoved(cc.Director, [
+ 'pushScene',
+ 'popScene',
+ 'popToRootScene',
+ 'popToSceneStackLevel',
+ 'setProjection',
+ 'getProjection',
+ ], 'cc.Director');
+
+ // Scheduler
+ provideClearError(cc.Scheduler, {
+ scheduleCallbackForTarget: 'schedule',
+ scheduleUpdateForTarget: 'scheduleUpdate',
+ unscheduleCallbackForTarget: 'unschedule',
+ unscheduleUpdateForTarget: 'unscheduleUpdate',
+ unscheduleAllCallbacksForTarget: 'unscheduleAllForTarget',
+ unscheduleAllCallbacks: 'unscheduleAll',
+ unscheduleAllCallbacksWithMinPriority: 'unscheduleAllWithMinPriority'
+ }, 'cc.Scheduler');
+
+ // cc.view
+ provideClearError(cc.view, {
+ adjustViewPort: 'adjustViewportMeta',
+ setViewPortInPoints: 'setViewportInPoints',
+ getViewPortRect: 'getViewportRect'
+ }, 'cc.view');
+ markAsRemovedInObject(cc.view, [
+ 'isViewReady',
+ 'setFrameZoomFactor',
+ 'canSetContentScaleFactor',
+ 'setContentTranslateLeftTop',
+ 'getContentTranslateLeftTop',
+ 'setViewName',
+ 'getViewName'
+ ], 'cc.view');
+
+ // Loader
+ markAsRemoved(cc.Pipeline, [
+ 'flowInDeps',
+ 'getItems'
+ ], 'cc.loader');
// cc.PhysicsManager
markAsRemoved(cc.PhysicsManager, [
diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js
index 69e64b2d47..d7dd503718 100644
--- a/cocos2d/particle/CCParticleSystem.js
+++ b/cocos2d/particle/CCParticleSystem.js
@@ -1074,7 +1074,7 @@ var ParticleSystem = cc.Class({
* @method setTextureWithRect
* @param {Texture2D} texture
* @param {Rect} rect
- * @deprecated
+ * @deprecated since v1.9
*/
setTextureWithRect: function (texture, rect) {
if (texture instanceof cc.Texture2D) {