mirror of
https://github.com/smallmain/cocos-enhance-kit.git
synced 2025-11-24 04:57:34 +00:00
[engine] [cocos2d-x] [jsb-adapter] 适配引擎 v2.4.10 版本
This commit is contained in:
@@ -845,7 +845,7 @@ cc.Director.prototype = {
|
||||
|
||||
// Update
|
||||
if (!this._paused) {
|
||||
this.emit(cc.Director.EVENT_BEFORE_UPDATE);
|
||||
this.emit(cc.Director.EVENT_BEFORE_UPDATE, deltaTime);
|
||||
|
||||
this._compScheduler.startPhase();
|
||||
this._compScheduler.updatePhase(deltaTime);
|
||||
@@ -856,15 +856,15 @@ cc.Director.prototype = {
|
||||
|
||||
this._compScheduler.lateUpdatePhase(deltaTime);
|
||||
|
||||
this.emit(cc.Director.EVENT_AFTER_UPDATE);
|
||||
this.emit(cc.Director.EVENT_AFTER_UPDATE, deltaTime);
|
||||
}
|
||||
|
||||
// Render
|
||||
this.emit(cc.Director.EVENT_BEFORE_DRAW);
|
||||
this.emit(cc.Director.EVENT_BEFORE_DRAW, deltaTime);
|
||||
renderer.render(this._scene, deltaTime);
|
||||
|
||||
// After draw
|
||||
this.emit(cc.Director.EVENT_AFTER_DRAW);
|
||||
this.emit(cc.Director.EVENT_AFTER_DRAW, deltaTime);
|
||||
|
||||
this._totalFrames++;
|
||||
|
||||
@@ -877,35 +877,36 @@ cc.Director.prototype = {
|
||||
// calculate "global" dt
|
||||
this.calculateDeltaTime(now);
|
||||
|
||||
const deltaTime = this._deltaTime;
|
||||
// Update
|
||||
if (!this._paused) {
|
||||
// before update
|
||||
this.emit(cc.Director.EVENT_BEFORE_UPDATE);
|
||||
this.emit(cc.Director.EVENT_BEFORE_UPDATE, deltaTime);
|
||||
|
||||
// Call start for new added components
|
||||
this._compScheduler.startPhase();
|
||||
|
||||
// Update for components
|
||||
this._compScheduler.updatePhase(this._deltaTime);
|
||||
this._compScheduler.updatePhase(deltaTime);
|
||||
// Engine update with scheduler
|
||||
this._scheduler.update(this._deltaTime);
|
||||
this._scheduler.update(deltaTime);
|
||||
|
||||
// Late update for components
|
||||
this._compScheduler.lateUpdatePhase(this._deltaTime);
|
||||
this._compScheduler.lateUpdatePhase(deltaTime);
|
||||
|
||||
// User can use this event to do things after update
|
||||
this.emit(cc.Director.EVENT_AFTER_UPDATE);
|
||||
this.emit(cc.Director.EVENT_AFTER_UPDATE, deltaTime);
|
||||
|
||||
// Destroy entities that have been removed recently
|
||||
Obj._deferredDestroy();
|
||||
}
|
||||
|
||||
// Render
|
||||
this.emit(cc.Director.EVENT_BEFORE_DRAW);
|
||||
renderer.render(this._scene, this._deltaTime);
|
||||
this.emit(cc.Director.EVENT_BEFORE_DRAW, deltaTime);
|
||||
renderer.render(this._scene, deltaTime);
|
||||
|
||||
// After draw
|
||||
this.emit(cc.Director.EVENT_AFTER_DRAW);
|
||||
this.emit(cc.Director.EVENT_AFTER_DRAW, deltaTime);
|
||||
|
||||
eventManager.frameUpdateListeners();
|
||||
this._totalFrames++;
|
||||
|
||||
@@ -149,6 +149,7 @@ export abstract class CacheManager {
|
||||
* 通过原始 url 移除缓存
|
||||
*
|
||||
* @method removeCache
|
||||
* @param {string} originUrl
|
||||
*/
|
||||
public abstract removeCache (originUrl: string): void;
|
||||
}
|
||||
|
||||
@@ -677,7 +677,7 @@ Object.defineProperties(cc, {
|
||||
if (CC_DEBUG) {
|
||||
if (onceWarns.loader) {
|
||||
onceWarns.loader = false;
|
||||
cc.log('cc.loader is deprecated, use cc.assetManager instead please. See https://docs.cocos.com/creator/manual/zh/release-notes/asset-manager-upgrade-guide.html');
|
||||
cc.log('cc.loader is deprecated, use cc.assetManager instead please. See https://docs.cocos.com/creator/2.4/manual/zh/release-notes/asset-manager-upgrade-guide.html');
|
||||
}
|
||||
}
|
||||
return loader;
|
||||
|
||||
@@ -383,11 +383,11 @@ let SpriteFrame = cc.Class(/** @lends cc.SpriteFrame# */{
|
||||
}
|
||||
|
||||
if (!self._originalSize) {
|
||||
self.setOriginalSize(cc.size(w, h));
|
||||
self._originalSize = cc.size(w, h);
|
||||
}
|
||||
|
||||
if (!self._offset) {
|
||||
self.setOffset(cc.v2(0, 0));
|
||||
self._offset = cc.v2(0, 0);
|
||||
}
|
||||
|
||||
self._calculateUV();
|
||||
|
||||
@@ -674,6 +674,18 @@ let Label = cc.Class({
|
||||
this._super();
|
||||
},
|
||||
|
||||
onRestore: CC_EDITOR && function () {
|
||||
// Because undo/redo will not call onEnable/onDisable,
|
||||
// we need call onEnable/onDisable manually to active/disactive children nodes.
|
||||
if (this.enabledInHierarchy) {
|
||||
this.node._renderComponent = null;
|
||||
this.onEnable();
|
||||
}
|
||||
else {
|
||||
this.onDisable();
|
||||
}
|
||||
},
|
||||
|
||||
_nodeSizeChanged () {
|
||||
// Because the content size is automatically updated when overflow is NONE.
|
||||
// And this will conflict with the alignment of the CCWidget.
|
||||
|
||||
@@ -62,6 +62,7 @@ var MotionStreak = cc.Class({
|
||||
ctor () {
|
||||
this._points = [];
|
||||
this._lastWPos = new cc.Vec2();
|
||||
this._lastWPosUpdated = false;
|
||||
},
|
||||
|
||||
properties: {
|
||||
@@ -313,8 +314,7 @@ var MotionStreak = cc.Class({
|
||||
reset () {
|
||||
this._points.length = 0;
|
||||
this._assembler && this._assembler._renderData.clear();
|
||||
this._lastWPos.x = 0;
|
||||
this._lastWPos.y = 0;
|
||||
this._lastWPosUpdated = false;
|
||||
if (CC_EDITOR) {
|
||||
cc.engine.repaintInEditMode();
|
||||
}
|
||||
|
||||
@@ -68,14 +68,14 @@ function ConvexPartition(vertices) {
|
||||
var list = [];
|
||||
var d, lowerDist, upperDist;
|
||||
var p;
|
||||
var lowerInt = cc.v2();
|
||||
var upperInt = cc.v2(); // intersection points
|
||||
var lowerInt = null;
|
||||
var upperInt = null; // intersection points
|
||||
var lowerIndex = 0, upperIndex = 0;
|
||||
var lowerPoly, upperPoly;
|
||||
|
||||
for (var i = 0; i < vertices.length; ++i) {
|
||||
if (Reflex(i, vertices)) {
|
||||
lowerDist = upperDist = 10e7; // std::numeric_limits<qreal>::max();
|
||||
lowerDist = upperDist = Number.MAX_SAFE_INTEGER || 9999999999999; // std::numeric_limits<qreal>::max();
|
||||
for (var j = 0; j < vertices.length; ++j) {
|
||||
// if line intersects with an edge
|
||||
if (Left(At(i - 1, vertices), At(i, vertices), At(j, vertices)) &&
|
||||
|
||||
@@ -316,12 +316,12 @@ cc.macro = {
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* Whether to clear the original image cache after uploaded a texture to GPU. If cleared, [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) will not be supported.
|
||||
* Whether to clear the original image cache after uploaded a texture to GPU. If cleared, [Dynamic Atlas](https://docs.cocos.com/creator/2.4/manual/en/advanced-topics/dynamic-atlas.html) will not be supported.
|
||||
* Normally you don't need to enable this option on the web platform, because Image object doesn't consume too much memory.
|
||||
* But on WeChat Game platform, the current version cache decoded data in Image object, which has high memory usage.
|
||||
* So we enabled this option by default on WeChat, so that we can release Image cache immediately after uploaded to GPU.
|
||||
* !#zh
|
||||
* 是否在将贴图上传至 GPU 之后删除原始图片缓存,删除之后图片将无法进行 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。
|
||||
* 是否在将贴图上传至 GPU 之后删除原始图片缓存,删除之后图片将无法进行 [动态合图](https://docs.cocos.com/creator/2.4/manual/zh/advanced-topics/dynamic-atlas.html)。
|
||||
* 在 Web 平台,你通常不需要开启这个选项,因为在 Web 平台 Image 对象所占用的内存很小。
|
||||
* 但是在微信小游戏平台的当前版本,Image 对象会缓存解码后的图片数据,它所占用的内存空间很大。
|
||||
* 所以我们在微信平台默认开启了这个选项,这样我们就可以在上传 GL 贴图之后立即释放 Image 对象的内存,避免过高的内存占用。
|
||||
|
||||
@@ -32,8 +32,8 @@ function beforeSceneLoad() {
|
||||
let _enabled = false;
|
||||
|
||||
/**
|
||||
* !#en Manage Dynamic Atlas Manager. Dynamic Atlas Manager is used for merging textures at runtime, see [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) for details.
|
||||
* !#zh 管理动态图集。动态图集用于在运行时对贴图进行合并,详见 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。
|
||||
* !#en Manage Dynamic Atlas Manager. Dynamic Atlas Manager is used for merging textures at runtime, see [Dynamic Atlas](https://docs.cocos.com/creator/2.4/manual/en/advanced-topics/dynamic-atlas.html) for details.
|
||||
* !#zh 管理动态图集。动态图集用于在运行时对贴图进行合并,详见 [动态合图](https://docs.cocos.com/creator/2.4/manual/zh/advanced-topics/dynamic-atlas.html)。
|
||||
* @class DynamicAtlasManager
|
||||
*/
|
||||
let dynamicAtlasManager = {
|
||||
@@ -41,8 +41,8 @@ let dynamicAtlasManager = {
|
||||
Rect: Rect,
|
||||
|
||||
/**
|
||||
* !#en Enable or disable the dynamic atlas, see [Dynamic Atlas](https://docs.cocos.com/creator/manual/en/advanced-topics/dynamic-atlas.html) for details.
|
||||
* !#zh 开启或者关闭动态图集,详见 [动态合图](https://docs.cocos.com/creator/manual/zh/advanced-topics/dynamic-atlas.html)。
|
||||
* !#en Enable or disable the dynamic atlas, see [Dynamic Atlas](https://docs.cocos.com/creator/2.4/manual/en/advanced-topics/dynamic-atlas.html) for details.
|
||||
* !#zh 开启或者关闭动态图集,详见 [动态合图](https://docs.cocos.com/creator/2.4/manual/zh/advanced-topics/dynamic-atlas.html)。
|
||||
* @property enabled
|
||||
* @type {Boolean}
|
||||
*/
|
||||
@@ -192,6 +192,7 @@ let dynamicAtlasManager = {
|
||||
* !#zh 添加碎图进入动态图集。
|
||||
* @method insertSpriteFrame
|
||||
* @param {SpriteFrame} spriteFrame
|
||||
* @return {Object} frame
|
||||
*/
|
||||
insertSpriteFrame(spriteFrame) {
|
||||
if (CC_EDITOR) return null;
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
import MotionStreakAssembler from "./motion-streak";
|
||||
import { vfmtPosUvColorTexId } from '../../webgl/vertex-format';
|
||||
import Mat4 from '../../../value-types/mat4';
|
||||
|
||||
const MotionStreak = require('../../../components/CCMotionStreak');
|
||||
const RenderFlow = require('../../render-flow');
|
||||
|
||||
@@ -47,6 +49,7 @@ Point.prototype.setDir = function (x, y) {
|
||||
|
||||
let _normal = cc.v2();
|
||||
let _vec2 = cc.v2();
|
||||
let _worldMat = new Mat4();
|
||||
|
||||
function normal (out, dir) {
|
||||
//get perpendicular
|
||||
@@ -74,14 +77,14 @@ export default class MultiMotionStreakAssembler extends MotionStreakAssembler {
|
||||
let stroke = comp._stroke / 2;
|
||||
|
||||
let node = comp.node;
|
||||
let matrix = node._worldMatrix.m;
|
||||
let tx = matrix[12], ty = matrix[13];
|
||||
node.getWorldMatrix(_worldMat);
|
||||
let tx = _worldMat.m[12], ty = _worldMat.m[13];
|
||||
|
||||
let points = comp._points;
|
||||
let lastPos = comp._lastWPos;
|
||||
let fadeTime = comp._fadeTime;
|
||||
|
||||
let moved = lastPos.x !== tx || lastPos.y !== ty;
|
||||
let moved = comp._lastWPosUpdated && (lastPos.x !== tx || lastPos.y !== ty);
|
||||
if (moved) {
|
||||
let cur;
|
||||
let newHead = false;
|
||||
@@ -126,7 +129,8 @@ export default class MultiMotionStreakAssembler extends MotionStreakAssembler {
|
||||
|
||||
lastPos.x = tx;
|
||||
lastPos.y = ty;
|
||||
|
||||
comp._lastWPosUpdated = true;
|
||||
|
||||
if (points.length < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import Assembler2D from '../../assembler-2d';
|
||||
import Mat4 from '../../../value-types/mat4';
|
||||
|
||||
const RenderFlow = require('../../render-flow');
|
||||
|
||||
@@ -48,6 +49,7 @@ let _tangent = cc.v2();
|
||||
let _miter = cc.v2();
|
||||
let _normal = cc.v2();
|
||||
let _vec2 = cc.v2();
|
||||
let _worldMat = new Mat4();
|
||||
|
||||
function normal (out, dir) {
|
||||
//get perpendicular
|
||||
@@ -91,14 +93,14 @@ export default class MotionStreakAssembler extends Assembler2D {
|
||||
let stroke = comp._stroke / 2;
|
||||
|
||||
let node = comp.node;
|
||||
let matrix = node._worldMatrix.m;
|
||||
let tx = matrix[12], ty = matrix[13];
|
||||
node.getWorldMatrix(_worldMat);
|
||||
let tx = _worldMat.m[12], ty = _worldMat.m[13];
|
||||
|
||||
let points = comp._points;
|
||||
let lastPos = comp._lastWPos;
|
||||
let fadeTime = comp._fadeTime;
|
||||
|
||||
let moved = lastPos.x !== tx || lastPos.y !== ty;
|
||||
let moved = comp._lastWPosUpdated && (lastPos.x !== tx || lastPos.y !== ty);
|
||||
if (moved) {
|
||||
let cur;
|
||||
let newHead = false;
|
||||
@@ -143,7 +145,8 @@ export default class MotionStreakAssembler extends Assembler2D {
|
||||
|
||||
lastPos.x = tx;
|
||||
lastPos.y = ty;
|
||||
|
||||
comp._lastWPosUpdated = true;
|
||||
|
||||
if (points.length < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user