我正在嘗試將以下 Phaser2 示例 ( https://phaser.io/examples/v2/tilemaps/fill-tiles ) 移植到 Phaser3 中。我遇到兩個(gè)問題:我無法旋轉(zhuǎn)車輛,因?yàn)樽?右鍵不起作用。我無法讓 tilemap 正確顯示,它似乎被切斷了。 import Phaser from "phaser"; const config = { type: Phaser.AUTO, parent: "phaser-example", width: 800, height: 600, physics: { default: 'arcade' }, scene: { preload: preload, create: create, update: update, render: render } }; const game = new Phaser.Game(config); let cursors; let player; let map; let speed = 0; function preload() { this.load.tilemapTiledJSON('desert', 'desert.json'); this.load.image('tiles', 'https://examples.phaser.io/assets/tilemaps/tiles/tmw_desert_spacing.png') this.load.image('car', 'http://labs.phaser.io/assets/sprites/car90.png') } function create() { map = this.make.tilemap({ key: 'desert' }); const tiles = map.addTilesetImage('Desert', 'tiles'); const layer = map.createDynamicLayer('Ground', tiles, 0, 0); cursors = this.input.keyboard.createCursorKeys(); player = this.physics.add.sprite(450, 80, 'car'); this.cameras.main.startFollow(player, true, 0.05, 0.05); } function update() { // Drive forward if cursor up key is pressed down if (cursors.up.isDown && speed <= 400) { speed += 10; } else { if (speed >= 10) { speed -= 10 } } // Drive backwards if cursor down key is pressed down if (cursors.down.isDown && speed >= -200) { speed -= 5; } else { if (speed <= -5) { speed += 5 } } // Steer the car if (cursors.left.isDown) { player.body.angularVelocity = -5 * (speed / 1000); } else if (cursors.right.isDown) { player.body.angularVelocity = 5 * (speed / 1000); } else { player.body.angularVelocity = 0; } 我怎樣才能解決這個(gè)問題?
無法旋轉(zhuǎn)汽車且瓦片地圖不完全可見
慕的地8271018
2022-12-09 19:20:16