expo / expo-phaser

Use Phaser.js on mobile with Expo GL
MIT License
226 stars 30 forks source link

ExpoPhaser on Android not working #2

Closed NickDelfino closed 6 years ago

NickDelfino commented 6 years ago

Trying to add ExpoPhaser to my Expo Android app and just making a game object causes the app to error. I am using a Galaxy S8.

undefined is not an object (evaluating window.emitter.emit

Not sure what to make of the error. Seems to build okay on the iOS simulator.

Can provide more details if needed. Thanks for library! Really like the idea!

NickDelfino commented 6 years ago

This error changes on second load to:

EXGL: Invalid pixel data argument for gl.textImage2D()!

This is all I have in my App.js.


import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Expo from 'expo';
import ExpoPhaser from 'expo-phaser';

export default class App extends React.Component {
  state = { loading: true };
  async componentWillMount() {
    this.setState({ loading: false });
  }
  render() {
    if (this.state.loading) {
      return <Expo.AppLoading />;
    }

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

function startGame({ context }) {
  const game = ExpoPhaser.game({ context });
}
EvanBacon commented 6 years ago

Right, I've tracked the issue down to a problem with base64 image conversion. lol apparently in Android ImageStore.addImageFromBase64 isn't available. We need an alternative to this in @expo/browser-polyfill to proceed.

Haipt241 commented 6 years ago

Ok, how can we apply fix ?

EvanBacon commented 6 years ago

Native code would need to be added to the android build, there is currently no way to parse base64 on Android

axedre commented 6 years ago

Is there any ETA on this?

EvanBacon commented 6 years ago

@axedre nothing definitive right now. I'm working on ARCore for android atm. This is phaser-ce (~2.7) which is a little outdated now. I think it might make sense to add support for the newer versions of Phaser with Android. We still need the FileSystem updates either way. It also might make sense to support a simpler game engine like melon.js as well. If you have any input on any of this lemme know.

axedre commented 6 years ago

Nothing much really, apart from a quick SO search (which I'm sure you've already attempted) that yields https://stackoverflow.com/questions/42294821/convert-base64-string-to-image-in-android I'm no Java developer though so I wouldn't know where to start... :-/

EvanBacon commented 6 years ago

https://github.com/expo/expo/pull/2328

lobobabysaurus commented 5 years ago

Can a new version be published to npm? I am getting bit by this issue and the last version published was 10 months ago

baochungit commented 5 years ago

How is this going? If it's still not working on Android, please add a note on README so that other people intending to use it for Android app could avoid to take time for this. Thank you!

justinTime225 commented 5 years ago

Not working for me either, I made a new issue https://github.com/expo/expo-phaser/issues/11

mmarko-g commented 5 years ago

Same issue on expo-pixi.