Javascript 移相器如何形成一个无限的地面?
我是Phaser的noob,我在研究Flappy Bird。我试着创造一个无限的天地,我试着用瓷砖定位,但它不起作用Javascript 移相器如何形成一个无限的地面?,javascript,phaser-framework,Javascript,Phaser Framework,我是Phaser的noob,我在研究Flappy Bird。我试着创造一个无限的天地,我试着用瓷砖定位,但它不起作用 var ground; function preload(){ game.load.image('ground', '/assets/groud.png'); } function create(){ ground = game.add.tileSprite(0, 480, 'ground'); } function update(){ ground.tilePosi
var ground;
function preload(){
game.load.image('ground', '/assets/groud.png');
}
function create(){
ground = game.add.tileSprite(0, 480, 'ground');
}
function update(){
ground.tilePosition.x -= 1;
}
但它不起作用。有人能帮我吗?需要参数x,y,宽度,高度,键(和frame
,但这只适用于spritesheets,不适用于使用image
)
所以我认为你忘记了宽度和高度参数,导致Phaser将“地面”视为宽度。这可能会在JavaScript控制台上引发错误消息。在Chrome中按CTRL+Shift+J或在FireFox中按F12,然后检查控制台是否有任何消息
另外,我不知道您使用的分辨率是什么,但参数480
是y位置,这可能会导致瓷砖位于屏幕下方,因此不可见
或许可以试试这个:
function create(){
ground = game.add.tileSprite(0, 100, game.width, 50, 'ground');
}
一般来说,对于计算机相关的东西,仅仅说“它不工作”是不够的。你收到错误信息了吗?它是否显示一个空白屏幕?雪碧不会移动吗?考虑评论或接受未来的答案,也许有人会帮助你。你注意到你在你的形象的道路上有一种类型吗?ground.png而不是ground.png?