forked from noxious/client
[new feature] camera movement
This commit is contained in:
21
src/App.vue
21
src/App.vue
@ -1,11 +1,18 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import Phaser from 'phaser';
|
import 'phaser';
|
||||||
import { Game, Scene, Rectangle } from 'phavuer'
|
import { Game, Scene, Rectangle } from 'phavuer'
|
||||||
import Example from './scenes/mapScene'
|
import Example from './scenes/mapScene'
|
||||||
|
|
||||||
const gameConfig = {
|
const gameConfig = {
|
||||||
width: '100%',
|
scale: {
|
||||||
height: '99%',
|
mode: Phaser.Scale.FIT,
|
||||||
|
autoCenter: Phaser.Scale.CENTER_BOTH,
|
||||||
|
width: 1280,
|
||||||
|
height: 720,
|
||||||
|
},
|
||||||
|
render: {
|
||||||
|
roundPixels: true,
|
||||||
|
},
|
||||||
pixelArt: true,
|
pixelArt: true,
|
||||||
type: Phaser.AUTO,
|
type: Phaser.AUTO,
|
||||||
scene: Example
|
scene: Example
|
||||||
@ -13,9 +20,7 @@ const gameConfig = {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Game :config="gameConfig" class="game">
|
<div class="game-container">
|
||||||
<Scene name="MainScene">
|
<Game :config="gameConfig" class="game" />
|
||||||
<Rectangle :x="100" :y="100" :width="100" :height="100" :fillColor="0xAAAAAA" />
|
</div>
|
||||||
</Scene>
|
|
||||||
</Game>
|
|
||||||
</template>
|
</template>
|
0
src/engine/camera.js
Normal file
0
src/engine/camera.js
Normal file
0
src/engine/init.js
Normal file
0
src/engine/init.js
Normal file
@ -45,6 +45,15 @@ class Example extends Phaser.Scene
|
|||||||
});
|
});
|
||||||
y++;
|
y++;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var cam = this.cameras.main;
|
||||||
|
|
||||||
|
this.input.on("pointermove", function (p) {
|
||||||
|
if (!p.isDown) return;
|
||||||
|
|
||||||
|
cam.scrollX -= (p.x - p.prevPosition.x) / cam.zoom;
|
||||||
|
cam.scrollY -= (p.y - p.prevPosition.y) / cam.zoom;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user