Skip to content

Commit b25579a

Browse files
committed
Interpolation Events
1 parent b895b04 commit b25579a

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/engine/runtime.js

+14
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,20 @@ class Runtime extends EventEmitter {
643643
return 'INTERPOLATION_CHANGED';
644644
}
645645

646+
/**
647+
* Event called before interpolation data is set.
648+
*/
649+
static get BEFORE_INTERPOLATION () {
650+
return 'BEFORE_INTERPOLATION';
651+
}
652+
653+
/**
654+
* Event called after interpolation data is set.
655+
*/
656+
static get AFTER_INTERPOLATION () {
657+
return 'AFTER_INTERPOLATION';
658+
}
659+
646660
/**
647661
* Event name for stage size changing.
648662
* @const {string}

src/engine/tw-interpolate.js

+4
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ const interpolate = (runtime, time) => {
6161
continue;
6262
}
6363

64+
runtime.emit(runtime.constructor.BEFORE_INTERPOLATION, target);
65+
6466
const drawableID = target.drawableID;
6567

6668
// Position interpolation.
@@ -137,6 +139,8 @@ const interpolate = (runtime, time) => {
137139
renderer.updateDrawableDirectionScale(drawableID, direction, scale);
138140
}
139141
}
142+
143+
runtime.emit(runtime.constructor.AFTER_INTERPOLATION, target);
140144
}
141145
};
142146

src/virtual-machine.js

+6
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,12 @@ class VirtualMachine extends EventEmitter {
184184
this.runtime.on(Runtime.INTERPOLATION_CHANGED, framerate => {
185185
this.emit(Runtime.INTERPOLATION_CHANGED, framerate);
186186
});
187+
this.runtime.on(Runtime.BEFORE_INTERPOLATION, target => {
188+
this.emit(Runtime.BEFORE_INTERPOLATION, target);
189+
});
190+
this.runtime.on(Runtime.AFTER_INTERPOLATION, target => {
191+
this.emit(Runtime.AFTER_INTERPOLATION, target);
192+
});
187193
this.runtime.on(Runtime.STAGE_SIZE_CHANGED, (width, height) => {
188194
this.emit(Runtime.STAGE_SIZE_CHANGED, width, height);
189195
});

0 commit comments

Comments
 (0)