这是我的代码的一部分:
create_bounds: function(){
this.bounds = game.add.group();
this.left = new Phaser.Rectangle(0, 0, 20, game.world.height);
this.right = new Phaser.Rectangle(game.world.width, 0, 20, game.world.height);
this.bounds.add(this.left);
//this.bounds.addAt(this.right);
//var right =
//this.bounds.add(left);
},
Run Code Online (Sandbox Code Playgroud)
我想做的就是向组中添加一个简单的矩形,然后该矩形将在更新函数中与玩家交互。我无法这样做,因为当我加载页面时会出现以下内容:
Phaser.js:32473 Uncaught TypeError: child.preUpdate 不是
在 Phaser.Group.preUpdate (phaser.js:
在 Phaser.World.Phaser.Group.preUpdate (phaser.js:
在 Phaser.Stage.preUpdate (phaser.js:30486)
在 Phaser.Game.updateLogic (phaser.js:
在 Phaser.Game.update (phaser.js:
在 Phaser.RequestAnimationFrame.updateRAF (phaser.js:
在 _onLoop (phaser.js:63015)
仅当我尝试将矩形添加到组中时才会发生这种情况,而不是在创建矩形时发生。我该如何解决?
我正在尝试制作一个分数显示,显示在我的游戏上方并显示当前分数。我已经尝试过:
this.scene.call("scene1", "scene2");
这不起作用。
我可以使用以下命令运行一个场景:
this.scene.start("scene1");但this.scene.start("scene1", "scene2");只启动第一个场景。
有没有一种方法可以并行启动 2 个场景?
我对 Phaser 相当陌生,我想知道是否有任何方法可以将 Phaser 游戏转换为 Android 游戏。
我正在将 Phaser 与 NPM 结合使用。
谢谢。
有没有办法在精灵的动画之间切换?例如,我有一个精灵触摸地面,但当它离开地面时,我希望它播放的动画不同于它在地面上播放的动画.但是,我也想让它在第一个动画再次触地时播放.我基本上想要这样的东西:
if (sprite.body.touching.down === false) {
sprite.animations.toggleAnimation("different_animation");
} else {
sprite.animations.play("original_animation");
}
Run Code Online (Sandbox Code Playgroud)
Phaser有一个简单的方法吗?
如何在 Phaser 中为精灵装备衣服?假设我使用以下内容:


我能想到的唯一方法是制作每个精灵都打开的图像。一定有不同的方法,比如叠加或者其他什么?
我遇到了问题,尝试在鼠标单击图像时显示鼠标位置x / y,im使用了相位器提供的单击和图像示例之一。
这是代码
var game = new Phaser.Game(800, 500, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
var text;
var counter = 0;
function preload () {
// You can fill the preloader with as many assets as your game requires
// Here we are loading an image. The first parameter is the unique
// string by which we'll identify the image later in our code.
// The second parameter is the URL of the image (relative)
game.load.image('Happy-face', 'happy.png'); …Run Code Online (Sandbox Code Playgroud) 我正在寻找一种简单快捷的方法来清除整个 Phaser 屏幕,例如在 HTML5 画布中如何通过将画布的宽度重置为自身来擦除所有内容。我无法通过搜索找到任何这样的方法 - 只有 graphics.clear(),但这不会影响文本对象等其他内容。有没有这样的清屏方法?
谢谢。
我使用移相器编写了一个桌面游戏,在完成状态后我遵循了关于无内存和对象破坏的所有指导但我无法理解为什么游戏在整个游戏过程中每次都会给出混蛋2-3秒(特别是瓷砖精灵),我想知道其他原因可能是什么?
在 Phaser 3 中添加瓷砖贴图时,瓷砖之间会出现明显的渗色(或间隙)。这有时被描述为瓷砖的“闪烁”或“闪烁”。
这在平移时通常更为突出。
const map = this.make.tilemap({ key: 'some-map' })
const tiles = map.addTilesetImage('some-tileset', 'some-key')
const baseLayer = map.createStaticLayer('base', tiles, x, y)
Run Code Online (Sandbox Code Playgroud)
我如何阻止这种情况发生?
phaser-framework ×10
javascript ×7
animation ×1
apk ×1
frameworks ×1
html ×1
npm ×1
screen ×1
stage ×1