dacha 0.14.0 → 0.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -82,6 +82,9 @@ export class AudioSystem extends System {
|
|
|
82
82
|
this.scene.removeEventListener(PlayAudio, this.handlePlayAudio);
|
|
83
83
|
this.scene.removeEventListener(StopAudio, this.handleStopAudio);
|
|
84
84
|
this.scene.removeEventListener(SetAudioVolume, this.handleSetAudioVolume);
|
|
85
|
+
window.removeEventListener('click', this.resumeIfSuspended);
|
|
86
|
+
window.removeEventListener('keydown', this.resumeIfSuspended);
|
|
87
|
+
window.removeEventListener('touchstart', this.resumeIfSuspended);
|
|
85
88
|
}
|
|
86
89
|
handleActorAdd = (event) => {
|
|
87
90
|
this.initAudio(event.actor);
|
|
@@ -166,6 +166,13 @@ export class SpriteRenderer extends System {
|
|
|
166
166
|
this.actorsMap[actor.id] = object.id;
|
|
167
167
|
this.renderScene.add(object);
|
|
168
168
|
}
|
|
169
|
+
normalizeOffset(value) {
|
|
170
|
+
const currentCamera = this.cameraService.getCurrentCamera();
|
|
171
|
+
const camera = currentCamera?.getComponent(Camera);
|
|
172
|
+
const zoom = camera?.zoom ?? 1;
|
|
173
|
+
const ratio = 1 / (window.devicePixelRatio * zoom);
|
|
174
|
+
return Math.round(value / ratio) * ratio;
|
|
175
|
+
}
|
|
169
176
|
updateCamera() {
|
|
170
177
|
const currentCamera = this.cameraService.getCurrentCamera();
|
|
171
178
|
const transform = currentCamera?.getComponent(Transform);
|
|
@@ -175,7 +182,7 @@ export class SpriteRenderer extends System {
|
|
|
175
182
|
const zoom = camera?.zoom ?? 1;
|
|
176
183
|
this.currentCamera.zoom = zoom;
|
|
177
184
|
// TODO: Figure out how to set up camera correctly to avoid negative transform by y axis
|
|
178
|
-
this.currentCamera.position.set(offsetX, -offsetY, 1);
|
|
185
|
+
this.currentCamera.position.set(this.normalizeOffset(offsetX), -this.normalizeOffset(offsetY), 1);
|
|
179
186
|
this.currentCamera.updateProjectionMatrix();
|
|
180
187
|
}
|
|
181
188
|
updateActors() {
|
|
@@ -195,7 +202,7 @@ export class SpriteRenderer extends System {
|
|
|
195
202
|
}
|
|
196
203
|
object.scale.set((sprite.flipX ? -1 : 1) * transform.scaleX, (sprite.flipY ? -1 : 1) * transform.scaleY, 1);
|
|
197
204
|
object.rotation.set(0, 0, MathOps.degToRad(transform.rotation + sprite.rotation));
|
|
198
|
-
object.position.set(transform.offsetX, transform.offsetY, 0);
|
|
205
|
+
object.position.set(this.normalizeOffset(transform.offsetX), this.normalizeOffset(transform.offsetY), 0);
|
|
199
206
|
object.renderOrder = index;
|
|
200
207
|
const material = object.material;
|
|
201
208
|
const textureArray = this.getTextureArray(sprite);
|