From 6dfaecd86aa8d391a8faec9026892c92b1720f86 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 13 Apr 2018 15:59:37 +0800 Subject: [PATCH] Small improvements --- cocos2d/core/CCDirector.js | 12 ++++++------ cocos2d/core/CCNode.js | 8 +++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js index 7c489a7a2b..ab2deef17f 100644 --- a/cocos2d/core/CCDirector.js +++ b/cocos2d/core/CCDirector.js @@ -121,7 +121,7 @@ cc.Director = function () { // FPS this._totalFrames = 0; - this._lastUpdate = Date.now(); + this._lastUpdate = performance.now(); this._deltaTime = 0.0; // Scheduler for user registration update @@ -135,7 +135,7 @@ cc.Director = function () { var self = this; cc.game.on(cc.game.EVENT_SHOW, function () { - self._lastUpdate = Date.now(); + self._lastUpdate = performance.now(); }); }; @@ -143,7 +143,7 @@ cc.Director.prototype = { constructor: cc.Director, init: function () { this._totalFrames = 0; - this._lastUpdate = Date.now(); + this._lastUpdate = performance.now(); this._paused = false; this._purgeDirectorInNextLoop = false; this._winSizeInPoints = cc.size(0, 0); @@ -212,7 +212,7 @@ cc.Director.prototype = { * calculates delta time since last time it was called */ calculateDeltaTime: function () { - var now = Date.now(); + var now = performance.now(); this._deltaTime = (now - this._lastUpdate) / 1000; if ((cc.game.config[cc.game.CONFIG_KEY.debugMode] > 0) && (this._deltaTime > 1)) @@ -674,7 +674,7 @@ cc.Director.prototype = { return; } - this._lastUpdate = Date.now(); + this._lastUpdate = performance.now(); if (!this._lastUpdate) { cc.logID(1200); } @@ -900,7 +900,7 @@ cc.Director.prototype = { */ startAnimation: function () { this.invalid = false; - this._lastUpdate = Date.now(); + this._lastUpdate = performance.now(); }, /* diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js index 9261460019..76afc5fc72 100644 --- a/cocos2d/core/CCNode.js +++ b/cocos2d/core/CCNode.js @@ -1904,9 +1904,6 @@ var Node = cc.Class({ if (hasRotation || hasSkew) { let a = 1, b = 0, c = 0, d = 1; - // position - t.m12 = this._position.x; - t.m13 = this._position.y; // rotation if (hasRotation) { let rotationRadiansX = this._rotationX * ONE_DEGREE; @@ -1947,9 +1944,10 @@ var Node = cc.Class({ t.m01 = 0; t.m04 = 0; t.m05 = sy; - t.m12 = this._position.x; - t.m13 = this._position.y; } + // position + t.m12 = this._position.x; + t.m13 = this._position.y; this._localMatDirty = false; // Register dirty status of world matrix so that it can be recalculated