✨ add ZoomMouseScene with zoom-to-mouse correction
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.
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
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],
|
||||
scene: [ZoomTestScene, ZoomMouseScene],
|
||||
scale: {
|
||||
mode: Phaser.Scale.RESIZE,
|
||||
autoCenter: Phaser.Scale.CENTER_BOTH,
|
||||
|
||||
Reference in New Issue
Block a user