Skip to content
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

avoid cc.game.once multiple triggers. #6055

Merged
merged 2 commits into from
Jan 10, 2020
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
4 changes: 2 additions & 2 deletions cocos2d/core/CCGame.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,14 +429,14 @@ var game = {
* @typescript
* on<T extends Function>(type: string, callback: T, target?: any, useCapture?: boolean): T
*/
on (type, callback, target) {
on (type, callback, target, once) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不是once有问题么,怎么改on

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once 是通过 on + 参数实现的

// Make sure EVENT_ENGINE_INITED and EVENT_GAME_INITED callbacks to be invoked
if ((this._prepared && type === this.EVENT_ENGINE_INITED) ||
(!this._paused && type === this.EVENT_GAME_INITED)) {
callback.call(target);
}
else {
this.eventTargetOn(type, callback, target);
this.eventTargetOn(type, callback, target, once);
}
},
/**
Expand Down
2 changes: 1 addition & 1 deletion cocos2d/core/collider/CCCollisionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ let CollisionManager = cc.Class({

for (let i = 0, l = colliders.length; i < l; i++) {
let collider = colliders[i];
if(collider instanceof cc.PhysicsCollider) {
if(cc.PhysicsCollider && collider instanceof cc.PhysicsCollider) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个判断是做什么的?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

模块裁剪吧,如果把物理剔除了,instanceof 就会报错

continue;
}
this.removeCollider(collider);
Expand Down