Skip to content

Fix advanced release mode and acceleration event issue #3525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CCBoot.js
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ cc.loader = (function () {
delete _queue[url];
}

if (ENABLE_IMAEG_POOL && cc._renderType === cc.game.RENDER_TYPE_WEBGL) {
if (window.ENABLE_IMAEG_POOL && cc._renderType === cc.game.RENDER_TYPE_WEBGL) {
imagePool.put(img);
}
};
Expand Down
2 changes: 2 additions & 0 deletions cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@
set: function (value) { this.setShaderProgram(value); },
get: function () { return this.getShaderProgram(); }
});
/** @expose */
proto._shaderProgram;
})();
26 changes: 13 additions & 13 deletions cocos2d/core/platform/CCClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,19 @@ cc.inject = function (srcPrototype, destPrototype) {
* @namespace
* @name ClassManager
*/
var ClassManager = {
id : (0|(Math.random()*998)),
var ClassManager = function () {
var id = (0|(Math.random()*998));
var instanceId = (0|(Math.random()*998));

instanceId : (0|(Math.random()*998)),

getNewID : function(){
return this.id++;
},
this.getNewID = function () {
return id++;
};

getNewInstanceId : function(){
return this.instanceId++;
}
this.getNewInstanceId = function () {
return instanceId++;
};
};
var classManager = new ClassManager();

/* Managed JavaScript Inheritance
* Based on John Resig's Simple JavaScript Inheritance http://ejohn.org/blog/simple-javascript-inheritance/
Expand Down Expand Up @@ -192,7 +192,7 @@ var ClassManager = {
var Class;
if (cc.game.config && cc.game.config[cc.game.CONFIG_KEY.exposeClassName]) {
var constructor = "(function " + (props._className || "Class") + " (arg0, arg1, arg2, arg3, arg4, arg5) {\n";
constructor += " this.__instanceId = ClassManager.getNewInstanceId();\n";
constructor += " this.__instanceId = classManager.getNewInstanceId();\n";
constructor += " if (this.ctor) {\n";
constructor += " switch (arguments.length) {\n";
constructor += " case 0: this.ctor(); break;\n";
Expand All @@ -208,7 +208,7 @@ var ClassManager = {
}
else {
Class = function (arg0, arg1, arg2, arg3, arg4) {
this.__instanceId = ClassManager.getNewInstanceId();
this.__instanceId = classManager.getNewInstanceId();
if (this.ctor) {
switch (arguments.length) {
case 0: this.ctor(); break;
Expand All @@ -223,7 +223,7 @@ var ClassManager = {
};
}

desc.value = ClassManager.getNewID();
desc.value = classManager.getNewID();
Object.defineProperty(prototype, '__pid', desc);

// Populate our constructed prototype object
Expand Down
13 changes: 11 additions & 2 deletions cocos2d/core/platform/CCInputExtension.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ _p.setAccelerometerEnabled = function(isEnable){
var scheduler = cc.director.getScheduler();
if(_t._accelEnabled){
_t._accelCurTime = 0;
_t._registerAccelerometerEvent();
scheduler.scheduleUpdate(_t);
} else {
_t._accelCurTime = 0;
scheduler.scheduleUpdate(_t);
_t._unregisterAccelerometerEvent();
scheduler.unscheduleUpdate(_t);
}
};

Expand Down Expand Up @@ -85,7 +87,14 @@ _p._registerAccelerometerEvent = function(){
_t._minus = -1;
}

w.addEventListener(_deviceEventType, _t.didAccelerate.bind(_t), false);
_t.didAccelerateCallback = _t.didAccelerate.bind(_t);
w.addEventListener(_deviceEventType, _t.didAccelerateCallback, false);
};

_p._unregisterAccelerometerEvent = function () {
this._acceleration = null;
var _deviceEventType = (this._accelDeviceEvent === window.DeviceMotionEvent) ? "devicemotion" : "deviceorientation";
window.removeEventListener(_deviceEventType, this.didAccelerateCallback, false);
};

_p.didAccelerate = function (eventData) {
Expand Down
2 changes: 1 addition & 1 deletion cocos2d/core/textures/TexturesWebGL.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ cc._tmp.WebGLTexture2D = function () {

self._hasPremultipliedAlpha = premultiplied;
self._hasMipmaps = false;
if (ENABLE_IMAEG_POOL) {
if (window.ENABLE_IMAEG_POOL) {
self._htmlElementObj = null;
}

Expand Down