ImageStore已从React-native

问题描述

我正在尝试使用expo-phaser来构建带有react-native的2D游戏。我需要在RN中完成此游戏,然后将其集成到现有的应用中。在安装unimodules以便能够在裸反应本机项目上使用expo模块之后,现在出现此错误

enter image description here

主要组件的代码是:

const Assets = {
  'map.json': require('assets/map.json'),'dirt.png': require('assets/dirt.png'),};

export default class App extends React.Component {
  state = {loading: false};
  async componentwillMount() {
    const downloads = [];
    for (let key of Object.keys(Assets)) {
      const asset = Asset.fromModule(Assets[key]);
      downloads.push(asset.downloadAsync());
    }
    await Promise.all(downloads);
    this.setState({loading: false});
  }
  render() {
    if (this.state.loading) {
      return (
        <View>
          <Text>loading</Text>
        </View>
      );
    }

    return (
      <GLView
        style={{flex: 1}}
        onContextCreate={(context) => startGame({context})}
      />
    );
  }
}

function startGame({context}) {
  const game = ExpoPhaser.game({context});
  game.state.add('Playable',{
    preload: function () {
      const tileMap = Asset.fromModule(Assets['map.json']).localUri;
      const dirt = Asset.fromModule(Assets['dirt.png']).localUri;
     
      game.load.tilemap(
        'tilemap',tileMap,null,ExpoPhaser.Phaser.Tilemap.TILED_JSON,);
      game.load.image('dirt',dirt);

    },create: function () {
      game.stage.backgroundColor = '#4488AA';

      game.physics.startSystem(ExpoPhaser.Phaser.Physics.ARCADE);

     
    },update: function () {},});

  game.state.start('Playable');
}

谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)