老师。我的图片为什么没加载。背景也是。

来源:2-3 phaser环境搭建

留白的云

2021-03-18 17:31

var game =new Phaser.Game(375,667,Phaser.AUTO);

var helloState={
preload:function (){
    game.stage.backgroundColor="#a8d4bf"
    game.load.image("logo","/source/logo.png")
    },

create:function (){
    var text=game.add.text(game.world.centerX,25,"hello world11",{fill:'#fff'})
    text.anchor.set(0.5);
    var logo=game.add.image(game.world.centerX,game.world.centerY,"logo")
    logo.anchor.set(0.5);
    }
}

game.state.add("helloState",helloState);
game.state.start("helloState");


http://img4.mukewang.com/60531dd60001df3004820763.jpg

写回答 关注

2回答

  • 天天敲代码
    2021-03-31 18:03:20

    已经看见你评论了很多,特意在这回一条,加油,在慕课网一起进步。还有学完了,来个中肯评价?

  • 学音乐的程序员
    2021-03-18 23:47:08

    图片在哪里加载完成的?

    你的背景图片没加载,你就一个hellostate。

    留白的云

    谢谢 找到问题了 把生命周期方法名写错了

    2021-03-24 15:16:49

    共 1 条回复 >

Phaser从0到1实战微信2D小游戏【钢琴方块】

2D游戏框架Phaser从基础到实战,带你开发一个关于钢琴的微信小游戏

6055 学习 · 24 问题

查看课程

相似问题