Implements scroll correction after cam.setZoom() so the world point under the mouse stays fixed. Formula accounts for Phaser's center-based zoom: scrollX += (mouseX - cw/2) * (1/zBefore - 1/zAfter). Tab switches between the two test scenes in both directions. Also fixes centerWorld formula in ZoomTestScene overlay and logs.
23 lines
523 B
TypeScript
23 lines
523 B
TypeScript
import Phaser from 'phaser'
|
|
import { ZoomTestScene } from './ZoomTestScene'
|
|
import { ZoomMouseScene } from './ZoomMouseScene'
|
|
|
|
const config: Phaser.Types.Core.GameConfig = {
|
|
type: Phaser.AUTO,
|
|
width: window.innerWidth,
|
|
height: window.innerHeight,
|
|
backgroundColor: '#0d1a0d',
|
|
scene: [ZoomTestScene, ZoomMouseScene],
|
|
scale: {
|
|
mode: Phaser.Scale.RESIZE,
|
|
autoCenter: Phaser.Scale.CENTER_BOTH,
|
|
},
|
|
render: {
|
|
pixelArt: false,
|
|
antialias: true,
|
|
roundPixels: true,
|
|
},
|
|
}
|
|
|
|
new Phaser.Game(config)
|