我正在尝试一个游戏,其中两个玩家通过推杆连接。他们建立联系后,游戏将无法开始!它一直在加载....什么问题?我究竟做错了什么?任何帮助都会有帮助
通过按钮连接的游戏的登录代码
-bsf:v, h264_mp4toannexb
游戏代码..开始,但是没有问题正在加载!它适用于单人游戏。
login = () => {
let username = this.state.username;
if (username) {
this.setState({
is_loading: true
});
this.pusher = new Pusher("78a138a20754a86fee85", {
authEndpoint: "http://94758d28.ngrok.io/pusher/auth",
cluster: "mt1",
encrypted: true,
auth: {
params: { username: username }
}
});
this.my_channel = this.pusher.subscribe(`private-user-${username}`);
this.my_channel.bind("pusher:subscription_error", status => {
Alert.alert(
"Error",
"Subscription error occurred. Please restart the app"
);
});
this.my_channel.bind("pusher:subscription_succeeded", data => {
console.log("subscription ok: ", data);
this.my_channel.bind("opponent-found", data => {
console.log("opponent found: ", data);
let opponent =
username == data.player_one ? data.player_two : data.player_one;
Alert.alert("Opponent found!", `${opponent} will take you on!`);
this.setState({
is_loading: false,
username: ""
});
this.props.navigation.navigate("Quiz", {
pusher: this.pusher,
username: username,
opponent: opponent,
my_channel: this.my_channel
});
});
});
}
};
}