问题描述
我是移相器和游戏开发的新手,正在尝试使用动画构建游戏。 我尝试加载精灵表并制作动画 - 但我不断收到此错误:
phaser.js:73195 Uncaught TypeError: Cannot read property 'frame' of undefined
at Animation.setCurrentFrame (phaser.js:73195)
at Animation.updateFrame (phaser.js:73224)
at Animation.load (phaser.js:54133)
at AnimationManager.load (phaser.js:53129)
at Animation.load (phaser.js:72733)
at Animation.play (phaser.js:72833)
at Scene.update ((index):168)
at Systems.step (phaser.js:27164)
at SceneManager.update (phaser.js:46776)
at Game.step (phaser.js:109330)
该错误似乎与为 spritesheet 加载的帧有关。
这是精灵表的预加载(图片尺寸:宽=80,高=16,共5帧):
this.load.spritesheet("animal","assets/animals.png",{ frameWidth: 16,frameHeight: 16 });
这是函数 create() 中的动画:
this.anims.create({
key: "animate",frames: this.anims.generateFrameNumbers("animal",{starts:0,ends:5}),frameRate: 10,repeat: -1
})
问题似乎与“frames”属性有关,所以我尝试记录:
console.log(this.anims.generateFrameNumbers("animal",ends:5}))
但只有一个空列表。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)