Melon.js Space Invaders 项目 - Grunt 配置正在清除资源文件

Melon.js Space Invaders Project - Grunt config is clearing resource file

我试图复制 Melon.js 的 Space Invaders 项目。它使用 Grunt,初始配置是清除包含播放器图像的文件。

resources: {
  dist: {
    options: {
      dest: 'build/js/resources.js',
      varname: 'game.resources',
    },
    files: [{
      src: ['data/bgm/**/*', 'data/sfx/**/*'],
      type: 'audio'
    },{
      src: ['data/img/**/*.png'],
      type: 'image'
    },{
      src: ['data/img/**/*.json'],
      type: 'json'
    },{
      src: ['data/map/**/*.tmx', 'data/map/**/*.json'],
      type: 'tmx'
    },{
      src: ['data/map/**/*.tsx'],
      type: 'tsx'
    }]
  }
},

如何更新配置,使其不清除文件 /build/js/resources.js?

干杯

如果你打算按原样使用gruntfile,你应该让它根据源目录中的资源构建资源文件。换句话说,不要手动编辑 build/ 目录中的文件。

例如,如果要将新的png图像添加到resources.js文件中,只需将图像文件放入data/img/子目录中,构建过程就会正确为您将其添加到 resources.js