Hi David,
This highlights the fact that I need to add snapshot3(), snapshot4(), ... snapshot6() to sodium-typescript. I've done this and checked in, and given it the version number 1.0.0. I've got someone (Richard) helping me release it, so until he's done that, it's not on npm yet. You'll have to build it locally. I also found an important bug in the TimerSystem, which is also fixed in this version.
Doing things the right way, everything that needs to be kept alive is kept alive. The reason why cInitPosition.listen(() => {}) was needed was to compensate for the fact that this isn't happening.
Here's one right way:
class Tuple3<A,B,C> {
constructor(a : A, b : B, c : C) {
this.a = a;
this.b = b;
this.c = c;
}
a : A;
b : B;
c : C;
}
sMovePosition.snapshot3(cInitPosition, cPosition, (shape, initPos, pos) =>
new Tuple3<PIXI.Point, PIXI.Point, PIXI.Point>(shape, initPos, pos))
.listen(t => {
const shape = t.a, initPos = t.b, pos = t.c;
shape.position.set(pos.x - initPos.x, pos.y - initPos.y);
});
Here's another:
sMovePosition.snapshot3(cInitPosition, cPosition, (shape, initPos, pos) =>
() => { shape.position.set(pos.x - initPos.x, pos.y - initPos.y); })
.listen(f => { f(); });
Steve