phaserjs / phaser-ce

Phaser CE is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.

Home Page:http://phaser.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

In several cases,Group.callAll() will not work or make errors

aleafworld opened this issue · comments

Not sure if this is a bug:
eg. sprites in group have a method as "sprite.subobj.func()"
group.callAll("subobj.func") ---- not work
group.callAll("func","subobj") ---- not work
group.callAll("subobj.func","subobj") ---- it work

the API ---- "callAll(method, context, args)"
don't you think the second paramater is unnecessary?

commented

Assuming you want to do

sprite.subobj.func.call(sprite.subobj);

then only these arguments are correct:

group.callAll("subobj.func", "subobj");

The default context is always sprite, no matter what you pass in method. It's true that if you pass a deep property in method you will probably have to pass a matching context as well, I guess the docs could note that.

Thanks.
I think context can be removed, because it can get by

context = methodLength > 1 ? this.callbackFromArray(child, method, methodLength - 1) : child;

then the code will be simpler.

commented

Closing since it works as described.