Added isometric tiles and scene
This commit is contained in:
20
src/App.vue
20
src/App.vue
@ -1,8 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
import Phaser from 'phaser';
|
||||
import { Game, Scene, Rectangle } from 'phavuer'
|
||||
import Example from './scenes/mapScene'
|
||||
|
||||
const gameConfig = {
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
pixelArt: true,
|
||||
type: Phaser.AUTO,
|
||||
scene: Example
|
||||
}
|
||||
|
||||
// isometric
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
<Game :config="gameConfig">
|
||||
<Scene name="MainScene">
|
||||
<Rectangle :x="100" :y="100" :width="100" :height="100" :fillColor="0xAAAAAA" />
|
||||
</Scene>
|
||||
</Game>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
51
src/scenes/mapScene.js
Normal file
51
src/scenes/mapScene.js
Normal file
@ -0,0 +1,51 @@
|
||||
import Phaser from 'phaser';
|
||||
|
||||
class Example extends Phaser.Scene
|
||||
{
|
||||
constructor () {
|
||||
super();
|
||||
}
|
||||
|
||||
preload () {
|
||||
this.load.image('tiles', '/assets/tilesets/iso-64x64-outside.png');
|
||||
}
|
||||
|
||||
create () {
|
||||
const mapData = new Phaser.Tilemaps.MapData({
|
||||
width: 10,
|
||||
height: 10,
|
||||
tileWidth: 64,
|
||||
tileHeight: 32,
|
||||
orientation: Phaser.Tilemaps.Orientation.ISOMETRIC,
|
||||
format: Phaser.Tilemaps.Formats.ARRAY_2D
|
||||
});
|
||||
|
||||
const map = new Phaser.Tilemaps.Tilemap(this, mapData);
|
||||
const tileset = map.addTilesetImage('iso-64x64-outside', 'tiles');
|
||||
const layer = map.createBlankLayer('layer', tileset, 350, 200);
|
||||
|
||||
const data = [
|
||||
[ 10, 11, 12, 13, 14, 15, 16, 10, 11, 12 ],
|
||||
[ 13, 11, 10, 12, 12, 15, 16, 10, 16, 10 ],
|
||||
[ 12, 10, 16, 13, 14, 15, 16, 16, 13, 12 ],
|
||||
[ 10, 11, 12, 13, 14, 15, 16, 10, 11, 12 ],
|
||||
[ 13, 11, 10, 12, 12, 15, 16, 10, 16, 10 ],
|
||||
[ 12, 10, 16, 13, 14, 15, 16, 16, 13, 12 ],
|
||||
[ 10, 11, 12, 13, 14, 15, 16, 10, 11, 12 ],
|
||||
[ 13, 11, 10, 12, 12, 15, 16, 10, 16, 10 ],
|
||||
[ 12, 10, 16, 13, 14, 15, 16, 16, 13, 12 ],
|
||||
[ 10, 11, 12, 13, 14, 15, 16, 10, 11, 12 ]
|
||||
];
|
||||
|
||||
let y = 0;
|
||||
|
||||
data.forEach(row => {
|
||||
row.forEach((tile, x) => {
|
||||
layer.putTileAt(tile, x, y);
|
||||
});
|
||||
y++;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default Example;
|
Reference in New Issue
Block a user